1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-21 18:11:11 +00:00

Normal maps generation on the fly.

Parallax mapping with slope information.
Overriding normal maps.
This commit is contained in:
RealBadAngel 2014-03-21 01:32:00 +01:00
parent f3d83a4516
commit 0dc1aec509
16 changed files with 735 additions and 434 deletions

View file

@ -1,13 +1,20 @@
uniform mat4 mWorldViewProj;
uniform mat4 mInvWorld;
uniform mat4 mTransWorld;
uniform mat4 mWorld;
uniform float dayNightRatio;
uniform float animationTimer;
uniform vec3 eyePosition;
varying vec3 vPosition;
varying vec3 worldPosition;
varying vec3 eyeVec;
varying vec3 lightVec;
const float BS = 10.0;
#ifdef ENABLE_WAVING_LEAVES
float smoothCurve( float x ) {
@ -27,7 +34,7 @@ void main(void)
#ifdef ENABLE_WAVING_LEAVES
vec4 pos = gl_Vertex;
vec4 pos2 = mTransWorld*gl_Vertex;
vec4 pos2 = mWorld*gl_Vertex;
pos.x += (smoothTriangleWave(animationTimer*10.0 + pos2.x * 0.01 + pos2.z * 0.01) * 2.0 - 1.0) * 0.4;
pos.y += (smoothTriangleWave(animationTimer*15.0 + pos2.x * -0.01 + pos2.z * -0.01) * 2.0 - 1.0) * 0.2;
pos.z += (smoothTriangleWave(animationTimer*10.0 + pos2.x * -0.01 + pos2.z * -0.01) * 2.0 - 1.0) * 0.4;
@ -36,10 +43,13 @@ void main(void)
gl_Position = mWorldViewProj * gl_Vertex;
#endif
vPosition = (mWorldViewProj * gl_Vertex).xyz;
vPosition = gl_Position.xyz;
worldPosition = (mWorld * gl_Vertex).xyz;
vec3 sunPosition = vec3 (0.0, eyePosition.y * BS + 900.0, 0.0);
lightVec = sunPosition - worldPosition;
eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;
vec4 color;
//color = vec4(1.0, 1.0, 1.0, 1.0);
@ -75,13 +85,8 @@ void main(void)
color = color * color; // SRGB -> Linear
if(gl_Normal.y <= 0.5)
color *= 0.6;
//color *= 0.7;
color = sqrt(color); // Linear -> SRGB
color.a = gl_Color.a;
gl_FrontColor = gl_BackColor = color;
gl_TexCoord[0] = gl_MultiTexCoord0;
}