Update shader.frag
This commit is contained in:
parent
664eb5872a
commit
8908ef1332
1 changed files with 23 additions and 8 deletions
|
|
@ -15,19 +15,34 @@ 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;
|
||||
float baseWeight = 0.2;
|
||||
float dominantWeight = 0.4;
|
||||
|
||||
vec4 blendedColor = vec4(0.0);
|
||||
vec4 weights = vec4(baseWeight);
|
||||
vec2 uvOffsets[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
float type = TexType[i];
|
||||
uvOffsets[i] = vec2(mod(type, 8.0), floor(type / 8.0)) * tileSize;
|
||||
if (type == RealType) {
|
||||
weights[i] = dominantWeight;
|
||||
}
|
||||
}
|
||||
|
||||
vec4 blendedColor[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vec2 uv = TexCoord * tileSize + uvOffsets[i];
|
||||
blendedColor += texture(texture0, uv) * 0.25;
|
||||
blendedColor[i] = texture(texture0, uv);
|
||||
}
|
||||
|
||||
float weightX = TexCoord.x;
|
||||
float weightY = TexCoord.y;
|
||||
|
||||
vec4 mix1 = mix(blendedColor[0], blendedColor[2], weightX);
|
||||
vec4 mix2 = mix(blendedColor[1], blendedColor[3], weightX);
|
||||
vec4 finalColor = mix(mix1, mix2, weightY);
|
||||
|
||||
|
||||
float distance = length(viewPos - FragPos);
|
||||
float interpolationFactor = clamp(distance / 1000.0, 0.0, 1.0);
|
||||
outputColor = mix(blendedColor, FarColor, interpolationFactor);
|
||||
outputColor = mix(finalColor, FarColor, interpolationFactor);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue