Optimise water shaders after ideas and suggestions by Thorsten Renk
Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
This commit is contained in:
parent
7e1ed19307
commit
9657518663
6 changed files with 277 additions and 349 deletions
|
@ -11,9 +11,6 @@
|
||||||
<internal-format>normalized</internal-format>
|
<internal-format>normalized</internal-format>
|
||||||
</texture>
|
</texture>
|
||||||
<texture n="2">
|
<texture n="2">
|
||||||
<!--<image>Textures/Water/water-normalmap.png</image>-->
|
|
||||||
<!--<image>Textures/Water/water-normalmap2.dds</image>-->
|
|
||||||
<!--<image>Textures/Water/water_sine_nmap.dds</image>-->
|
|
||||||
<image>Textures/Water/waves-ver10-nm.dds</image>
|
<image>Textures/Water/waves-ver10-nm.dds</image>
|
||||||
<filter>linear-mipmap-linear</filter>
|
<filter>linear-mipmap-linear</filter>
|
||||||
<wrap-s>repeat</wrap-s>
|
<wrap-s>repeat</wrap-s>
|
||||||
|
@ -21,11 +18,7 @@
|
||||||
<internal-format>normalized</internal-format>
|
<internal-format>normalized</internal-format>
|
||||||
</texture>
|
</texture>
|
||||||
<texture n="3">
|
<texture n="3">
|
||||||
<!--<image>Textures/Water/water-dudv.png</image>-->
|
<image>Textures/Water/water_sine_nmap.dds</image>
|
||||||
<!--<image>Textures/Water/dudvmap2.png</image>-->
|
|
||||||
<!--<image>Textures/Water/waves-ver10-dudv.dds</image>-->
|
|
||||||
<!--<image>Textures/Water/water-reflection-grey.png</image>-->
|
|
||||||
<image>Textures/Water/water_sine_nmap.dds</image>
|
|
||||||
<filter>linear-mipmap-linear</filter>
|
<filter>linear-mipmap-linear</filter>
|
||||||
<wrap-s>repeat</wrap-s>
|
<wrap-s>repeat</wrap-s>
|
||||||
<wrap-t>repeat</wrap-t>
|
<wrap-t>repeat</wrap-t>
|
||||||
|
@ -47,7 +40,6 @@
|
||||||
</texture>
|
</texture>
|
||||||
<texture n="6">
|
<texture n="6">
|
||||||
<image>Textures/Water/perlin-noise-nm.dds</image>
|
<image>Textures/Water/perlin-noise-nm.dds</image>
|
||||||
<!-- <image>Textures/Water/water_sine_nmap.dds</image> -->
|
|
||||||
<filter>linear-mipmap-linear</filter>
|
<filter>linear-mipmap-linear</filter>
|
||||||
<wrap-s>repeat</wrap-s>
|
<wrap-s>repeat</wrap-s>
|
||||||
<wrap-t>repeat</wrap-t>
|
<wrap-t>repeat</wrap-t>
|
||||||
|
@ -77,18 +69,12 @@
|
||||||
<cloud-cover n="4">
|
<cloud-cover n="4">
|
||||||
<use>/environment/clouds/layer[4]/coverage-type</use>
|
<use>/environment/clouds/layer[4]/coverage-type</use>
|
||||||
</cloud-cover>
|
</cloud-cover>
|
||||||
<!--<wind>
|
|
||||||
<use>/environment/wind-speed-kt</use>
|
|
||||||
</wind>-->
|
|
||||||
<windE>
|
<windE>
|
||||||
<use>/environment/sea/surface/wind-from-east-fps</use>
|
<use>/environment/sea/surface/wind-from-east-fps</use>
|
||||||
</windE>
|
</windE>
|
||||||
<windN>
|
<windN>
|
||||||
<use>/environment/sea/surface/wind-from-north-fps</use>
|
<use>/environment/sea/surface/wind-from-north-fps</use>
|
||||||
</windN>
|
</windN>
|
||||||
<!--wind-from> unused?
|
|
||||||
<use>/environment/config/boundary/entry[0]/wind-from-heading-deg</use>
|
|
||||||
</wind-from-->
|
|
||||||
<WaveFreq>
|
<WaveFreq>
|
||||||
<use>/environment/wave/freq</use>
|
<use>/environment/wave/freq</use>
|
||||||
</WaveFreq>
|
</WaveFreq>
|
||||||
|
@ -109,50 +95,74 @@
|
||||||
</WaveDAngle>
|
</WaveDAngle>
|
||||||
|
|
||||||
<!-- fog include -->
|
<!-- fog include -->
|
||||||
<visibility><use>/environment/ground-visibility-m</use></visibility>
|
<visibility>
|
||||||
<avisibility><use>/environment/visibility-m</use></avisibility>
|
<use>/environment/ground-visibility-m</use>
|
||||||
<lthickness><use>/environment/ground-haze-thickness-m</use></lthickness>
|
</visibility>
|
||||||
<scattering><use>/rendering/scene/scattering</use></scattering>
|
<avisibility>
|
||||||
<ground_scattering><use>/environment/surface/scattering</use></ground_scattering>
|
<use>/environment/visibility-m</use>
|
||||||
<terminator><use>/environment/terminator-relative-position-m</use></terminator>
|
</avisibility>
|
||||||
<terrain_alt><use>/environment/mean-terrain-elevation-m</use></terrain_alt>
|
<lthickness>
|
||||||
<overcast><use>/rendering/scene/overcast</use></overcast>
|
<use>/environment/ground-haze-thickness-m</use>
|
||||||
<eye_alt><use>/sim/rendering/eye-altitude-m</use></eye_alt>
|
</lthickness>
|
||||||
|
<scattering>
|
||||||
|
<use>/rendering/scene/scattering</use>
|
||||||
|
</scattering>
|
||||||
|
<ground_scattering>
|
||||||
|
<use>/environment/surface/scattering</use>
|
||||||
|
</ground_scattering>
|
||||||
|
<terminator>
|
||||||
|
<use>/environment/terminator-relative-position-m</use>
|
||||||
|
</terminator>
|
||||||
|
<terrain_alt>
|
||||||
|
<use>/environment/mean-terrain-elevation-m</use>
|
||||||
|
</terrain_alt>
|
||||||
|
<overcast>
|
||||||
|
<use>/rendering/scene/overcast</use>
|
||||||
|
</overcast>
|
||||||
|
<eye_alt>
|
||||||
|
<use>/sim/rendering/eye-altitude-m</use>
|
||||||
|
</eye_alt>
|
||||||
<fogtype>
|
<fogtype>
|
||||||
<use>/sim/rendering/shaders/skydome</use>
|
<use>/sim/rendering/shaders/skydome</use>
|
||||||
</fogtype>
|
</fogtype>
|
||||||
<!-- sea colors -->
|
<!-- sea colors -->
|
||||||
<sea_r><use>/environment/sea/color_r</use></sea_r>
|
<sea_r>
|
||||||
<sea_g><use>/environment/sea/color_g</use></sea_g>
|
<use>/environment/sea/color_r</use>
|
||||||
<sea_b><use>/environment/sea/color_b</use></sea_b>
|
</sea_r>
|
||||||
|
<sea_g>
|
||||||
|
<use>/environment/sea/color_g</use>
|
||||||
|
</sea_g>
|
||||||
|
<sea_b>
|
||||||
|
<use>/environment/sea/color_b</use>
|
||||||
|
</sea_b>
|
||||||
|
|
||||||
<!-- END fog include -->
|
<!-- END fog include -->
|
||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
|
|
||||||
<technique n="3">
|
<technique n="3">
|
||||||
<predicate>
|
<predicate>
|
||||||
<and>
|
<and>
|
||||||
<property>/sim/rendering/shaders/skydome</property>
|
<property>/sim/rendering/shaders/skydome</property>
|
||||||
<less-equal>
|
<less-equal>
|
||||||
<value type="float">4.0</value>
|
<value type="float">4.0</value>
|
||||||
<float-property>/sim/rendering/shaders/water</float-property>
|
<float-property>/sim/rendering/shaders/water</float-property>
|
||||||
</less-equal>
|
</less-equal>
|
||||||
<or>
|
<or>
|
||||||
<less-equal>
|
<less-equal>
|
||||||
<value type="float">2.0</value>
|
<value type="float">2.0</value>
|
||||||
<glversion/>
|
<glversion/>
|
||||||
</less-equal>
|
</less-equal>
|
||||||
<and>
|
<and>
|
||||||
<extension-supported>GL_ARB_shader_objects</extension-supported>
|
<extension-supported>GL_ARB_shader_objects</extension-supported>
|
||||||
<extension-supported>GL_ARB_shading_language_100</extension-supported>
|
<extension-supported>GL_ARB_shading_language_100</extension-supported>
|
||||||
<extension-supported>GL_ARB_vertex_shader</extension-supported>
|
<extension-supported>GL_ARB_vertex_shader</extension-supported>
|
||||||
<extension-supported>GL_ARB_fragment_shader</extension-supported>
|
<extension-supported>GL_ARB_fragment_shader</extension-supported>
|
||||||
</and>
|
</and>
|
||||||
</or>
|
</or>
|
||||||
</and>
|
</and>
|
||||||
</predicate>
|
</predicate>
|
||||||
|
|
||||||
<pass>
|
<pass>
|
||||||
<lighting>true</lighting>
|
<lighting>true</lighting>
|
||||||
<material>
|
<material>
|
||||||
|
@ -201,10 +211,6 @@
|
||||||
<use>texture[0]/internal-format</use>
|
<use>texture[0]/internal-format</use>
|
||||||
</internal-format>
|
</internal-format>
|
||||||
</texture-unit>-->
|
</texture-unit>-->
|
||||||
<!--<texture-unit>
|
|
||||||
<unit>1</unit>
|
|
||||||
<type>noise</type>
|
|
||||||
</texture-unit>-->
|
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
<unit>2</unit>
|
<unit>2</unit>
|
||||||
<image>
|
<image>
|
||||||
|
@ -297,9 +303,7 @@
|
||||||
</texture-unit>
|
</texture-unit>
|
||||||
|
|
||||||
<program>
|
<program>
|
||||||
<!-- <vertex-shader>Shaders/include_fog.vert</vertex-shader> -->
|
|
||||||
<vertex-shader>Shaders/water_lightfield.vert</vertex-shader>
|
<vertex-shader>Shaders/water_lightfield.vert</vertex-shader>
|
||||||
<!--<fragment-shader>Shaders/include_fog.frag</fragment-shader>-->
|
|
||||||
<fragment-shader>Shaders/water_lightfield.frag</fragment-shader>
|
<fragment-shader>Shaders/water_lightfield.frag</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
<!--<uniform>
|
<!--<uniform>
|
||||||
|
@ -307,11 +311,6 @@
|
||||||
<type>sampler-2d</type>
|
<type>sampler-2d</type>
|
||||||
<value type="int">0</value>
|
<value type="int">0</value>
|
||||||
</uniform>-->
|
</uniform>-->
|
||||||
<!--<uniform>
|
|
||||||
<name>Noise</name>
|
|
||||||
<type>sampler-3d</type>
|
|
||||||
<value type="int">1</value>
|
|
||||||
</uniform>-->
|
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>water_normalmap</name>
|
<name>water_normalmap</name>
|
||||||
<type>sampler-2d</type>
|
<type>sampler-2d</type>
|
||||||
|
@ -322,11 +321,6 @@
|
||||||
<type>sampler-2d</type>
|
<type>sampler-2d</type>
|
||||||
<value type="int">3</value>
|
<value type="int">3</value>
|
||||||
</uniform>
|
</uniform>
|
||||||
<!--<uniform>
|
|
||||||
<name>water_reflection_grey</name>
|
|
||||||
<type>sampler-2d</type>
|
|
||||||
<value type="int">4</value>
|
|
||||||
</uniform>-->
|
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>sea_foam</name>
|
<name>sea_foam</name>
|
||||||
<type>sampler-2d</type>
|
<type>sampler-2d</type>
|
||||||
|
@ -341,57 +335,10 @@
|
||||||
<name>saturation</name>
|
<name>saturation</name>
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
<!--<value>0.4</value>-->
|
<!--<value>0.4</value>-->
|
||||||
<value><use>saturation</use></value>
|
|
||||||
</uniform>
|
|
||||||
<!--<uniform>
|
|
||||||
<name>CloudCover0</name>
|
|
||||||
<type>float</type>
|
|
||||||
<value>
|
<value>
|
||||||
<use>cloud-cover[0]</use>
|
<use>saturation</use>
|
||||||
</value>
|
</value>
|
||||||
</uniform>
|
</uniform>
|
||||||
<uniform>
|
|
||||||
<name>CloudCover1</name>
|
|
||||||
<type>float</type>
|
|
||||||
<value>
|
|
||||||
<use>cloud-cover[1]</use>
|
|
||||||
</value>
|
|
||||||
</uniform>
|
|
||||||
<uniform>
|
|
||||||
<name>CloudCover2</name>
|
|
||||||
<type>float</type>
|
|
||||||
<value>
|
|
||||||
<use>cloud-cover[2]</use>
|
|
||||||
</value>
|
|
||||||
</uniform>
|
|
||||||
<uniform>
|
|
||||||
<name>CloudCover3</name>
|
|
||||||
<type>float</type>
|
|
||||||
<value>
|
|
||||||
<use>cloud-cover[3]</use>
|
|
||||||
</value>
|
|
||||||
</uniform>
|
|
||||||
<uniform>
|
|
||||||
<name>CloudCover4</name>
|
|
||||||
<type>float</type>
|
|
||||||
<value>
|
|
||||||
<use>cloud-cover[4]</use>
|
|
||||||
</value>
|
|
||||||
</uniform>
|
|
||||||
<uniform>
|
|
||||||
<name>Status</name>
|
|
||||||
<type>int</type>
|
|
||||||
<value>
|
|
||||||
<use>status</use>
|
|
||||||
</value>
|
|
||||||
</uniform>-->
|
|
||||||
<!--<uniform>
|
|
||||||
<name>Overcast</name>
|
|
||||||
<type>float</type>
|
|
||||||
<value>
|
|
||||||
<use>overcast</use>
|
|
||||||
</value>
|
|
||||||
</uniform>-->
|
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>WindE</name>
|
<name>WindE</name>
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
|
@ -406,13 +353,6 @@
|
||||||
<use>windN</use>
|
<use>windN</use>
|
||||||
</value>
|
</value>
|
||||||
</uniform>
|
</uniform>
|
||||||
<!-- uniform> unused?
|
|
||||||
<name>WindFrom</name>
|
|
||||||
<type>float</type>
|
|
||||||
<value>
|
|
||||||
<use>wind-from</use>
|
|
||||||
</value>
|
|
||||||
</uniform-->
|
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>WaveFreq</name>
|
<name>WaveFreq</name>
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
|
@ -458,7 +398,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- BEGIN fog include -->
|
<!-- BEGIN fog include -->
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>visibility</name>
|
<name>visibility</name>
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
|
@ -488,10 +428,12 @@
|
||||||
</value>
|
</value>
|
||||||
</uniform>
|
</uniform>
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>ground_scattering</name>
|
<name>ground_scattering</name>
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
<value><use>ground_scattering</use></value>
|
<value>
|
||||||
</uniform>
|
<use>ground_scattering</use>
|
||||||
|
</value>
|
||||||
|
</uniform>
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>terminator</name>
|
<name>terminator</name>
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
|
@ -499,48 +441,50 @@
|
||||||
<use>terminator</use>
|
<use>terminator</use>
|
||||||
</value>
|
</value>
|
||||||
</uniform>
|
</uniform>
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>terrain_alt</name>
|
<name>terrain_alt</name>
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
<value><use>terrain_alt</use></value>
|
|
||||||
</uniform>
|
|
||||||
<uniform>
|
|
||||||
<name>overcast</name>
|
|
||||||
<type>float</type>
|
|
||||||
<value><use>overcast</use></value>
|
|
||||||
</uniform>
|
|
||||||
<uniform>
|
|
||||||
<name>eye_alt</name>
|
|
||||||
<type>float</type>
|
|
||||||
<value><use>eye_alt</use></value>
|
|
||||||
</uniform>
|
|
||||||
<!-- sea colors -->
|
|
||||||
<uniform>
|
|
||||||
<name>sea_r</name>
|
|
||||||
<type>float</type>
|
|
||||||
<value><use>sea_r</use></value>
|
|
||||||
</uniform>
|
|
||||||
<uniform>
|
|
||||||
<name>sea_g</name>
|
|
||||||
<type>float</type>
|
|
||||||
<value><use>sea_g</use></value>
|
|
||||||
</uniform>
|
|
||||||
<uniform>
|
|
||||||
<name>sea_b</name>
|
|
||||||
<type>float</type>
|
|
||||||
<value><use>sea_b</use></value>
|
|
||||||
</uniform>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--<uniform>
|
|
||||||
<name>fogType</name>
|
|
||||||
<type>int</type>
|
|
||||||
<value>
|
<value>
|
||||||
<use>fogtype</use>
|
<use>terrain_alt</use>
|
||||||
</value>
|
</value>
|
||||||
</uniform>-->
|
</uniform>
|
||||||
<!-- END fog include -->
|
<uniform>
|
||||||
|
<name>overcast</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value>
|
||||||
|
<use>overcast</use>
|
||||||
|
</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>eye_alt</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value>
|
||||||
|
<use>eye_alt</use>
|
||||||
|
</value>
|
||||||
|
</uniform>
|
||||||
|
<!-- sea colors -->
|
||||||
|
<uniform>
|
||||||
|
<name>sea_r</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value>
|
||||||
|
<use>sea_r</use>
|
||||||
|
</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>sea_g</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value>
|
||||||
|
<use>sea_g</use>
|
||||||
|
</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>sea_b</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value>
|
||||||
|
<use>sea_b</use>
|
||||||
|
</value>
|
||||||
|
</uniform>
|
||||||
|
<!-- END fog include -->
|
||||||
</pass>
|
</pass>
|
||||||
</technique>
|
</technique>
|
||||||
|
|
||||||
|
@ -598,6 +542,7 @@
|
||||||
<use>render-bin/bin-name</use>
|
<use>render-bin/bin-name</use>
|
||||||
</bin-name>
|
</bin-name>
|
||||||
</render-bin>
|
</render-bin>
|
||||||
|
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
<unit>0</unit>
|
<unit>0</unit>
|
||||||
<image>
|
<image>
|
||||||
|
@ -616,7 +561,6 @@
|
||||||
<use>texture[0]/internal-format</use>
|
<use>texture[0]/internal-format</use>
|
||||||
</internal-format>
|
</internal-format>
|
||||||
</texture-unit>
|
</texture-unit>
|
||||||
|
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
<unit>2</unit>
|
<unit>2</unit>
|
||||||
<image>
|
<image>
|
||||||
|
@ -709,7 +653,6 @@
|
||||||
</texture-unit>
|
</texture-unit>
|
||||||
|
|
||||||
<program>
|
<program>
|
||||||
<!-- <vertex-shader>Shaders/include_fog.vert</vertex-shader> -->
|
|
||||||
<vertex-shader>Shaders/water.vert</vertex-shader>
|
<vertex-shader>Shaders/water.vert</vertex-shader>
|
||||||
<fragment-shader>Shaders/include_fog.frag</fragment-shader>
|
<fragment-shader>Shaders/include_fog.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/water_sine.frag</fragment-shader>
|
<fragment-shader>Shaders/water_sine.frag</fragment-shader>
|
||||||
|
@ -719,7 +662,6 @@
|
||||||
<type>sampler-2d</type>
|
<type>sampler-2d</type>
|
||||||
<value type="int">0</value>
|
<value type="int">0</value>
|
||||||
</uniform>
|
</uniform>
|
||||||
|
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>water_normalmap</name>
|
<name>water_normalmap</name>
|
||||||
<type>sampler-2d</type>
|
<type>sampler-2d</type>
|
||||||
|
@ -749,7 +691,9 @@
|
||||||
<name>saturation</name>
|
<name>saturation</name>
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
<!--<value>0.4</value>-->
|
<!--<value>0.4</value>-->
|
||||||
<value><use>saturation</use></value>
|
<value>
|
||||||
|
<use>saturation</use>
|
||||||
|
</value>
|
||||||
</uniform>
|
</uniform>
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>CloudCover0</name>
|
<name>CloudCover0</name>
|
||||||
|
@ -815,13 +759,6 @@
|
||||||
<use>windN</use>
|
<use>windN</use>
|
||||||
</value>
|
</value>
|
||||||
</uniform>
|
</uniform>
|
||||||
<!-- uniform> unused?
|
|
||||||
<name>WindFrom</name>
|
|
||||||
<type>float</type>
|
|
||||||
<value>
|
|
||||||
<use>wind-from</use>
|
|
||||||
</value>
|
|
||||||
</uniform-->
|
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>WaveFreq</name>
|
<name>WaveFreq</name>
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
|
@ -865,9 +802,7 @@
|
||||||
</value>
|
</value>
|
||||||
</uniform>
|
</uniform>
|
||||||
|
|
||||||
|
<!-- BEGIN fog include -->
|
||||||
|
|
||||||
<!-- BEGIN fog include -->
|
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>visibility</name>
|
<name>visibility</name>
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
|
@ -910,7 +845,7 @@
|
||||||
<use>fogtype</use>
|
<use>fogtype</use>
|
||||||
</value>
|
</value>
|
||||||
</uniform>
|
</uniform>
|
||||||
<!-- END fog include -->
|
<!-- END fog include -->
|
||||||
</pass>
|
</pass>
|
||||||
</technique>
|
</technique>
|
||||||
<technique n="9">
|
<technique n="9">
|
||||||
|
@ -1075,7 +1010,6 @@
|
||||||
</texture-unit>
|
</texture-unit>
|
||||||
|
|
||||||
<program>
|
<program>
|
||||||
<!-- <vertex-shader>Shaders/include_fog.vert</vertex-shader> -->
|
|
||||||
<vertex-shader>Shaders/water.vert</vertex-shader>
|
<vertex-shader>Shaders/water.vert</vertex-shader>
|
||||||
<fragment-shader>Shaders/include_fog.frag</fragment-shader>
|
<fragment-shader>Shaders/include_fog.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/water.frag</fragment-shader>
|
<fragment-shader>Shaders/water.frag</fragment-shader>
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
// © Michael Horsch - 2005
|
// © Michael Horsch - 2005
|
||||||
// Major update and revisions - 2011-10-07
|
// Major update and revisions - 2011-10-07
|
||||||
// © Emilian Huminiuc and Vivian Meazza
|
// © Emilian Huminiuc and Vivian Meazza
|
||||||
|
// Optimisation - 2012-5-05
|
||||||
|
// Based on ideas by Thorsten Renk
|
||||||
|
// © Emilian Huminiuc and Vivian Meazza
|
||||||
|
|
||||||
#version 120
|
#version 120
|
||||||
|
|
||||||
|
@ -21,8 +24,6 @@ uniform int Status;
|
||||||
|
|
||||||
varying vec4 waterTex1; //moving texcoords
|
varying vec4 waterTex1; //moving texcoords
|
||||||
varying vec4 waterTex2; //moving texcoords
|
varying vec4 waterTex2; //moving texcoords
|
||||||
varying vec4 waterTex4; //viewts
|
|
||||||
varying vec4 ecPosition;
|
|
||||||
varying vec3 viewerdir;
|
varying vec3 viewerdir;
|
||||||
varying vec3 lightdir;
|
varying vec3 lightdir;
|
||||||
varying vec3 normal;
|
varying vec3 normal;
|
||||||
|
@ -72,7 +73,7 @@ void main(void)
|
||||||
//bool Status = true;
|
//bool Status = true;
|
||||||
|
|
||||||
|
|
||||||
float windEffect = sqrt( WindE*WindE + WindN*WindN ) * 0.6; //wind speed in kt
|
float windEffect = sqrt( WindE*WindE + WindN*WindN ) * 0.6; //wind speed in kt
|
||||||
float windScale = 15.0/(3.0 + windEffect); //wave scale
|
float windScale = 15.0/(3.0 + windEffect); //wave scale
|
||||||
float windEffect_low = 0.3 + 0.7 * smoothstep(0.0, 5.0, windEffect); //low windspeed wave filter
|
float windEffect_low = 0.3 + 0.7 * smoothstep(0.0, 5.0, windEffect); //low windspeed wave filter
|
||||||
float waveRoughness = 0.05 + smoothstep(0.0, 20.0, windEffect); //wave roughness filter
|
float waveRoughness = 0.05 + smoothstep(0.0, 20.0, windEffect); //wave roughness filter
|
||||||
|
@ -91,7 +92,7 @@ void main(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 viewt = normalize(waterTex4);
|
vec4 viewt = vec4(-E, 0.0) * 0.6;
|
||||||
|
|
||||||
vec4 disdis = texture2D(water_dudvmap, vec2(waterTex2 * tscale)* windScale) * 2.0 - 1.0;
|
vec4 disdis = texture2D(water_dudvmap, vec2(waterTex2 * tscale)* windScale) * 2.0 - 1.0;
|
||||||
|
|
||||||
|
@ -122,13 +123,14 @@ void main(void)
|
||||||
nmap1 *= windEffect_low;
|
nmap1 *= windEffect_low;
|
||||||
// mix water and noise, modulated by factor
|
// mix water and noise, modulated by factor
|
||||||
vec4 vNorm = normalize(mix(nmap, nmap1, mixFactor) * waveRoughness);
|
vec4 vNorm = normalize(mix(nmap, nmap1, mixFactor) * waveRoughness);
|
||||||
//vNorm.r += ddx;
|
|
||||||
vNorm = -vNorm; //dds fix
|
vNorm = -vNorm; //dds fix
|
||||||
|
|
||||||
//load reflection
|
//load reflection
|
||||||
vec4 tmp = vec4(lightdir, 0.0);
|
vec4 tmp = vec4(lightdir, 0.0);
|
||||||
vec4 refTex;
|
vec4 refTex;
|
||||||
vec4 refl;
|
vec4 refl;
|
||||||
|
|
||||||
// cover = 0;
|
// cover = 0;
|
||||||
|
|
||||||
if(cover >= 1.5){
|
if(cover >= 1.5){
|
||||||
|
@ -163,8 +165,6 @@ void main(void)
|
||||||
N1 *= windEffect_low;
|
N1 *= windEffect_low;
|
||||||
|
|
||||||
vec3 N = normalize(mix(Normal + N0, Normal + N1, mixFactor) * waveRoughness);
|
vec3 N = normalize(mix(Normal + N0, Normal + N1, mixFactor) * waveRoughness);
|
||||||
//N.r += ddx;
|
|
||||||
//N.g += ddy;
|
|
||||||
|
|
||||||
N = -N; //dds fix
|
N = -N; //dds fix
|
||||||
|
|
||||||
|
@ -180,15 +180,6 @@ void main(void)
|
||||||
vec4 fres = vec4(1.0) + invfres;
|
vec4 fres = vec4(1.0) + invfres;
|
||||||
refl *= fres;
|
refl *= fres;
|
||||||
|
|
||||||
//calculate the fog factor
|
|
||||||
// float fogFactor;
|
|
||||||
// float fogCoord = ecPosition.z;
|
|
||||||
// const float LOG2 = 1.442695;
|
|
||||||
// fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2);
|
|
||||||
//
|
|
||||||
// if(gl_Fog.density == 1.0)
|
|
||||||
// fogFactor=1.0;
|
|
||||||
|
|
||||||
//calculate final colour
|
//calculate final colour
|
||||||
vec4 ambient_light = gl_LightSource[0].diffuse;
|
vec4 ambient_light = gl_LightSource[0].diffuse;
|
||||||
vec4 finalColor;
|
vec4 finalColor;
|
||||||
|
@ -200,7 +191,6 @@ void main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
float foamSlope = 0.10 + 0.1 * windScale;
|
float foamSlope = 0.10 + 0.1 * windScale;
|
||||||
//float waveSlope = mix(N0.g, N1.g, 0.25);
|
|
||||||
|
|
||||||
vec4 foam_texel = texture2D(sea_foam, vec2(waterTex2 * tscale) * 25.0);
|
vec4 foam_texel = texture2D(sea_foam, vec2(waterTex2 * tscale) * 25.0);
|
||||||
float waveSlope = N.g;
|
float waveSlope = N.g;
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
|
|
||||||
varying vec4 waterTex1;
|
varying vec4 waterTex1;
|
||||||
varying vec4 waterTex2;
|
varying vec4 waterTex2;
|
||||||
varying vec4 waterTex4;
|
//varying vec4 waterTex4;
|
||||||
varying vec4 ecPosition;
|
|
||||||
|
|
||||||
varying vec3 viewerdir;
|
varying vec3 viewerdir;
|
||||||
varying vec3 lightdir;
|
varying vec3 lightdir;
|
||||||
|
@ -19,53 +18,48 @@ varying vec3 normal;
|
||||||
uniform float osg_SimulationTime;
|
uniform float osg_SimulationTime;
|
||||||
uniform float WindE, WindN;
|
uniform float WindE, WindN;
|
||||||
|
|
||||||
////fog "include"////////
|
|
||||||
// uniform int fogType;
|
|
||||||
//
|
|
||||||
// void fog_Func(int type);
|
|
||||||
/////////////////////////
|
|
||||||
|
|
||||||
/////// functions /////////
|
/////// functions /////////
|
||||||
|
|
||||||
void rotationmatrix(in float angle, out mat4 rotmat)
|
void rotationmatrix(in float angle, out mat4 rotmat)
|
||||||
{
|
{
|
||||||
rotmat = mat4( cos( angle ), -sin( angle ), 0.0, 0.0,
|
rotmat = mat4( cos( angle ), -sin( angle ), 0.0, 0.0,
|
||||||
sin( angle ), cos( angle ), 0.0, 0.0,
|
sin( angle ), cos( angle ), 0.0, 0.0,
|
||||||
0.0 , 0.0 , 1.0, 0.0,
|
0.0 , 0.0 , 1.0, 0.0,
|
||||||
0.0 , 0.0 , 0.0, 1.0 );
|
0.0 , 0.0 , 0.0, 1.0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
mat4 RotationMatrix;
|
mat4 RotationMatrix;
|
||||||
vec3 N = normalize(gl_Normal);
|
vec3 N = normalize(gl_Normal);
|
||||||
normal = N;
|
normal = N;
|
||||||
|
|
||||||
ecPosition = gl_ModelViewMatrix * gl_Vertex;
|
vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
|
||||||
|
|
||||||
viewerdir = vec3(gl_ModelViewMatrixInverse[3]) - vec3(gl_Vertex);
|
viewerdir = vec3(gl_ModelViewMatrixInverse[3]) - vec3(gl_Vertex);
|
||||||
lightdir = normalize(vec3(gl_ModelViewMatrixInverse * gl_LightSource[0].position));
|
lightdir = normalize(vec3(gl_ModelViewMatrixInverse * gl_LightSource[0].position));
|
||||||
|
|
||||||
waterTex4 = vec4( ecPosition.xzy, 0.0 );
|
//waterTex4 = vec4(ecPosition.xzy, 0.0 );
|
||||||
|
|
||||||
vec4 t1 = vec4(0.0, osg_SimulationTime * 0.005217, 0.0, 0.0);
|
vec4 t1 = vec4(0.0, osg_SimulationTime * 0.005217, 0.0, 0.0);
|
||||||
vec4 t2 = vec4(0.0, osg_SimulationTime * -0.0012, 0.0, 0.0);
|
vec4 t2 = vec4(0.0, osg_SimulationTime * -0.0012, 0.0, 0.0);
|
||||||
|
|
||||||
float Angle;
|
float Angle;
|
||||||
|
|
||||||
float windFactor = sqrt(pow(abs(WindE),2)+pow(abs(WindN),2)) * 0.05;
|
float windFactor = sqrt(pow(abs(WindE),2)+pow(abs(WindN),2)) * 0.05;
|
||||||
if (WindN == 0.0 && WindE == 0.0) {
|
|
||||||
Angle = 0.0;
|
|
||||||
}else{
|
|
||||||
Angle = atan(-WindN, WindE) - atan(1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
rotationmatrix(Angle, RotationMatrix);
|
if (WindN == 0.0 && WindE == 0.0) {
|
||||||
waterTex1 = gl_MultiTexCoord0 * RotationMatrix - t1 * windFactor;
|
Angle = 0.0;
|
||||||
|
}else{
|
||||||
|
Angle = atan(-WindN, WindE) - atan(1.0);
|
||||||
|
}
|
||||||
|
|
||||||
rotationmatrix(Angle, RotationMatrix);
|
rotationmatrix(Angle, RotationMatrix);
|
||||||
waterTex2 = gl_MultiTexCoord0 * RotationMatrix - t2 * windFactor;
|
waterTex1 = gl_MultiTexCoord0 * RotationMatrix - t1 * windFactor;
|
||||||
|
|
||||||
// fog_Func(fogType);
|
rotationmatrix(Angle, RotationMatrix);
|
||||||
gl_Position = ftransform();
|
waterTex2 = gl_MultiTexCoord0 * RotationMatrix - t2 * windFactor;
|
||||||
}
|
|
||||||
|
// fog_Func(fogType);
|
||||||
|
gl_Position = ftransform();
|
||||||
|
}
|
|
@ -4,6 +4,9 @@
|
||||||
// © Michael Horsch - 2005
|
// © Michael Horsch - 2005
|
||||||
// Major update and revisions - 2011-10-07
|
// Major update and revisions - 2011-10-07
|
||||||
// © Emilian Huminiuc and Vivian Meazza
|
// © Emilian Huminiuc and Vivian Meazza
|
||||||
|
// Optimisation - 2012-5-05
|
||||||
|
// Based on ideas by Thorsten Renk
|
||||||
|
// © Emilian Huminiuc and Vivian Meazza
|
||||||
|
|
||||||
#version 120
|
#version 120
|
||||||
|
|
||||||
|
@ -23,8 +26,7 @@ uniform int Status;
|
||||||
|
|
||||||
varying vec4 waterTex1; //moving texcoords
|
varying vec4 waterTex1; //moving texcoords
|
||||||
varying vec4 waterTex2; //moving texcoords
|
varying vec4 waterTex2; //moving texcoords
|
||||||
varying vec4 waterTex4; //viewts
|
|
||||||
//varying vec4 ecPosition;
|
|
||||||
varying vec3 viewerdir;
|
varying vec3 viewerdir;
|
||||||
varying vec3 lightdir;
|
varying vec3 lightdir;
|
||||||
varying vec3 normal;
|
varying vec3 normal;
|
||||||
|
@ -42,6 +44,8 @@ uniform int fogType;
|
||||||
vec3 fog_Func(vec3 color, int type);
|
vec3 fog_Func(vec3 color, int type);
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
|
const vec4 AllOnes = vec4(1.0);
|
||||||
|
|
||||||
/////// functions /////////
|
/////// functions /////////
|
||||||
|
|
||||||
void rotationmatrix(in float angle, out mat4 rotmat)
|
void rotationmatrix(in float angle, out mat4 rotmat)
|
||||||
|
@ -92,7 +96,7 @@ void sumWaves(float angle, float dangle, float windScale, float factor, out floa
|
||||||
{
|
{
|
||||||
mat4 RotationMatrix;
|
mat4 RotationMatrix;
|
||||||
float deriv;
|
float deriv;
|
||||||
vec4 P = waterTex1 * 1024;
|
vec4 P = waterTex1 * 1024.0;
|
||||||
|
|
||||||
rotationmatrix(radians(angle + dangle * windScale + 0.6 * sin(P.x * factor)), RotationMatrix);
|
rotationmatrix(radians(angle + dangle * windScale + 0.6 * sin(P.x * factor)), RotationMatrix);
|
||||||
P *= RotationMatrix;
|
P *= RotationMatrix;
|
||||||
|
@ -139,14 +143,16 @@ void main(void)
|
||||||
|
|
||||||
const float water_shininess = 240.0;
|
const float water_shininess = 240.0;
|
||||||
|
|
||||||
|
float range = gl_ProjectionMatrix[3].z/(gl_FragCoord.z * -2.0 + 1.0 - gl_ProjectionMatrix[2].z);
|
||||||
|
|
||||||
// approximate cloud cover
|
// approximate cloud cover
|
||||||
float cover = 0.0;
|
float cover = 0.0;
|
||||||
//bool Status = true;
|
//bool Status = true;
|
||||||
|
|
||||||
float windEffect = sqrt( WindE*WindE + WindN*WindN ) * 0.6; //wind speed in kt
|
float windEffect = sqrt( WindE*WindE + WindN*WindN ) * 0.6; //wind speed in kt
|
||||||
float windScale = 15.0/(3.0 + windEffect); //wave scale
|
float windScale = 15.0/(3.0 + windEffect); //wave scale
|
||||||
float windEffect_low = 0.3 + 0.7 * smoothstep(0.0, 5.0, windEffect); //low windspeed wave filter
|
float windEffect_low = 0.3 + 0.7 * smoothstep(0.0, 5.0, windEffect); //low windspeed wave filter
|
||||||
float waveRoughness = 0.01 + smoothstep(0.0, 40.0, windEffect); //wave roughness filter
|
float waveRoughness = 0.01 + smoothstep(0.0, 40.0, windEffect); //wave roughness filter
|
||||||
|
|
||||||
float mixFactor = 0.2 + 0.02 * smoothstep(0.0, 50.0, windEffect);
|
float mixFactor = 0.2 + 0.02 * smoothstep(0.0, 50.0, windEffect);
|
||||||
//mixFactor = 0.2;
|
//mixFactor = 0.2;
|
||||||
|
@ -154,68 +160,94 @@ void main(void)
|
||||||
|
|
||||||
// sine waves
|
// sine waves
|
||||||
|
|
||||||
|
// Test data
|
||||||
//float WaveFreq =1.0;
|
//float WaveFreq =1.0;
|
||||||
//float WaveAmp = 1000.0;
|
//float WaveAmp = 1000.0;
|
||||||
//float WaveSharp = 10.0;
|
//float WaveSharp = 10.0;
|
||||||
float angle = 0.0;
|
|
||||||
|
|
||||||
wave0.freq = WaveFreq ;
|
vec4 ddxVec = vec4(0.0);
|
||||||
wave0.amp = WaveAmp;
|
vec4 ddyVec = vec4(0.0);
|
||||||
wave0.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
int detailFlag = 0;
|
||||||
|
|
||||||
angle -= 45;
|
//uncomment to test
|
||||||
wave1.freq = WaveFreq * 2.0 ;
|
//range = -20000;
|
||||||
wave1.amp = WaveAmp * 1.25;
|
|
||||||
wave1.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
|
||||||
|
|
||||||
angle += 30;
|
if (range > -15000 || dot(Normal,H) > 0.95 ) {
|
||||||
wave2.freq = WaveFreq * 3.5;
|
|
||||||
wave2.amp = WaveAmp * 0.75;
|
|
||||||
wave2.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
|
||||||
|
|
||||||
angle -= 50;
|
float ddx = 0.0, ddy = 0.0;
|
||||||
wave3.freq = WaveFreq * 3.0 ;
|
float ddx1 = 0.0, ddy1 = 0.0;
|
||||||
wave3.amp = WaveAmp * 0.75;
|
float ddx2 = 0.0, ddy2 = 0.0;
|
||||||
wave3.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
float ddx3 = 0.0, ddy3 = 0.0;
|
||||||
|
float waveamp;
|
||||||
|
|
||||||
// sum waves
|
float angle = 0.0;
|
||||||
|
|
||||||
float ddx = 0.0, ddy = 0.0;
|
wave0.freq = WaveFreq ;
|
||||||
sumWaves(WaveAngle, -1.5, windScale, WaveFactor, ddx, ddy);
|
wave0.amp = WaveAmp;
|
||||||
|
wave0.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
||||||
|
|
||||||
float ddx1 = 0.0, ddy1 = 0.0;
|
angle -= 45;
|
||||||
sumWaves(WaveAngle, 1.5, windScale, WaveFactor, ddx1, ddy1);
|
wave1.freq = WaveFreq * 2.0 ;
|
||||||
|
wave1.amp = WaveAmp * 1.25;
|
||||||
|
wave1.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
||||||
|
|
||||||
//reset the waves
|
angle += 30;
|
||||||
angle = 0.0;
|
wave2.freq = WaveFreq * 3.5;
|
||||||
float waveamp = WaveAmp * 0.75;
|
wave2.amp = WaveAmp * 0.75;
|
||||||
|
wave2.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
||||||
|
|
||||||
wave0.freq = WaveFreq ;
|
angle -= 50;
|
||||||
wave0.amp = waveamp;
|
wave3.freq = WaveFreq * 3.0 ;
|
||||||
wave0.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
wave3.amp = WaveAmp * 0.75;
|
||||||
|
wave3.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
||||||
|
|
||||||
angle -= 20;
|
// sum waves
|
||||||
wave1.freq = WaveFreq * 2.0 ;
|
|
||||||
wave1.amp = waveamp * 1.25;
|
|
||||||
wave1.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
|
||||||
|
|
||||||
angle += 35;
|
ddx = 0.0, ddy = 0.0;
|
||||||
wave2.freq = WaveFreq * 3.5;
|
sumWaves(WaveAngle, -1.5, windScale, WaveFactor, ddx, ddy);
|
||||||
wave2.amp = waveamp * 0.75;
|
|
||||||
wave2.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
|
||||||
|
|
||||||
angle -= 45;
|
ddx1 = 0.0, ddy1 = 0.0;
|
||||||
wave3.freq = WaveFreq * 3.0 ;
|
sumWaves(WaveAngle, 1.5, windScale, WaveFactor, ddx1, ddy1);
|
||||||
wave3.amp = waveamp * 0.75;
|
|
||||||
wave3.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
|
||||||
|
|
||||||
float ddx2 = 0.0, ddy2 = 0.0;
|
//reset the waves
|
||||||
sumWaves(WaveAngle + WaveDAngle, -1.5, windScale, WaveFactor, ddx2, ddy2);
|
angle = 0.0;
|
||||||
|
waveamp = WaveAmp * 0.75;
|
||||||
|
|
||||||
float ddx3 = 0.0, ddy3 = 0.0;
|
wave0.freq = WaveFreq ;
|
||||||
sumWaves(WaveAngle + WaveDAngle, 1.5, windScale, WaveFactor, ddx3, ddy3);
|
wave0.amp = waveamp;
|
||||||
|
wave0.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
||||||
|
|
||||||
// end sine stuff
|
angle -= 20;
|
||||||
|
wave1.freq = WaveFreq * 2.0 ;
|
||||||
|
wave1.amp = waveamp * 1.25;
|
||||||
|
wave1.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
||||||
|
|
||||||
|
angle += 35;
|
||||||
|
wave2.freq = WaveFreq * 3.5;
|
||||||
|
wave2.amp = waveamp * 0.75;
|
||||||
|
wave2.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
||||||
|
|
||||||
|
angle -= 45;
|
||||||
|
wave3.freq = WaveFreq * 3.0 ;
|
||||||
|
wave3.amp = waveamp * 0.75;
|
||||||
|
wave3.dir = vec2(cos(radians(angle)), sin(radians(angle)));
|
||||||
|
|
||||||
|
// sum waves
|
||||||
|
ddx2 = 0.0, ddy2 = 0.0;
|
||||||
|
sumWaves(WaveAngle + WaveDAngle, -1.5, windScale, WaveFactor, ddx2, ddy2);
|
||||||
|
|
||||||
|
ddx3 = 0.0, ddy3 = 0.0;
|
||||||
|
sumWaves(WaveAngle + WaveDAngle, 1.5, windScale, WaveFactor, ddx3, ddy3);
|
||||||
|
|
||||||
|
ddxVec = vec4(ddx, ddx1, ddx2, ddx3);
|
||||||
|
ddyVec = vec4(ddy, ddy1, ddy2, ddy3);
|
||||||
|
|
||||||
|
//toggle detailFlag
|
||||||
|
detailFlag = 1;
|
||||||
|
} // end sine stuff
|
||||||
|
|
||||||
|
float ddxSum = dot(ddxVec, AllOnes);
|
||||||
|
float ddySum = dot(ddyVec, AllOnes);
|
||||||
|
|
||||||
if (Status == 1){
|
if (Status == 1){
|
||||||
cover = min(min(min(min(CloudCover0, CloudCover1),CloudCover2),CloudCover3),CloudCover4);
|
cover = min(min(min(min(CloudCover0, CloudCover1),CloudCover2),CloudCover3),CloudCover4);
|
||||||
|
@ -228,16 +260,11 @@ void main(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 viewt = normalize(waterTex4);
|
// vec4 viewt = normalize(waterTex4);
|
||||||
|
vec4 viewt = vec4(-E, 0.0) * 0.6;
|
||||||
|
|
||||||
vec4 disdis = texture2D(water_dudvmap, vec2(waterTex2 * tscale)* windScale) * 2.0 - 1.0;
|
vec4 disdis = texture2D(water_dudvmap, vec2(waterTex2 * tscale)* windScale) * 2.0 - 1.0;
|
||||||
|
|
||||||
//vec4 dist = texture2D(water_dudvmap, vec2(waterTex1 + disdis*sca2)* windScale) * 2.0 - 1.0;
|
|
||||||
//dist *= (0.6 + 0.5 * smoothstep(0.0, 15.0, windEffect));
|
|
||||||
//vec4 fdist = normalize(dist);
|
|
||||||
//fdist = -fdist; //dds fix
|
|
||||||
//fdist *= sca;
|
|
||||||
|
|
||||||
//normalmaps
|
//normalmaps
|
||||||
vec4 nmap = texture2D(water_normalmap, vec2(waterTex1 + disdis * sca2) * windScale) * 2.0 - 1.0;
|
vec4 nmap = texture2D(water_normalmap, vec2(waterTex1 + disdis * sca2) * windScale) * 2.0 - 1.0;
|
||||||
vec4 nmap1 = texture2D(perlin_normalmap, vec2(waterTex1 + disdis * sca2) * windScale) * 2.0 - 1.0;
|
vec4 nmap1 = texture2D(perlin_normalmap, vec2(waterTex1 + disdis * sca2) * windScale) * 2.0 - 1.0;
|
||||||
|
@ -251,18 +278,21 @@ void main(void)
|
||||||
|
|
||||||
// mix water and noise, modulated by factor
|
// mix water and noise, modulated by factor
|
||||||
vec4 vNorm = normalize(mix(nmap, nmap1, mixFactor) * waveRoughness);
|
vec4 vNorm = normalize(mix(nmap, nmap1, mixFactor) * waveRoughness);
|
||||||
vNorm.r += ddx + ddx1 + ddx2 + ddx3;
|
vNorm.r += ddxSum;
|
||||||
vNorm = -vNorm; //dds fix
|
vNorm = -vNorm; //dds fix
|
||||||
|
|
||||||
//load reflection
|
//load reflection
|
||||||
vec4 tmp = vec4(lightdir, 0.0);
|
vec4 tmp = vec4(lightdir, 0.0);
|
||||||
vec4 refTex = texture2D(water_reflection, vec2(tmp)) ;
|
vec4 refTex = texture2D(water_reflection, vec2(tmp + waterTex1) * 32.0) ;
|
||||||
vec4 refTexGrey = texture2D(water_reflection_grey, vec2(tmp)) ;
|
vec4 refTexGrey = texture2D(water_reflection_grey, vec2(tmp * waterTex1)) ;
|
||||||
vec4 refl ;
|
vec4 refl ;
|
||||||
// cover = 0;
|
|
||||||
|
// Test data
|
||||||
|
// cover = 0;
|
||||||
|
|
||||||
if(cover >= 1.5){
|
if(cover >= 1.5){
|
||||||
refl= normalize(refTex);
|
refl = normalize(refTex);
|
||||||
|
refl.a = 1.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -270,10 +300,9 @@ void main(void)
|
||||||
refl.r *= (0.75 + 0.15 * cover);
|
refl.r *= (0.75 + 0.15 * cover);
|
||||||
refl.g *= (0.80 + 0.15 * cover);
|
refl.g *= (0.80 + 0.15 * cover);
|
||||||
refl.b *= (0.875 + 0.125 * cover);
|
refl.b *= (0.875 + 0.125 * cover);
|
||||||
refl.a *= 1.0;
|
refl.a = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vec3 N0 = vec3(texture2D(water_normalmap, vec2(waterTex1 + disdis * sca2) * windScale) * 2.0 - 1.0);
|
vec3 N0 = vec3(texture2D(water_normalmap, vec2(waterTex1 + disdis * sca2) * windScale) * 2.0 - 1.0);
|
||||||
vec3 N1 = vec3(texture2D(perlin_normalmap, vec2(waterTex1 + disdis * sca) * windScale) * 2.0 - 1.0);
|
vec3 N1 = vec3(texture2D(perlin_normalmap, vec2(waterTex1 + disdis * sca) * windScale) * 2.0 - 1.0);
|
||||||
|
|
||||||
|
@ -288,19 +317,24 @@ void main(void)
|
||||||
N0 += vec3(texture2D(water_normalmap, vec2(waterTex1 * RotationMatrix + disdis * sca2) * windScale) * 2.0 - 1.0);
|
N0 += vec3(texture2D(water_normalmap, vec2(waterTex1 * RotationMatrix + disdis * sca2) * windScale) * 2.0 - 1.0);
|
||||||
N1 += vec3(texture2D(perlin_normalmap, vec2(waterTex1 * RotationMatrix + disdis * sca) * windScale) * 2.0 - 1.0);
|
N1 += vec3(texture2D(perlin_normalmap, vec2(waterTex1 * RotationMatrix + disdis * sca) * windScale) * 2.0 - 1.0);
|
||||||
|
|
||||||
N0 *= windEffect_low;
|
if(detailFlag > 0)
|
||||||
N1 *= windEffect_low;
|
{
|
||||||
|
N0 *= windEffect_low;
|
||||||
|
N1 *= windEffect_low;
|
||||||
|
//N0.r += (ddx + ddx1 + ddx2 + ddx3);
|
||||||
|
//N0.g += (ddy + ddy1 + ddy2 + ddy3);
|
||||||
|
|
||||||
N0.r += (ddx + ddx1 + ddx2 + ddx3);
|
N0.r += ddxSum;
|
||||||
N0.g += (ddy + ddy1 + ddy2 + ddy3);
|
N0.g += ddySum;
|
||||||
|
|
||||||
vec3 N = normalize(mix(Normal + N0, Normal + N1, mixFactor) * waveRoughness);
|
Normal = normalize(mix(Normal + N0, Normal + N1, mixFactor) * waveRoughness);
|
||||||
|
Normal = -Normal; //dds fix
|
||||||
|
}
|
||||||
|
|
||||||
N = -N; //dds fix
|
|
||||||
|
|
||||||
// specular
|
// specular
|
||||||
vec3 specular_color = vec3(gl_LightSource[0].diffuse)
|
vec3 specular_color = vec3(gl_LightSource[0].diffuse)
|
||||||
* pow(max(0.0, dot(N, H)), water_shininess) * 6.0;
|
* pow(max(0.0, dot(Normal, H)), water_shininess) * 6.0;
|
||||||
vec4 specular = vec4(specular_color, 0.5);
|
vec4 specular = vec4(specular_color, 0.5);
|
||||||
|
|
||||||
specular = specular * saturation * 0.3 ;
|
specular = specular * saturation * 0.3 ;
|
||||||
|
@ -310,15 +344,6 @@ void main(void)
|
||||||
vec4 fres = vec4(1.0) + invfres;
|
vec4 fres = vec4(1.0) + invfres;
|
||||||
refl *= fres;
|
refl *= fres;
|
||||||
|
|
||||||
//calculate the fog factor
|
|
||||||
// float fogFactor;
|
|
||||||
// float fogCoord = ecPosition.z;
|
|
||||||
// const float LOG2 = 1.442695;
|
|
||||||
// fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2);
|
|
||||||
//
|
|
||||||
// if(gl_Fog.density == 1.0)
|
|
||||||
// fogFactor=1.0;
|
|
||||||
|
|
||||||
//calculate final colour
|
//calculate final colour
|
||||||
vec4 ambient_light = gl_LightSource[0].diffuse;
|
vec4 ambient_light = gl_LightSource[0].diffuse;
|
||||||
vec4 finalColor;
|
vec4 finalColor;
|
||||||
|
@ -330,41 +355,26 @@ void main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
//add foam
|
//add foam
|
||||||
|
|
||||||
float foamSlope = 0.10 + 0.1 * windScale;
|
|
||||||
//float waveSlope = mix(N0.g, N1.g, 0.25);
|
|
||||||
|
|
||||||
vec4 foam_texel = texture2D(sea_foam, vec2(waterTex2 * tscale) * 25.0);
|
vec4 foam_texel = texture2D(sea_foam, vec2(waterTex2 * tscale) * 25.0);
|
||||||
float waveSlope = N.g;
|
if (range > -10000.0){
|
||||||
|
|
||||||
if (windEffect >= 8.0)
|
float foamSlope = 0.1 + 0.1 * windScale;
|
||||||
if (waveSlope >= foamSlope){
|
//float waveSlope = mix(N0.g, N1.g, 0.25);
|
||||||
finalColor = mix(finalColor, max(finalColor, finalColor + foam_texel), smoothstep(0.01, 0.50, N.g));
|
float waveSlope = Normal.g;
|
||||||
|
|
||||||
|
if (windEffect >= 8.0)
|
||||||
|
|
||||||
|
if (waveSlope >= foamSlope){
|
||||||
|
finalColor = mix(finalColor, max(finalColor, finalColor + foam_texel),
|
||||||
|
smoothstep(0.01, 0.50, Normal.g));
|
||||||
}
|
}
|
||||||
|
|
||||||
// float deltaN0 = 1.0 - N0.g;
|
} // end range
|
||||||
//float deltaN1 = 1.0 - N1.g;
|
|
||||||
//if (windEffect >= 8.0){
|
|
||||||
// if (N0.g >= foamSlope){
|
|
||||||
// if (deltaN0 > 0.8){
|
|
||||||
// finalColor = mix(finalColor, max(finalColor, finalColor + foam_texel), smoothstep(0.01, 0.50, N0.g));
|
|
||||||
// } else {
|
|
||||||
// finalColor = mix(finalColor, max(finalColor, finalColor + foam_texel), smoothstep(0.15, 0.25, deltaN0));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (N1.g >= foamSlope){
|
|
||||||
// if (deltaN1 > 0.85){
|
|
||||||
// finalColor = mix(finalColor, max(finalColor, finalColor + foam_texel), smoothstep(0.01, 0.13, N1.g));
|
|
||||||
// } else {
|
|
||||||
// finalColor = mix(finalColor, max(finalColor, finalColor + foam_texel), smoothstep(0.01, 0.20, deltaN1));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
finalColor *= ambient_light;
|
finalColor *= ambient_light;
|
||||||
|
|
||||||
//gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor);
|
//gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor);
|
||||||
finalColor.rgb = fog_Func(finalColor.rgb, fogType);
|
finalColor.rgb = fog_Func(finalColor.rgb, fogType);
|
||||||
gl_FragColor = finalColor;
|
gl_FragColor = finalColor;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 48 KiB |
Binary file not shown.
Before Width: | Height: | Size: 962 B After Width: | Height: | Size: 274 B |
Loading…
Reference in a new issue