diff --git a/engine/src/core-effects/Common/MatDefs/Water/SimpleWater.j3md b/engine/src/core-effects/Common/MatDefs/Water/SimpleWater.j3md index 639e06c19..dd07648ab 100644 --- a/engine/src/core-effects/Common/MatDefs/Water/SimpleWater.j3md +++ b/engine/src/core-effects/Common/MatDefs/Water/SimpleWater.j3md @@ -10,9 +10,9 @@ MaterialDef Simple Water { Vector3 lightPos Float time Float waterDepth - Vector4 distortionScale - Vector4 distortionMix - Vector4 texScale + Float distortionScale + Float distortionMix + Float texScale Vector2 FrustumNearFar Float waterTransparency } diff --git a/engine/src/core-effects/Common/MatDefs/Water/simple_water.frag b/engine/src/core-effects/Common/MatDefs/Water/simple_water.frag index 65a9c991c..ae9b10875 100644 --- a/engine/src/core-effects/Common/MatDefs/Water/simple_water.frag +++ b/engine/src/core-effects/Common/MatDefs/Water/simple_water.frag @@ -12,17 +12,22 @@ uniform sampler2D m_water_dudvmap; uniform sampler2D m_water_depthmap; uniform vec4 m_waterColor; uniform float m_waterDepth; -uniform vec4 m_distortionScale; -uniform vec4 m_distortionMix; -uniform vec4 m_texScale; +uniform float m_distortionScale; +uniform float m_distortionMix; +uniform float m_texScale; +/*uniform float m_distortionScale; +uniform float m_distortionMix; +uniform float m_texScale; +*/ uniform vec2 m_FrustumNearFar; uniform float m_waterTransparency; varying vec4 lightDir; //lightpos -varying vec4 waterTex1; //moving texcoords -varying vec4 waterTex2; //moving texcoords +varying vec2 waterTex1; //moving texcoords +varying vec2 waterTex2; //moving texcoords + varying vec4 position; //for projection varying vec4 viewDir; //viewts varying vec4 viewLightDir; @@ -62,13 +67,12 @@ void main(void) vec4 lightTS = normalize(lightDir); vec4 viewt = normalize(viewDir); - vec4 disdis = texture2D(m_water_dudvmap, vec2(waterTex2 * m_texScale)); - vec4 fdist = texture2D(m_water_dudvmap, vec2(waterTex1 + disdis*m_distortionMix)); - fdist =normalize( fdist * 2.0 - 1.0)* m_distortionScale; - + vec4 disdis = texture2D(m_water_dudvmap, waterTex2 * vec2(m_texScale)); + vec4 fdist = texture2D(m_water_dudvmap, waterTex1 + vec2(disdis) * vec2(m_distortionMix)); + fdist =normalize( fdist * 2.0 - 1.0)* vec4(m_distortionScale); - //load normalmap - vec4 nmap = texture2D(m_water_normalmap, vec2(waterTex1 + disdis*m_distortionMix)); + //load normalmap + vec4 nmap = texture2D(m_water_normalmap, waterTex1 + vec2(disdis) * vec2(m_distortionMix)); nmap = (nmap-ofive) * two; // nmap = nmap*2.0-1.0; vec4 vNorm = normalize(nmap); diff --git a/engine/src/core-effects/Common/MatDefs/Water/simple_water.vert b/engine/src/core-effects/Common/MatDefs/Water/simple_water.vert index e6052d8d5..b6ec06675 100644 --- a/engine/src/core-effects/Common/MatDefs/Water/simple_water.vert +++ b/engine/src/core-effects/Common/MatDefs/Water/simple_water.vert @@ -19,8 +19,8 @@ attribute vec3 inTangent; attribute vec3 inNormal; varying vec4 lightDir; -varying vec4 waterTex1; -varying vec4 waterTex2; +varying vec2 waterTex1; +varying vec2 waterTex2; varying vec4 position; varying vec4 viewDir; varying vec4 viewpos; @@ -76,11 +76,11 @@ void main(void) viewCamDir.w = 0.0; - vec4 t1 = vec4(0.0, -m_time, 0.0,0.0); - vec4 t2 = vec4(0.0, m_time, 0.0,0.0); + vec2 t1 = vec2(0.0, -m_time); + vec2 t2 = vec2(0.0, m_time); - waterTex1 =vec4(inTexCoord,0.0,0.0) + t1; - waterTex2 =vec4(inTexCoord ,0.0,0.0)+ t2; + waterTex1 = inTexCoord + t1; + waterTex2 = inTexCoord + t2; position = g_WorldViewProjectionMatrix * inPosition; gl_Position = position; diff --git a/engine/src/core-effects/com/jme3/water/SimpleWaterProcessor.java b/engine/src/core-effects/com/jme3/water/SimpleWaterProcessor.java index 014cf2d5d..1177fc266 100644 --- a/engine/src/core-effects/com/jme3/water/SimpleWaterProcessor.java +++ b/engine/src/core-effects/com/jme3/water/SimpleWaterProcessor.java @@ -139,10 +139,10 @@ public class SimpleWaterProcessor implements SceneProcessor { material.setFloat("waterTransparency", waterTransparency / 10); material.setColor("waterColor", ColorRGBA.White); material.setVector3("lightPos", new Vector3f(1, -1, 1)); - - material.setColor("distortionScale", new ColorRGBA(0.2f, 0.2f, 0.2f, 0.2f)); - material.setColor("distortionMix", new ColorRGBA(0.5f, 0.5f, 0.5f, 0.5f)); - material.setColor("texScale", new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); + + material.setFloat("distortionScale", distortionScale); + material.setFloat("distortionMix", distortionMix); + material.setFloat("texScale", texScale); updateClipPlanes(); } @@ -487,7 +487,7 @@ public class SimpleWaterProcessor implements SceneProcessor { */ public void setDistortionScale(float value) { distortionScale = value; - material.setColor("distortionScale", new ColorRGBA(value, value, value, value)); + material.setFloat("distortionScale", distortionScale); } /** @@ -495,7 +495,7 @@ public class SimpleWaterProcessor implements SceneProcessor { */ public void setDistortionMix(float value) { distortionMix = value; - material.setColor("distortionMix", new ColorRGBA(value, value, value, value)); + material.setFloat("distortionMix", distortionMix); } /** @@ -505,7 +505,7 @@ public class SimpleWaterProcessor implements SceneProcessor { */ public void setTexScale(float value) { texScale = value; - material.setColor("texScale", new ColorRGBA(value, value, value, value)); + material.setFloat("texScale", texScale); } /**