diff --git a/Effects/forest.eff b/Effects/forest.eff new file mode 100644 index 000000000..52b2b8ad6 --- /dev/null +++ b/Effects/forest.eff @@ -0,0 +1,126 @@ + + + Effects/forest + Effects/terrain-default + + + Textures/Terrain/forest.png + linear-mipmap-linear + repeat + repeat + normalized + + + Textures/Terrain/forest-colors.png + linear-mipmap-linear + mirror + normalized + + + Textures/Terrain/forest.png + linear-mipmap-linear + repeat + repeat + normalized + + + + + + /sim/rendering/crop-shader + /sim/rendering/shader-effects + + + 2.0 + + + + GL_ARB_shader_objects + GL_ARB_shading_language_100 + GL_ARB_vertex_shader + GL_ARB_fragment_shader + + + + + + true + + + material/ambient + material/diffuse + material/specular + ambient-and-diffuse + + transparent + transparent + smooth + back + + render-bin/bin-number + render-bin/bin-name + + + 0 + noise + + + 1 + texture[2]/image + texture[2]/filter + texture[2]/wrap-s + texture[2]/wrap-t + + texture[2]/internal-format + + + + 3 + 1d + texture[3]/image + texture[3]/filter + texture[3]/wrap-s + + texture[3]/internal-format + + + + 2 + texture[4]/image + texture[4]/filter + texture[4]/wrap-s + texture[4]/wrap-t + + texture[4]/internal-format + + + + + Shaders/forest.vert + Shaders/forest.frag + + + NoiseTex + sampler-3d + 0 + + + SampleTex + sampler-2d + 1 + + + SampleTex2 + sampler-2d + 2 + + + ColorsTex + sampler-1d + 3 + + + + diff --git a/Shaders/forest.frag b/Shaders/forest.frag new file mode 100644 index 000000000..057b00c12 --- /dev/null +++ b/Shaders/forest.frag @@ -0,0 +1,72 @@ +#version 120 + +varying vec4 rawpos; +varying vec4 ecPosition; +varying vec3 VNormal; +varying vec3 Normal; + +uniform sampler3D NoiseTex; +uniform sampler2D SampleTex; +uniform sampler1D ColorsTex; +uniform sampler2D SampleTex2; + +const float scale = 1.0; + +void main (void) +{ + const float snowlevel=2000.0; + + vec4 basecolor = texture2D(SampleTex, rawpos.xy*0.000144); + vec4 basecolor2 = texture2D(SampleTex2, rawpos.xy*0.000144); + + basecolor = texture1D(ColorsTex, basecolor.r+0.0); + + vec4 noisevec = texture3D(NoiseTex, (rawpos.xyz)*0.01*scale); + + vec4 nvL = texture3D(NoiseTex, (rawpos.xyz)*0.00066*scale); + + float fogFactor; + float fogCoord = ecPosition.z; + const float LOG2 = 1.442695; + fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); + float biasFactor = exp2(-0.00000002 * fogCoord * fogCoord * LOG2); + + float n=0.12; + n += nvL[0]*0.4; + n += nvL[1]*0.6; + n += nvL[2]*2.0; + n += nvL[3]*4.0; + n += noisevec[0]*0.1; + n += noisevec[1]*0.4; + + n += noisevec[2]*0.8; + n += noisevec[3]*2.1; + n = mix(0.6, n, biasFactor); + + vec4 c1; + c1 = basecolor * vec4(smoothstep(-1.3, 0.5, n), smoothstep(-1.3, 0.5, n), smoothstep(-2.0, 0.9, n), 0.0); + + vec4 c2; + c2 = basecolor2 * vec4(smoothstep(-1.3, 0.5, n), smoothstep(-1.3, 0.5, n), smoothstep(-2.0, 0.9, n), 0.0); + + //draw floor where !steep, and another blurb for smoothing transitions + vec4 c3, c4, c5; + c3 = mix(vec4(n-0.88, n-0.14, -n, 0.0), c1, smoothstep(0.990, 0.970, abs(normalize(Normal).z)+nvL[2]*1.3)); + c4 = mix(vec4(n-0.88, n-0.74, -n, 0.0), c1, smoothstep(0.990, 0.890, abs(normalize(Normal).z)+nvL[2]*0.9)); + c5 = mix(c3, c4, 1.0); + + + //mix floor with texture right way + c1 = mix(c2, c5, clamp(0.65, n*0.5, 0.4)); + + vec3 diffuse = gl_Color.rgb * max(0.4, dot(VNormal, gl_LightSource[0].position.xyz)); + vec4 ambient_light = gl_LightSource[0].diffuse * vec4(diffuse, 1.0); + + c1 *= ambient_light; + vec4 finalColor = c1; + + if(gl_Fog.density == 1.0) + fogFactor=1.0; + + gl_FragColor = mix(gl_Fog.color ,finalColor, fogFactor); +} diff --git a/Shaders/forest.vert b/Shaders/forest.vert new file mode 100644 index 000000000..29f9ad7d0 --- /dev/null +++ b/Shaders/forest.vert @@ -0,0 +1,22 @@ +#version 120 + +varying vec4 rawpos; +varying vec4 ecPosition; +varying vec3 VNormal; +varying vec3 Normal; +//varying vec4 constantColor; + +void main(void) +{ + gl_TexCoord[0] = gl_MultiTexCoord0; + + rawpos = gl_Vertex; + ecPosition = gl_ModelViewMatrix * gl_Vertex; + VNormal = normalize(gl_NormalMatrix * gl_Normal); + Normal = normalize(gl_Normal); + + gl_FrontColor = gl_Color; + //constantColor = gl_FrontMaterial.emission + // + gl_Color * (gl_LightModel.ambient + gl_LightSource[0].ambient); + gl_Position = ftransform(); +} diff --git a/Textures/Terrain/forest-colors.png b/Textures/Terrain/forest-colors.png new file mode 100644 index 000000000..356b39d09 Binary files /dev/null and b/Textures/Terrain/forest-colors.png differ diff --git a/Textures/Terrain/forest.png b/Textures/Terrain/forest.png new file mode 100644 index 000000000..c285cda61 Binary files /dev/null and b/Textures/Terrain/forest.png differ