Watergit push!
This commit is contained in:
@@ -22,6 +22,22 @@ Comments:
|
||||
OGRE_NATIVE_GLSL_VERSION_DIRECTIVE
|
||||
#include <OgreUnifiedShader.h>
|
||||
|
||||
#if NEW_WATER_SHADER
|
||||
OGRE_UNIFORMS(
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 viewMatrix;
|
||||
uniform mat4 modelMatrix;
|
||||
)
|
||||
MAIN_PARAMETERS
|
||||
IN(vec4 position, POSITION)
|
||||
OUT(vec4 clipSpace, TEXCOORD0)
|
||||
MAIN_DECLARATION
|
||||
{
|
||||
clipSpace = projectionMatrix * viewMatrix * modelMatrix * vec4(position.xyz, 1.0);
|
||||
gl_Position = clipSpace;
|
||||
}
|
||||
|
||||
#else
|
||||
OGRE_UNIFORMS(
|
||||
uniform vec3 eyePosition;
|
||||
uniform float BumpScale;
|
||||
@@ -30,12 +46,14 @@ uniform vec2 bumpSpeed;
|
||||
uniform highp float time;
|
||||
uniform float waveFreq;
|
||||
uniform float waveAmp;
|
||||
uniform vec4 cameraPositionOS;
|
||||
uniform mat4 world;
|
||||
uniform mat4 viewProj;
|
||||
uniform mat4 worldView;
|
||||
uniform mat4 worldViewProj;
|
||||
uniform mat4 textureProjMatrix;
|
||||
uniform mat3 normalMatrix;
|
||||
uniform vec3 lightDirection;
|
||||
uniform float scale; // the amount to scale the noise texture by
|
||||
uniform float scroll; // the amount by which to scroll the noise
|
||||
uniform float noise; // the noise perturb as a factor of the time
|
||||
@@ -89,30 +107,46 @@ vec4 wave2(vec4 parameter, vec2 position, float t, inout vec3 tangent, inout vec
|
||||
MAIN_PARAMETERS
|
||||
IN(vec4 vertex, POSITION)
|
||||
IN(vec3 normal, NORMAL)
|
||||
IN(vec3 tangent, TANGENT)
|
||||
IN(vec4 uv0, TEXCOORD0)
|
||||
OUT(f32vec3 positionWS, TEXCOORD0)
|
||||
OUT(f32vec3 vnormal, TEXCOORD1)
|
||||
OUT(f32vec3 vbinormal, TEXCOORD2)
|
||||
OUT(f32vec3 vtangent, TEXCOORD3)
|
||||
OUT(float vertex_height, TEXCOORD4)
|
||||
OUT(f32vec3 viewDirection, TEXCOORD2)
|
||||
OUT(f32vec3 viewDirectionTS, TEXCOORD3)
|
||||
OUT(f32vec3 olightDirection, TEXCOORD4)
|
||||
// OUT(f32vec3 vbinormal, TEXCOORD2)
|
||||
// OUT(f32vec3 vtangent, TEXCOORD3)
|
||||
// OUT(float vertex_height, TEXCOORD4)
|
||||
OUT(f32vec3 lightDirectionTS, TEXCOORD5)
|
||||
OUT(f32vec2 bumpCoord0, TEXCOORD6)
|
||||
MAIN_DECLARATION
|
||||
{
|
||||
float textureScale = 0.6;
|
||||
float bumpSpeed = 0.8;
|
||||
f32vec4 position = vec4(mul(world, vertex).xyz, 1.0);
|
||||
f32vec3 vertex_position = position.xyz;
|
||||
f32vec3 tang = vec3(0.0, 0.0, 0.0);
|
||||
f32vec3 bin = vec3(0.0, 0.0, 0.0);
|
||||
f32vec3 tang = tangent;
|
||||
f32vec3 bin = cross(tangent, normal);
|
||||
position += wave(wave_a, vertex_position.xz, time, tang, bin);
|
||||
position += wave(wave_b, vertex_position.xz, time, tang, bin);
|
||||
position += wave(wave_c, vertex_position.xz, time, tang, bin);
|
||||
position += wave(wave_d, vertex_position.xz, time, tang, bin);
|
||||
vtangent = tang;
|
||||
vbinormal = bin;
|
||||
vertex_position = position.xyz;
|
||||
// vtangent = tang;
|
||||
// vbinormal = bin;
|
||||
// vertex_position = position.xyz;
|
||||
// vnormal = normalize(mul(mat3(world), cross(vbinormal, vtangent)));
|
||||
vnormal = normalize(cross(vbinormal, vtangent));
|
||||
vnormal = normalize(cross(bin, tang));
|
||||
mat3 TBN = mtxFromRows(tang, bin, vnormal);
|
||||
// vnormal = normalize(vec3(0.0, 1.0, 0.0));
|
||||
|
||||
// gl_Position = mul(worldViewProj, vertex);
|
||||
viewDirection = vertex.xyz - cameraPositionOS.xyz;
|
||||
viewDirectionTS = mul(TBN, viewDirection);
|
||||
olightDirection = lightDirection;
|
||||
lightDirectionTS = mul(TBN, lightDirection);
|
||||
gl_Position = mul(viewProj, position);
|
||||
positionWS = mul(world, vertex).xyz;
|
||||
bumpCoord0.xy = uv0.xy * textureScale + time * bumpSpeed;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user