WaterFilter now use the built in global uniform ViewProjectionMatrixInverse instead of a custome material parameter
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10751 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
afa9376b26
commit
b20905f08d
@ -12,7 +12,7 @@ uniform sampler2D m_FoamMap;
|
|||||||
uniform sampler2D m_CausticsMap;
|
uniform sampler2D m_CausticsMap;
|
||||||
uniform sampler2D m_ReflectionMap;
|
uniform sampler2D m_ReflectionMap;
|
||||||
|
|
||||||
uniform mat4 m_ViewProjectionMatrixInverse;
|
uniform mat4 g_ViewProjectionMatrixInverse;
|
||||||
uniform mat4 m_TextureProjMatrix;
|
uniform mat4 m_TextureProjMatrix;
|
||||||
uniform vec3 m_CameraPosition;
|
uniform vec3 m_CameraPosition;
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ vec3 saturate(in vec3 val){
|
|||||||
|
|
||||||
vec3 getPosition(in float depth, in vec2 uv){
|
vec3 getPosition(in float depth, in vec2 uv){
|
||||||
vec4 pos = vec4(uv, depth, 1.0) * 2.0 - 1.0;
|
vec4 pos = vec4(uv, depth, 1.0) * 2.0 - 1.0;
|
||||||
pos = m_ViewProjectionMatrixInverse * pos;
|
pos = g_ViewProjectionMatrixInverse * pos;
|
||||||
return pos.xyz / pos.w;
|
return pos.xyz / pos.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ MaterialDef Advanced Water {
|
|||||||
Float Time
|
Float Time
|
||||||
Vector3 frustumCorner
|
Vector3 frustumCorner
|
||||||
Matrix4 TextureProjMatrix
|
Matrix4 TextureProjMatrix
|
||||||
Matrix4 ViewProjectionMatrixInverse
|
|
||||||
Float WaterHeight
|
Float WaterHeight
|
||||||
Vector3 LightDir
|
Vector3 LightDir
|
||||||
Float WaterTransparency
|
Float WaterTransparency
|
||||||
@ -56,6 +55,7 @@ MaterialDef Advanced Water {
|
|||||||
FragmentShader GLSL150 : Common/MatDefs/Water/Water15.frag
|
FragmentShader GLSL150 : Common/MatDefs/Water/Water15.frag
|
||||||
|
|
||||||
WorldParameters {
|
WorldParameters {
|
||||||
|
ViewProjectionMatrixInverse
|
||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
|
@ -16,7 +16,7 @@ uniform sampler2D m_FoamMap;
|
|||||||
uniform sampler2D m_CausticsMap;
|
uniform sampler2D m_CausticsMap;
|
||||||
uniform sampler2D m_ReflectionMap;
|
uniform sampler2D m_ReflectionMap;
|
||||||
|
|
||||||
uniform mat4 m_ViewProjectionMatrixInverse;
|
uniform mat4 g_ViewProjectionMatrixInverse;
|
||||||
uniform mat4 m_TextureProjMatrix;
|
uniform mat4 m_TextureProjMatrix;
|
||||||
uniform vec3 m_CameraPosition;
|
uniform vec3 m_CameraPosition;
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ vec3 saturate(in vec3 val){
|
|||||||
|
|
||||||
vec3 getPosition(in float depth, in vec2 uv){
|
vec3 getPosition(in float depth, in vec2 uv){
|
||||||
vec4 pos = vec4(uv, depth, 1.0) * 2.0 - 1.0;
|
vec4 pos = vec4(uv, depth, 1.0) * 2.0 - 1.0;
|
||||||
pos = m_ViewProjectionMatrixInverse * pos;
|
pos = g_ViewProjectionMatrixInverse * pos;
|
||||||
return pos.xyz / pos.w;
|
return pos.xyz / pos.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,8 +151,6 @@ public class WaterFilter extends Filter {
|
|||||||
biasMatrix.mult(sceneCam.getViewProjectionMatrix(), textureProjMatrix);
|
biasMatrix.mult(sceneCam.getViewProjectionMatrix(), textureProjMatrix);
|
||||||
material.setMatrix4("TextureProjMatrix", textureProjMatrix);
|
material.setMatrix4("TextureProjMatrix", textureProjMatrix);
|
||||||
material.setVector3("CameraPosition", sceneCam.getLocation());
|
material.setVector3("CameraPosition", sceneCam.getLocation());
|
||||||
material.setMatrix4("ViewProjectionMatrixInverse", sceneCam.getViewProjectionMatrix().invert());
|
|
||||||
|
|
||||||
material.setFloat("WaterHeight", waterHeight);
|
material.setFloat("WaterHeight", waterHeight);
|
||||||
|
|
||||||
//update reflection cam
|
//update reflection cam
|
||||||
|
Loading…
x
Reference in New Issue
Block a user