mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 00:25:19 +02:00
Optimize shaders code. Add settings at compile time.
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
#version 120
|
||||
|
||||
uniform sampler2D baseTexture;
|
||||
uniform sampler2D normalTexture;
|
||||
uniform sampler2D useNormalmap;
|
||||
|
||||
uniform float enableBumpmapping;
|
||||
|
||||
uniform vec4 skyBgColor;
|
||||
uniform float fogDistance;
|
||||
uniform vec3 eyePosition;
|
||||
@@ -19,12 +15,13 @@ void main (void)
|
||||
{
|
||||
vec3 color;
|
||||
vec2 uv = gl_TexCoord[0].st;
|
||||
|
||||
#ifdef NORMALS
|
||||
float use_normalmap = texture2D(useNormalmap,vec2(1.0,1.0)).r;
|
||||
float enable_bumpmapping = enableBumpmapping;
|
||||
|
||||
if ((enable_bumpmapping == 1.0) && (use_normalmap > 0.0)) {
|
||||
#ifdef USE_NORMALMAPS
|
||||
float use_normalmap = texture2D(useNormalmap,vec2(1.0,1.0)).r;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_BUMPMAPPING
|
||||
if (use_normalmap > 0.0) {
|
||||
vec3 base = texture2D(baseTexture, uv).rgb;
|
||||
vec3 vVec = normalize(eyeVec);
|
||||
vec3 bump = normalize(texture2D(normalTexture, uv).xyz * 2.0 - 1.0);
|
||||
@@ -53,5 +50,5 @@ void main (void)
|
||||
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
|
||||
col = mix(col, skyBgColor, d);
|
||||
}
|
||||
gl_FragColor = vec4(col.r, col.g, col.b, alpha);
|
||||
gl_FragColor = vec4(col.r, col.g, col.b, alpha);
|
||||
}
|
||||
|
Reference in New Issue
Block a user