Cleaned up SimpleWater uniform and varyings to not systematically use vec4 for no reason.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10536 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 12 years ago
parent 761fe60388
commit e34d483973
  1. 6
      engine/src/core-effects/Common/MatDefs/Water/SimpleWater.j3md
  2. 24
      engine/src/core-effects/Common/MatDefs/Water/simple_water.frag
  3. 12
      engine/src/core-effects/Common/MatDefs/Water/simple_water.vert
  4. 12
      engine/src/core-effects/com/jme3/water/SimpleWaterProcessor.java

@ -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
}

@ -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));
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);

@ -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;

@ -140,9 +140,9 @@ public class SimpleWaterProcessor implements SceneProcessor {
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);
}
/**

Loading…
Cancel
Save