Till Busch - effects, shaders and textures for crop and water effects
Incorporated changes to effects file syntax. Changed Till's landmass to mix in the base terrain texture. Some shader cleanup. Also, add a GUI control for enabling shaders.
This commit is contained in:
parent
53e5e5120f
commit
943ba2a4fe
15 changed files with 584 additions and 18 deletions
103
Effects/crop.eff
Normal file
103
Effects/crop.eff
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PropertyList>
|
||||
<name>Effects/crop</name>
|
||||
<inherits-from>Effects/terrain-default</inherits-from>
|
||||
<parameters>
|
||||
<texture n="2">
|
||||
<image>Textures/Terrain/crop.png</image>
|
||||
<filter>linear-mipmap-linear</filter>
|
||||
<wrap-s>repeat</wrap-s>
|
||||
<wrap-t>repeat</wrap-t>
|
||||
<internal-format>normalized</internal-format>
|
||||
</texture>
|
||||
<texture n="3">
|
||||
<image>Textures/Terrain/cropcolors.png</image>
|
||||
<filter>linear-mipmap-linear</filter>
|
||||
<wrap-s>mirror</wrap-s>
|
||||
<internal-format>normalized</internal-format>
|
||||
</texture>
|
||||
</parameters>
|
||||
<technique n="9">
|
||||
<predicate>
|
||||
<and>
|
||||
<property>/sim/rendering/shader-experimental</property>
|
||||
<property>/sim/rendering/shader-effects</property>
|
||||
<or>
|
||||
<less-equal>
|
||||
<value type="float">2.0</value>
|
||||
<glversion/>
|
||||
</less-equal>
|
||||
<and>
|
||||
<extension-supported>GL_ARB_shader_objects</extension-supported>
|
||||
<extension-supported>GL_ARB_shading_language_100</extension-supported>
|
||||
<extension-supported>GL_ARB_vertex_shader</extension-supported>
|
||||
<extension-supported>GL_ARB_fragment_shader</extension-supported>
|
||||
</and>
|
||||
</or>
|
||||
</and>
|
||||
</predicate>
|
||||
<pass>
|
||||
<lighting>true</lighting>
|
||||
<!-- Use material values that are either inherited from the
|
||||
terrain-default effect or supplied by an effect derived
|
||||
from this one e.g., one created in the materials library. -->
|
||||
<material>
|
||||
<ambient><use>material/ambient</use></ambient>
|
||||
<diffuse><use>material/diffuse</use></diffuse>
|
||||
<specular><use>material/specular</use></specular>
|
||||
<color-mode>ambient-and-diffuse</color-mode>
|
||||
</material>
|
||||
<blend><use>transparent</use></blend>
|
||||
<alpha-test><use>transparent</use></alpha-test>
|
||||
<shade-model>smooth</shade-model>
|
||||
<cull-face>back</cull-face>
|
||||
<render-bin>
|
||||
<bin-number><use>render-bin/bin-number</use></bin-number>
|
||||
<bin-name><use>render-bin/bin-name</use></bin-name>
|
||||
</render-bin>
|
||||
<texture-unit>
|
||||
<unit>0</unit>
|
||||
<type>noise</type>
|
||||
</texture-unit>
|
||||
<texture-unit>
|
||||
<unit>1</unit>
|
||||
<image><use>texture[2]/image</use></image>
|
||||
<filter><use>texture[2]/filter</use></filter>
|
||||
<wrap-s><use>texture[2]/wrap-s</use></wrap-s>
|
||||
<wrap-t><use>texture[2]/wrap-t</use></wrap-t>
|
||||
<internal-format>
|
||||
<use>texture[2]/internal-format</use>
|
||||
</internal-format>
|
||||
</texture-unit>
|
||||
<texture-unit>
|
||||
<unit>2</unit>
|
||||
<type>1d</type>
|
||||
<image><use>texture[3]/image</use></image>
|
||||
<filter><use>texture[3]/filter</use></filter>
|
||||
<wrap-s><use>texture[3]/wrap-s</use></wrap-s>
|
||||
<internal-format>
|
||||
<use>texture[3]/internal-format</use>
|
||||
</internal-format>
|
||||
</texture-unit>
|
||||
<program>
|
||||
<vertex-shader>Shaders/crop.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/crop.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>NoiseTex</name>
|
||||
<type>sampler-3d</type>
|
||||
<value type="int">0</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>SampleTex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">1</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>ColorsTex</name>
|
||||
<type>sampler-1d</type>
|
||||
<value type="int">2</value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
</PropertyList>
|
71
Effects/landmass.eff
Normal file
71
Effects/landmass.eff
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PropertyList>
|
||||
<name>Effects/landmass</name>
|
||||
<inherits-from>Effects/terrain-default</inherits-from>
|
||||
<parameters>
|
||||
</parameters>
|
||||
<technique n="9">
|
||||
<predicate>
|
||||
<and>
|
||||
<property>/sim/rendering/shader-experimental</property>
|
||||
<property>/sim/rendering/shader-effects</property>
|
||||
<or>
|
||||
<less-equal>
|
||||
<value type="float">2.0</value>
|
||||
<glversion/>
|
||||
</less-equal>
|
||||
<and>
|
||||
<extension-supported>GL_ARB_shader_objects</extension-supported>
|
||||
<extension-supported>GL_ARB_shading_language_100</extension-supported>
|
||||
<extension-supported>GL_ARB_vertex_shader</extension-supported>
|
||||
<extension-supported>GL_ARB_fragment_shader</extension-supported>
|
||||
</and>
|
||||
</or>
|
||||
</and>
|
||||
</predicate>
|
||||
<pass>
|
||||
<lighting>true</lighting>
|
||||
<material>
|
||||
<ambient><use>material/ambient</use></ambient>
|
||||
<diffuse><use>material/diffuse</use></diffuse>
|
||||
<specular><use>material/specular</use></specular>
|
||||
<color-mode>ambient-and-diffuse</color-mode>
|
||||
</material>
|
||||
<blend><use>transparent</use></blend>
|
||||
<alpha-test><use>transparent</use></alpha-test>
|
||||
<shade-model>smooth</shade-model>
|
||||
<cull-face>back</cull-face>
|
||||
<render-bin>
|
||||
<bin-number><use>render-bin/bin-number</use></bin-number>
|
||||
<bin-name><use>render-bin/bin-name</use></bin-name>
|
||||
</render-bin>
|
||||
<texture-unit>
|
||||
<unit>0</unit>
|
||||
<type>noise</type>
|
||||
</texture-unit>
|
||||
<texture-unit>
|
||||
<unit>1</unit>
|
||||
<image><use>texture[0]/image</use></image>
|
||||
<filter><use>texture[0]/filter</use></filter>
|
||||
<wrap-s><use>texture[0]/wrap-s</use></wrap-s>
|
||||
<wrap-t><use>texture[0]/wrap-t</use></wrap-t>
|
||||
<internal-format>
|
||||
<use>texture[0]/internal-format</use>
|
||||
</internal-format>
|
||||
</texture-unit>
|
||||
<program>
|
||||
<vertex-shader>Shaders/landmass.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/landmass.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>NoiseTex</name>
|
||||
<type>sampler-3d</type>
|
||||
<value type="int">0</value></uniform>
|
||||
<uniform>
|
||||
<name>BaseTex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">1</value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
</PropertyList>
|
|
@ -19,7 +19,6 @@
|
|||
<shininess>1.2</shininess>
|
||||
</material>
|
||||
<texture n="0">
|
||||
<texture2d>
|
||||
<image>Textures/Terrain/unknown.png</image>
|
||||
<filter>linear-mipmap-linear</filter>
|
||||
<!-- also repeat -->
|
||||
|
@ -30,7 +29,6 @@
|
|||
-->
|
||||
<!-- float, signed-integer, integer -->
|
||||
<internal-format>normalized</internal-format>
|
||||
</texture2d>
|
||||
</texture>
|
||||
<transparent>false</transparent>
|
||||
<render-bin>
|
||||
|
@ -38,7 +36,9 @@
|
|||
<bin-name>RenderBin</bin-name>
|
||||
</render-bin>
|
||||
</parameters>
|
||||
<technique>
|
||||
<!-- put techniques at a "high" index to allow derived effects to
|
||||
insert their own techniques first. -->
|
||||
<technique n="10">
|
||||
<predicate>
|
||||
<and>
|
||||
<property>/sim/rendering/shader-effects</property>
|
||||
|
@ -74,15 +74,13 @@
|
|||
</render-bin>
|
||||
<texture-unit>
|
||||
<unit>0</unit>
|
||||
<texture2d><use>texture[0]/texture2d</use>
|
||||
<image><use>texture[0]/texture2d/image</use></image>
|
||||
<filter><use>texture[0]/texture2d/filter</use></filter>
|
||||
<wrap-s><use>texture[0]/texture2d/wrap-s</use></wrap-s>
|
||||
<wrap-t><use>texture[0]/texture2d/wrap-t</use></wrap-t>
|
||||
<image><use>texture[0]/image</use></image>
|
||||
<filter><use>texture[0]/filter</use></filter>
|
||||
<wrap-s><use>texture[0]/wrap-s</use></wrap-s>
|
||||
<wrap-t><use>texture[0]/wrap-t</use></wrap-t>
|
||||
<internal-format>
|
||||
<use>texture[0]/texture2d/internal-format</use>
|
||||
<use>texture[0]/internal-format</use>
|
||||
</internal-format>
|
||||
</texture2d>
|
||||
</texture-unit>
|
||||
<program>
|
||||
<vertex-shader>Shaders/default.vert</vertex-shader>
|
||||
|
@ -94,7 +92,7 @@
|
|||
<value type="int">0</value></uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
<technique>
|
||||
<technique n="11">
|
||||
<pass>
|
||||
<lighting>true</lighting>
|
||||
<material>
|
||||
|
@ -113,15 +111,13 @@
|
|||
</render-bin>
|
||||
<texture-unit>
|
||||
<unit>0</unit>
|
||||
<texture2d><use>texture[0]/texture2d</use>
|
||||
<image><use>texture[0]/texture2d/image</use></image>
|
||||
<filter><use>texture[0]/texture2d/filter</use></filter>
|
||||
<wrap-s><use>texture[0]/texture2d/wrap-s</use></wrap-s>
|
||||
<wrap-t><use>texture[0]/texture2d/wrap-t</use></wrap-t>
|
||||
<image><use>texture[0]/image</use></image>
|
||||
<filter><use>texture[0]/filter</use></filter>
|
||||
<wrap-s><use>texture[0]/wrap-s</use></wrap-s>
|
||||
<wrap-t><use>texture[0]/wrap-t</use></wrap-t>
|
||||
<internal-format>
|
||||
<use>texture[0]/texture2d/internal-format</use>
|
||||
<use>texture[0]/internal-format</use>
|
||||
</internal-format>
|
||||
</texture2d>
|
||||
<environment>
|
||||
<mode>modulate</mode>
|
||||
</environment>
|
||||
|
|
56
Effects/water.eff
Normal file
56
Effects/water.eff
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PropertyList>
|
||||
<name>Effects/water</name>
|
||||
<inherits-from>Effects/terrain-default</inherits-from>
|
||||
<parameters>
|
||||
</parameters>
|
||||
<technique n="9">
|
||||
<predicate>
|
||||
<and>
|
||||
<property>/sim/rendering/shader-experimental</property>
|
||||
<property>/sim/rendering/shader-effects</property>
|
||||
<or>
|
||||
<less-equal>
|
||||
<value type="float">2.0</value>
|
||||
<glversion/>
|
||||
</less-equal>
|
||||
<and>
|
||||
<extension-supported>GL_ARB_shader_objects</extension-supported>
|
||||
<extension-supported>GL_ARB_shading_language_100</extension-supported>
|
||||
<extension-supported>GL_ARB_vertex_shader</extension-supported>
|
||||
<extension-supported>GL_ARB_fragment_shader</extension-supported>
|
||||
</and>
|
||||
</or>
|
||||
</and>
|
||||
</predicate>
|
||||
<pass>
|
||||
<lighting>true</lighting>
|
||||
<material>
|
||||
<ambient><use>material/ambient</use></ambient>
|
||||
<diffuse><use>material/diffuse</use></diffuse>
|
||||
<specular><use>material/specular</use></specular>
|
||||
<color-mode>ambient-and-diffuse</color-mode>
|
||||
</material>
|
||||
<blend><use>transparent</use></blend>
|
||||
<alpha-test><use>transparent</use></alpha-test>
|
||||
<shade-model>smooth</shade-model>
|
||||
<cull-face>back</cull-face>
|
||||
<render-bin>
|
||||
<bin-number><use>render-bin/bin-number</use></bin-number>
|
||||
<bin-name><use>render-bin/bin-name</use></bin-name>
|
||||
</render-bin>
|
||||
<texture-unit>
|
||||
<unit>0</unit>
|
||||
<type>noise</type>
|
||||
</texture-unit>
|
||||
<program>
|
||||
<vertex-shader>Shaders/water.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/water.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>texture</name>
|
||||
<type>sampler-3d</type>
|
||||
<value type="int">0</value></uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
</PropertyList>
|
73
Shaders/crop.frag
Normal file
73
Shaders/crop.frag
Normal file
|
@ -0,0 +1,73 @@
|
|||
#version 120
|
||||
|
||||
varying vec4 rawpos;
|
||||
varying vec4 ecPosition;
|
||||
varying vec3 VNormal;
|
||||
varying vec3 Normal;
|
||||
|
||||
uniform sampler3D NoiseTex;
|
||||
uniform sampler2D SampleTex;
|
||||
uniform sampler1D ColorsTex;
|
||||
|
||||
const float scale = 1.0;
|
||||
|
||||
const vec4 red = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
const vec4 green = vec4(0.0, 1.0, 0.0, 1.0);
|
||||
const vec4 blue = vec4(0.0, 0.0, 1.0, 1.0);
|
||||
const vec4 yellow = vec4(1.0, 1.0, 0.0, 1.0);
|
||||
|
||||
#define BLA 1
|
||||
#define BLA2 0
|
||||
|
||||
void main (void)
|
||||
{
|
||||
const float snowlevel=2000.0;
|
||||
|
||||
vec4 basecolor = texture2D(SampleTex, rawpos.xy*0.000144);
|
||||
basecolor = texture1D(ColorsTex, basecolor.r+0.00);
|
||||
|
||||
vec4 noisevec = texture3D(NoiseTex, (rawpos.xyz)*0.01*scale);
|
||||
|
||||
vec4 nvL = texture3D(NoiseTex, (rawpos.xyz)*0.00066*scale);
|
||||
vec4 km = floor((rawpos)/1000.0);
|
||||
|
||||
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 biasFactor = fogFactor = clamp(fogFactor, 0.0, 1.0);
|
||||
|
||||
float n=0.06;
|
||||
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);
|
||||
|
||||
// good
|
||||
vec4 c1;
|
||||
c1 = basecolor * vec4(smoothstep(0.0, 1.15, n), smoothstep(0.0, 1.2, n), smoothstep(0.1, 1.3, n), 1.0);
|
||||
//"steep = gray"
|
||||
c1 = mix(vec4(n-0.42, n-0.44, n-0.51, 1.0), c1, smoothstep(0.970, 0.990, abs(normalize(Normal).z)+nvL[2]*1.3));
|
||||
//"snow"
|
||||
c1 = mix(c1, clamp(n+nvL[2]*4.1+vec4(0.1, 0.1, nvL[2]*2.2, 1.0), 0.7, 1.0), smoothstep(snowlevel+300.0, snowlevel+360.0, (rawpos.z)+nvL[1]*3000.0));
|
||||
|
||||
vec3 diffuse = gl_FrontMaterial.diffuse.rgb * max(0.0, dot(VNormal, gl_LightSource[0].position.xyz));
|
||||
vec4 ambientColor = gl_FrontLightModelProduct.sceneColor + gl_LightSource[0].ambient * gl_FrontMaterial.ambient;
|
||||
// ambientColor = vec4(0.01);
|
||||
vec4 ambient_light = ambientColor + 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);
|
||||
}
|
20
Shaders/crop.vert
Normal file
20
Shaders/crop.vert
Normal file
|
@ -0,0 +1,20 @@
|
|||
#version 120
|
||||
|
||||
varying vec4 rawpos;
|
||||
varying vec4 ecPosition;
|
||||
varying vec3 VNormal;
|
||||
varying vec3 Normal;
|
||||
centroid varying vec4 ipos;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
rawpos = gl_Vertex;
|
||||
ipos = gl_Vertex;
|
||||
ecPosition = gl_ModelViewMatrix * gl_Vertex;
|
||||
VNormal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
Normal = normalize(gl_Normal);
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
58
Shaders/landmass.frag
Normal file
58
Shaders/landmass.frag
Normal file
|
@ -0,0 +1,58 @@
|
|||
#version 120
|
||||
|
||||
varying vec4 rawpos;
|
||||
varying vec4 ecPosition;
|
||||
varying vec3 VNormal;
|
||||
varying vec3 Normal;
|
||||
|
||||
uniform sampler3D NoiseTex;
|
||||
uniform sampler2D BaseTex;
|
||||
|
||||
const float scale = 1.0;
|
||||
|
||||
void main (void)
|
||||
{
|
||||
const float snowlevel=2000.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 biasFactor = fogFactor = clamp(fogFactor, 0.0, 1.0);
|
||||
|
||||
float n=0.06;
|
||||
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);
|
||||
// good
|
||||
vec4 c1 = texture2D(BaseTex, gl_TexCoord[0].st);
|
||||
//brown
|
||||
//c1 = mix(c1, vec4(n-0.46, n-0.45, n-0.53, 1.0), smoothstep(0.50, 0.55, nvL[2]*6.6));
|
||||
//"steep = gray"
|
||||
c1 = mix(vec4(n-0.30, n-0.29, n-0.37, 1.0), c1, smoothstep(0.970, 0.990, abs(normalize(Normal).z)+nvL[2]*1.3));
|
||||
//"snow"
|
||||
c1 = mix(c1, clamp(n+nvL[2]*4.1+vec4(0.1, 0.1, nvL[2]*2.2, 1.0), 0.7, 1.0), smoothstep(snowlevel+300.0, snowlevel+360.0, (rawpos.z)+nvL[1]*3000.0));
|
||||
|
||||
vec3 diffuse = gl_FrontMaterial.diffuse.rgb * max(0.0, dot(normalize(VNormal), gl_LightSource[0].position.xyz));
|
||||
vec4 ambientColor = gl_FrontLightModelProduct.sceneColor + gl_LightSource[0].ambient * gl_FrontMaterial.ambient;
|
||||
// ambientColor = vec4(0.01);
|
||||
vec4 ambient_light = ambientColor + 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);
|
||||
}
|
15
Shaders/landmass.vert
Normal file
15
Shaders/landmass.vert
Normal file
|
@ -0,0 +1,15 @@
|
|||
varying vec4 rawpos;
|
||||
varying vec4 ecPosition;
|
||||
varying vec3 VNormal;
|
||||
varying vec3 Normal;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
rawpos = gl_Vertex;
|
||||
ecPosition = gl_ModelViewMatrix * gl_Vertex;
|
||||
VNormal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
Normal = normalize(gl_Normal);
|
||||
|
||||
gl_Position = ftransform();
|
||||
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
|
||||
}
|
102
Shaders/water.frag
Normal file
102
Shaders/water.frag
Normal file
|
@ -0,0 +1,102 @@
|
|||
#version 120
|
||||
|
||||
varying vec4 rawpos;
|
||||
varying vec4 ecPosition;
|
||||
varying vec3 VNormal;
|
||||
varying vec3 Normal;
|
||||
varying vec3 lightVec;
|
||||
|
||||
uniform sampler3D NoiseTex;
|
||||
uniform float osg_SimulationTime;
|
||||
|
||||
const float scale = 1.0;
|
||||
|
||||
void main (void)
|
||||
{
|
||||
const float snowlevel=2000.0;
|
||||
vec4 noisevecS = texture3D(NoiseTex, (rawpos.xyz)*0.0126);
|
||||
vec4 nvLS = texture3D(NoiseTex, (rawpos.xyz)*-0.0003323417);
|
||||
|
||||
vec4 noisevec = texture3D(NoiseTex, (rawpos.xyz)*0.00423+vec3(0.0,0.0,osg_SimulationTime*0.035217));
|
||||
vec4 nvL = texture3D(NoiseTex, (rawpos.xyz)*0.001223417+(0.0,0.0,osg_SimulationTime*-0.0212));
|
||||
|
||||
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);
|
||||
fogFactor = clamp(fogFactor, 0.0, 1.0);
|
||||
|
||||
float a=1.0;
|
||||
float n=0.00;
|
||||
n += nvLS[0]*a;
|
||||
a/=2.0;
|
||||
n += nvLS[1]*a;
|
||||
a/=2.0;
|
||||
n += nvLS[2]*a;
|
||||
a/=2.0;
|
||||
n += nvLS[3]*a;
|
||||
|
||||
a=4.0;
|
||||
float na=n;
|
||||
na += nvL[0]*1.1;
|
||||
a*=1.2;
|
||||
na += nvL[1]*a;
|
||||
a*=1.2;
|
||||
na += nvL[2]*a;
|
||||
a*=1.2;
|
||||
na += nvL[3]*a;
|
||||
a=2.0;
|
||||
na += noisevec[0]*a*0.2;
|
||||
a*=1.2;
|
||||
na += noisevec[1]*a;
|
||||
a*=1.2;
|
||||
na += noisevec[2]*a;
|
||||
a*=1.2;
|
||||
na += noisevec[3]*a;
|
||||
|
||||
// GOOD
|
||||
|
||||
vec4 c1;
|
||||
c1 = vec4(smoothstep(0.0, 2.2, n), smoothstep(-0.1, 2.10, n), smoothstep(-0.2, 2.0, n), 1.0);
|
||||
/*
|
||||
|
||||
vec3 Reflected = normalize(reflect(-normalize(lightVec), normalize(VNormal+nvL[2]*0.8)));
|
||||
vec3 bump = normalize(VNormal+vec3(0.0, 0.0, nvL[0]*1.4+nvL[1]*6.4+nvL[2]*16+noisevec[3]*3.3)*2.0-1.4);
|
||||
vec3 bumped = max(dot(normalize(Normal), normalize(bump)), 0.0);
|
||||
bumped=max(normalize(refract(lightVec, normalize(bump), 0.3)), 0.0);
|
||||
*/
|
||||
vec3 Eye = normalize(-ecPosition.xyz);
|
||||
vec3 Reflected = normalize(reflect(-normalize(lightVec), normalize(VNormal+vec3(0.0,0.0,na*0.10-0.24))));
|
||||
//Reflected = normalize(reflect(-normalize(lightVec), normalize(VNormal)));
|
||||
vec3 bump = normalize(VNormal+vec3(0.0, 0.0, na)-0.9);
|
||||
vec3 bumped;
|
||||
// = max(dot(normalize(Normal.xyz), normalize(bump)), vec3(0.0, 0.0, 0.0));
|
||||
bumped=max(normalize(refract(lightVec, normalize(bump), 0.16)), 0.0);
|
||||
|
||||
vec4 ambientColor = gl_LightSource[0].ambient;
|
||||
vec4 light = ambientColor;
|
||||
c1 *= light;
|
||||
|
||||
|
||||
// c1 += gl_LightSource[0].diffuse*0.5 * pow(max(dot(Reflected, Eye), 0.0), 2.0/*gl_FrontMaterial.shininess*/);
|
||||
// c1 *= pow(max(Reflected.x+Reflected.y+Reflected.z, 0.0), 1.0/*gl_FrontMaterial.shininess*/);
|
||||
// c1 *= 0.3;
|
||||
// c1 = vec4(0.0);
|
||||
// c1 = vec4(0.0);
|
||||
//c1 += (vec3(0.0, 0.01, 0.01)*n) * pow(max(Reflected.x+Reflected.y+Reflected.z, 0.0), 9.0/*gl_FrontMaterial.shininess*/);
|
||||
// c1 += gl_LightSource[0].specular*2.0 * pow(max(dot(bumped, Eye), 0.3), 89.0)/*gl_FrontMaterial.shininess*/;
|
||||
|
||||
|
||||
// HERE IS GOOD
|
||||
|
||||
c1 += (vec4(0.3, 0.34, 0.4, 1.0)-0.1)*gl_LightSource[0].diffuse * (bumped.r+bumped.g+bumped.b);
|
||||
// c1 = bumped;
|
||||
c1 += gl_LightSource[0].specular*2.0 * pow(max(dot(Reflected, Eye), 0.0), 90.0/*gl_FrontMaterial.shininess*/);
|
||||
vec4 finalColor = c1;
|
||||
|
||||
if(gl_Fog.density == 1.0)
|
||||
fogFactor=1.0;
|
||||
|
||||
gl_FragColor = mix(gl_Fog.color ,finalColor, fogFactor);
|
||||
}
|
15
Shaders/water.vert
Normal file
15
Shaders/water.vert
Normal file
|
@ -0,0 +1,15 @@
|
|||
varying vec4 rawpos;
|
||||
varying vec4 ecPosition;
|
||||
varying vec3 VNormal;
|
||||
varying vec3 Normal;
|
||||
varying vec3 lightVec;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
rawpos = gl_Vertex;
|
||||
ecPosition = gl_ModelViewMatrix * gl_Vertex;
|
||||
VNormal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
Normal = normalize(gl_Normal);
|
||||
lightVec = normalize(gl_LightSource[0].position.xyz/* - ecPosition*/);
|
||||
gl_Position = ftransform();
|
||||
}
|
BIN
Textures/Terrain/crop.png
Normal file
BIN
Textures/Terrain/crop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 346 KiB |
BIN
Textures/Terrain/cropcolors.png
Normal file
BIN
Textures/Terrain/cropcolors.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 208 B |
|
@ -239,6 +239,49 @@
|
|||
</group>
|
||||
</group>
|
||||
|
||||
<hrule/>
|
||||
|
||||
<group>
|
||||
<padding>8</padding>
|
||||
<layout>hbox</layout>
|
||||
<group>
|
||||
<layout>vbox</layout>
|
||||
<valign>top</valign>
|
||||
<halign>left</halign>
|
||||
<text>
|
||||
<padding>-6</padding>
|
||||
<label>Shaders</label>
|
||||
<color>
|
||||
<red>0.5</red>
|
||||
<green>0.5</green>
|
||||
<blue>0.5</blue>
|
||||
</color>
|
||||
</text>
|
||||
</group>
|
||||
<group>
|
||||
<layout>vbox</layout>
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<checkbox>
|
||||
<halign>left</halign>
|
||||
<label>Enable</label>
|
||||
<property>/sim/rendering/shader-effects</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
</binding>
|
||||
</checkbox>
|
||||
<checkbox>
|
||||
<halign>left</halign>
|
||||
<label>Experimental effects</label>
|
||||
<property>/sim/rendering/shader-experimental</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
</binding>
|
||||
</checkbox>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<empty><stretch>true</stretch></empty>
|
||||
|
|
|
@ -675,6 +675,7 @@ Shared parameters for various materials.
|
|||
<name>EvergreenBroadCover</name>
|
||||
<name>Island</name>
|
||||
<name>Default</name>
|
||||
<effect>Effects/landmass</effect>
|
||||
<texture>Terrain/forest1a.png</texture>
|
||||
<texture>Terrain/forest1b.png</texture>
|
||||
<texture>Terrain/forest1c.png</texture>
|
||||
|
@ -698,6 +699,7 @@ Shared parameters for various materials.
|
|||
<value>summer</value>
|
||||
</equals>
|
||||
</condition>
|
||||
<effect>Effects/landmass</effect>
|
||||
<name>DeciduousBroadCover</name>
|
||||
<name>Bog</name>
|
||||
<texture>Terrain/deciduous1.png</texture>
|
||||
|
@ -723,6 +725,7 @@ Shared parameters for various materials.
|
|||
<value>summer</value>
|
||||
</equals>
|
||||
</condition>
|
||||
<effect>Effects/landmass</effect>
|
||||
<name>MixedForestCover</name>
|
||||
<texture>Terrain/mixedforest.png</texture>
|
||||
<texture>Terrain/mixedforest2.png</texture>
|
||||
|
@ -747,6 +750,7 @@ Shared parameters for various materials.
|
|||
<value>summer</value>
|
||||
</equals>
|
||||
</condition>
|
||||
<effect>Effects/landmass</effect>
|
||||
<name>EvergreenNeedleCover</name>
|
||||
<name>WoodedTundraCover</name>
|
||||
<texture>Terrain/evergreen.png</texture>
|
||||
|
@ -770,6 +774,7 @@ Shared parameters for various materials.
|
|||
<value>summer</value>
|
||||
</equals>
|
||||
</condition>
|
||||
<effect>Effects/landmass</effect>
|
||||
<name>DeciduousNeedleCover</name>
|
||||
<texture>Terrain/dec_evergreen.png</texture>
|
||||
<xsize>1000</xsize>
|
||||
|
@ -812,6 +817,7 @@ Shared parameters for various materials.
|
|||
<value>summer</value>
|
||||
</equals>
|
||||
</condition>
|
||||
<effect>Effects/landmass</effect>
|
||||
<name>ShrubCover</name>
|
||||
<name>ShrubGrassCover</name>
|
||||
<name>ScrubCover</name>
|
||||
|
@ -996,6 +1002,7 @@ Shared parameters for various materials.
|
|||
<value>summer</value>
|
||||
</equals>
|
||||
</condition>
|
||||
<effect>Effects/water</effect>
|
||||
<name>Lake</name>
|
||||
<name>Pond</name>
|
||||
<name>Reservoir</name>
|
||||
|
@ -1221,6 +1228,7 @@ Shared parameters for various materials.
|
|||
<value>summer</value>
|
||||
</equals>
|
||||
</condition>
|
||||
<effect>Effects/crop</effect>
|
||||
<name>MixedCropPastureCover</name>
|
||||
<texture>Terrain/mixedcrop1.png</texture>
|
||||
<texture>Terrain/mixedcrop4.png</texture>
|
||||
|
@ -1279,6 +1287,7 @@ Shared parameters for various materials.
|
|||
<value>summer</value>
|
||||
</equals>
|
||||
</condition>
|
||||
<effect>Effects/crop</effect>
|
||||
<name>IrrCropPastureCover</name>
|
||||
<texture>Terrain/irrcrop1.png</texture>
|
||||
<texture>Terrain/irrcrop2.png</texture>
|
||||
|
@ -1337,6 +1346,7 @@ Shared parameters for various materials.
|
|||
<value>summer</value>
|
||||
</equals>
|
||||
</condition>
|
||||
<effect>Effects/crop</effect>
|
||||
<name>DryCropPastureCover</name>
|
||||
<texture>Terrain/drycrop1.png</texture>
|
||||
<texture>Terrain/drycrop2.png</texture>
|
||||
|
@ -1396,6 +1406,7 @@ Shared parameters for various materials.
|
|||
<value>summer</value>
|
||||
</equals>
|
||||
</condition>
|
||||
<effect>Effects/crop</effect>
|
||||
<name>CropGrassCover</name>
|
||||
<texture>Terrain/cropgrass1.png</texture>
|
||||
<texture>Terrain/cropgrass2.png</texture>
|
||||
|
@ -1437,6 +1448,7 @@ Shared parameters for various materials.
|
|||
</equals>
|
||||
</condition>
|
||||
<name>CropWoodCover</name>
|
||||
<effect>Effects/landmass</effect>
|
||||
<texture>Terrain/cropwood.png</texture>
|
||||
<xsize>2000</xsize>
|
||||
<ysize>2000</ysize>
|
||||
|
@ -2303,6 +2315,7 @@ Shared parameters for various materials.
|
|||
|
||||
<material>
|
||||
<name>Ocean</name>
|
||||
<effect>Effects/water</effect>
|
||||
<texture>Terrain/water.png</texture>
|
||||
<xsize>400</xsize>
|
||||
<ysize>400</ysize>
|
||||
|
|
|
@ -112,6 +112,7 @@ Started September 2000 by David Megginson, david@megginson.com
|
|||
<enabled type="bool" userarchive="y">true</enabled>
|
||||
<debug type="bool" userarchive="y">false</debug>
|
||||
</shadows>
|
||||
<shader-experimental type="bool" userarchive="y">false</shader-experimental>
|
||||
<shader-effects type="bool" userarchive="y">true</shader-effects>
|
||||
<fps-display type="bool" userarchive="y">false</fps-display>
|
||||
<on-screen-statistics type="int">0</on-screen-statistics>
|
||||
|
|
Loading…
Add table
Reference in a new issue