Landmass update: add a triangle for the ground and don't apply relief on it
This commit is contained in:
parent
d73a93f284
commit
5d76d5f3f5
4 changed files with 29 additions and 10 deletions
|
@ -80,7 +80,7 @@
|
||||||
<vertex-shader>Shaders/landmass-g.vert</vertex-shader>
|
<vertex-shader>Shaders/landmass-g.vert</vertex-shader>
|
||||||
<geometry-shader>Shaders/landmass.geom</geometry-shader>
|
<geometry-shader>Shaders/landmass.geom</geometry-shader>
|
||||||
<fragment-shader>Shaders/landmass.frag</fragment-shader>
|
<fragment-shader>Shaders/landmass.frag</fragment-shader>
|
||||||
<geometry-vertices-out type="int">16</geometry-vertices-out>
|
<geometry-vertices-out type="int">20</geometry-vertices-out>
|
||||||
<geometry-input-type>triangles</geometry-input-type>
|
<geometry-input-type>triangles</geometry-input-type>
|
||||||
<geometry-output-type>triangle-strip</geometry-output-type>
|
<geometry-output-type>triangle-strip</geometry-output-type>
|
||||||
<attribute>
|
<attribute>
|
||||||
|
|
|
@ -7,6 +7,7 @@ varying vec3 VTangent;
|
||||||
varying vec3 VBinormal;
|
varying vec3 VBinormal;
|
||||||
varying vec3 Normal;
|
varying vec3 Normal;
|
||||||
varying vec4 constantColor;
|
varying vec4 constantColor;
|
||||||
|
varying float bump;
|
||||||
|
|
||||||
uniform sampler3D NoiseTex;
|
uniform sampler3D NoiseTex;
|
||||||
uniform sampler2D BaseTex;
|
uniform sampler2D BaseTex;
|
||||||
|
@ -53,16 +54,26 @@ float ray_intersect(sampler2D reliefMap, vec2 dp, vec2 ds)
|
||||||
|
|
||||||
void main (void)
|
void main (void)
|
||||||
{
|
{
|
||||||
vec3 V = normalize(ecPosition.xyz);
|
vec2 uv;
|
||||||
float a = dot(VNormal, -V);
|
vec3 N;
|
||||||
vec2 s = vec2(dot(V, VTangent), dot(V, VBinormal));
|
if ( bump > 0.9 )
|
||||||
s *= depth_factor / a;
|
{
|
||||||
vec2 ds = s;
|
vec3 V = normalize(ecPosition.xyz);
|
||||||
vec2 dp = gl_TexCoord[0].st;
|
float a = dot(VNormal, -V);
|
||||||
float d = ray_intersect(NormalTex, dp, ds);
|
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;
|
uv = dp + ds * d;
|
||||||
vec3 N = texture2D(NormalTex, uv).xyz * 2.0 - 1.0;
|
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);
|
vec4 noisevec = texture3D(NoiseTex, (rawpos.xyz)*0.01*scale);
|
||||||
|
|
|
@ -13,6 +13,7 @@ varying out vec3 VTangent;
|
||||||
varying out vec3 VBinormal;
|
varying out vec3 VBinormal;
|
||||||
varying out vec3 Normal;
|
varying out vec3 Normal;
|
||||||
varying out vec4 constantColor;
|
varying out vec4 constantColor;
|
||||||
|
varying out float bump;
|
||||||
|
|
||||||
uniform float canopy_height;
|
uniform float canopy_height;
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ void createVertex(int i, int j, float offset, float s)
|
||||||
VNormal = normalize(gl_NormalMatrix * Normal);
|
VNormal = normalize(gl_NormalMatrix * Normal);
|
||||||
VTangent = VTangentIn[i];
|
VTangent = VTangentIn[i];
|
||||||
VBinormal = VBinormalIn[i];
|
VBinormal = VBinormalIn[i];
|
||||||
|
bump = s;
|
||||||
|
|
||||||
gl_FrontColor = gl_FrontColorIn[i];
|
gl_FrontColor = gl_FrontColorIn[i];
|
||||||
constantColor = gl_FrontMaterial.emission
|
constantColor = gl_FrontMaterial.emission
|
||||||
|
@ -72,4 +74,8 @@ void main(void)
|
||||||
createVertex(1, 2, canopy_height, 1.0);
|
createVertex(1, 2, canopy_height, 1.0);
|
||||||
createVertex(2, 0, canopy_height, 1.0);
|
createVertex(2, 0, canopy_height, 1.0);
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
|
createVertex(0, 1, 0.0, 0.0);
|
||||||
|
createVertex(1, 2, 0.0, 0.0);
|
||||||
|
createVertex(2, 0, 0.0, 0.0);
|
||||||
|
EndPrimitive();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ varying vec3 VTangent;
|
||||||
varying vec3 VBinormal;
|
varying vec3 VBinormal;
|
||||||
varying vec3 Normal;
|
varying vec3 Normal;
|
||||||
varying vec4 constantColor;
|
varying vec4 constantColor;
|
||||||
|
varying float bump;
|
||||||
|
|
||||||
attribute vec3 tangent;
|
attribute vec3 tangent;
|
||||||
attribute vec3 binormal;
|
attribute vec3 binormal;
|
||||||
|
@ -17,6 +18,7 @@ void main(void)
|
||||||
VNormal = gl_NormalMatrix * gl_Normal;
|
VNormal = gl_NormalMatrix * gl_Normal;
|
||||||
VTangent = gl_NormalMatrix * tangent;
|
VTangent = gl_NormalMatrix * tangent;
|
||||||
VBinormal = gl_NormalMatrix * binormal;
|
VBinormal = gl_NormalMatrix * binormal;
|
||||||
|
bump = 1.0;
|
||||||
|
|
||||||
gl_FrontColor = gl_Color;
|
gl_FrontColor = gl_Color;
|
||||||
constantColor = gl_FrontMaterial.emission
|
constantColor = gl_FrontMaterial.emission
|
||||||
|
|
Loading…
Add table
Reference in a new issue