mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Optimize shaders code. Add settings at compile time.
This commit is contained in:
parent
50b0e9f7a4
commit
dae03382bf
13 changed files with 181 additions and 195 deletions
|
@ -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));
|
||||
alpha = mix(alpha, 0.0, d);
|
||||
}
|
||||
gl_FragColor = vec4(col.r, col.g, col.b, alpha);
|
||||
gl_FragColor = vec4(col.r, col.g, col.b, alpha);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue