diff --git a/Effects/landmass.eff b/Effects/landmass.eff
index ad54d0aac..914a9ca4b 100644
--- a/Effects/landmass.eff
+++ b/Effects/landmass.eff
@@ -80,7 +80,7 @@
Shaders/landmass-g.vert
Shaders/landmass.geom
Shaders/landmass.frag
- 16
+ 20
triangles
triangle-strip
diff --git a/Shaders/landmass.frag b/Shaders/landmass.frag
index c8e2f42b8..c97069b6d 100644
--- a/Shaders/landmass.frag
+++ b/Shaders/landmass.frag
@@ -7,6 +7,7 @@ varying vec3 VTangent;
varying vec3 VBinormal;
varying vec3 Normal;
varying vec4 constantColor;
+varying float bump;
uniform sampler3D NoiseTex;
uniform sampler2D BaseTex;
@@ -53,16 +54,26 @@ float ray_intersect(sampler2D reliefMap, vec2 dp, vec2 ds)
void main (void)
{
- vec3 V = normalize(ecPosition.xyz);
- float a = dot(VNormal, -V);
- vec2 s = vec2(dot(V, VTangent), dot(V, VBinormal));
- s *= depth_factor / a;
- vec2 ds = s;
- vec2 dp = gl_TexCoord[0].st;
- float d = ray_intersect(NormalTex, dp, ds);
+ vec2 uv;
+ vec3 N;
+ if ( bump > 0.9 )
+ {
+ vec3 V = normalize(ecPosition.xyz);
+ float a = dot(VNormal, -V);
+ vec2 s = vec2(dot(V, VTangent), dot(V, VBinormal));
+ s *= depth_factor / a;
+ vec2 ds = s;
+ vec2 dp = gl_TexCoord[0].st;
+ float d = ray_intersect(NormalTex, dp, ds);
- vec2 uv = dp + ds * d;
- vec3 N = texture2D(NormalTex, uv).xyz * 2.0 - 1.0;
+ uv = dp + ds * d;
+ N = texture2D(NormalTex, uv).xyz * 2.0 - 1.0;
+ }
+ else
+ {
+ uv = gl_TexCoord[0].st;
+ N = vec3(0.0, 0.0, 1.0);
+ }
vec4 noisevec = texture3D(NoiseTex, (rawpos.xyz)*0.01*scale);
diff --git a/Shaders/landmass.geom b/Shaders/landmass.geom
index 16254ac14..6514f5417 100644
--- a/Shaders/landmass.geom
+++ b/Shaders/landmass.geom
@@ -13,6 +13,7 @@ varying out vec3 VTangent;
varying out vec3 VBinormal;
varying out vec3 Normal;
varying out vec4 constantColor;
+varying out float bump;
uniform float canopy_height;
@@ -41,6 +42,7 @@ void createVertex(int i, int j, float offset, float s)
VNormal = normalize(gl_NormalMatrix * Normal);
VTangent = VTangentIn[i];
VBinormal = VBinormalIn[i];
+ bump = s;
gl_FrontColor = gl_FrontColorIn[i];
constantColor = gl_FrontMaterial.emission
@@ -72,4 +74,8 @@ void main(void)
createVertex(1, 2, canopy_height, 1.0);
createVertex(2, 0, canopy_height, 1.0);
EndPrimitive();
+ createVertex(0, 1, 0.0, 0.0);
+ createVertex(1, 2, 0.0, 0.0);
+ createVertex(2, 0, 0.0, 0.0);
+ EndPrimitive();
}
diff --git a/Shaders/landmass.vert b/Shaders/landmass.vert
index 0c717001e..de27c5ac3 100644
--- a/Shaders/landmass.vert
+++ b/Shaders/landmass.vert
@@ -5,6 +5,7 @@ varying vec3 VTangent;
varying vec3 VBinormal;
varying vec3 Normal;
varying vec4 constantColor;
+varying float bump;
attribute vec3 tangent;
attribute vec3 binormal;
@@ -17,6 +18,7 @@ void main(void)
VNormal = gl_NormalMatrix * gl_Normal;
VTangent = gl_NormalMatrix * tangent;
VBinormal = gl_NormalMatrix * binormal;
+ bump = 1.0;
gl_FrontColor = gl_Color;
constantColor = gl_FrontMaterial.emission