]> git.lizzy.rs Git - dragonblocks_alpha.git/blobdiff - assets/shaders/3d/terrain/fragment.glsl
Make texture batching optional (for OpenGL 3.3 compat)
[dragonblocks_alpha.git] / assets / shaders / 3d / terrain / fragment.glsl
index 37bc56746cc76a2bf182f9e7a0b5bca60e40f59f..340eb48b68ecdb0f34c44af99497dacc7d4d052c 100755 (executable)
@@ -7,11 +7,22 @@ out vec4 outColor;
 
 uniform vec3 fogColor;
 uniform vec3 cameraPos;
-uniform sampler2D textures[MAX_TEXTURE_UNITS];
+
+#if TEXURE_BATCH_UNITS > 1
+uniform sampler2D textures[8];
+#else
+uniform sampler2D texture0;
+#endif
 
 void main()
 {
-       outColor = texture(textures[int(fragmentTextureIndex + 0.5)], fragmentTextureCoordinates) * vec4(fragmentColor, 1.0);
+#if TEXURE_BATCH_UNITS > 1
+       vec4 texel = texture(textures[int(fragmentTextureIndex + 0.5)], fragmentTextureCoordinates);
+#else
+       vec4 texel = texture(texture0, fragmentTextureCoordinates);
+#endif
+
+       outColor = texel * vec4(fragmentColor, 1.0);
        outColor.rgb = mix(outColor.rgb, fogColor, clamp(length(fragmentPosition - cameraPos) / VIEW_DISTANCE, 0.0, 1.0));
 
        if (outColor.a == 0.0)