Success to blend 4 texture
Need improuve for angle.
This commit is contained in:
parent
b9a2b87fe9
commit
664eb5872a
8 changed files with 186 additions and 105 deletions
|
|
@ -8,12 +8,26 @@ uniform sampler2D texture0;
|
|||
in vec4 FarColor;
|
||||
in vec3 FragPos;
|
||||
in vec2 TexCoord;
|
||||
in vec4 TexType;
|
||||
in float RealType;
|
||||
|
||||
void main()
|
||||
{
|
||||
float tileSize = 64.0 / 512.0;
|
||||
|
||||
vec2 uvOffsets[4];
|
||||
uvOffsets[0] = vec2(mod(TexType.x, 8.0), floor(TexType.x / 8.0)) * tileSize;
|
||||
uvOffsets[1] = vec2(mod(TexType.y, 8.0), floor(TexType.y / 8.0)) * tileSize;
|
||||
uvOffsets[2] = vec2(mod(TexType.z, 8.0), floor(TexType.z / 8.0)) * tileSize;
|
||||
uvOffsets[3] = vec2(mod(TexType.w, 8.0), floor(TexType.w / 8.0)) * tileSize;
|
||||
|
||||
vec4 blendedColor = vec4(0.0);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vec2 uv = TexCoord * tileSize + uvOffsets[i];
|
||||
blendedColor += texture(texture0, uv) * 0.25;
|
||||
}
|
||||
|
||||
float distance = length(viewPos - FragPos);
|
||||
float interpolationFactor = clamp(distance / 1000.0, 0.0, 1.0);
|
||||
|
||||
vec4 textureColor = texture(texture0, TexCoord);
|
||||
outputColor = mix(textureColor, FarColor, interpolationFactor);
|
||||
outputColor = mix(blendedColor, FarColor, interpolationFactor);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue