Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/shaders/glsl/water_high.vs
#version 110 | #version 110 | ||||
uniform mat4 reflectionMatrix; | uniform mat4 reflectionMatrix; | ||||
uniform mat4 refractionMatrix; | uniform mat4 refractionMatrix; | ||||
uniform mat4 losMatrix; | uniform mat4 losMatrix; | ||||
uniform mat4 shadowTransform; | uniform mat4 shadowTransform; | ||||
uniform float repeatScale; | uniform float repeatScale; | ||||
uniform float windAngle; | uniform float windAngle; | ||||
uniform float waviness; // "Wildness" of the reflections and refractions; choose based on texture | // "Wildness" of the reflections and refractions; choose based on texture | ||||
uniform float waviness; | |||||
uniform vec3 sunDir; | uniform vec3 sunDir; | ||||
#if USE_SHADOW_SAMPLER && USE_SHADOW_PCF | #if USE_SHADOW_SAMPLER && USE_SHADOW_PCF | ||||
uniform vec4 shadowScale; | uniform vec4 shadowScale; | ||||
#endif | #endif | ||||
uniform float time; | uniform float time; | ||||
uniform float mapSize; | uniform float mapSize; | ||||
varying float moddedTime; | |||||
uniform mat4 transform; | uniform mat4 transform; | ||||
uniform vec3 cameraPos; | |||||
varying float moddedTime; | |||||
varying vec3 worldPos; | varying vec3 worldPos; | ||||
varying float waterDepth; | varying float waterDepth; | ||||
varying vec2 waterInfo; | varying vec2 waterInfo; | ||||
uniform vec3 cameraPos; | |||||
varying vec3 v; | varying vec3 v; | ||||
varying vec4 normalCoords; | varying vec4 normalCoords; | ||||
varying vec3 reflectionCoords; | varying vec3 reflectionCoords; | ||||
varying vec3 refractionCoords; | varying vec3 refractionCoords; | ||||
varying vec2 losCoords; | varying vec2 losCoords; | ||||
varying float fwaviness; | varying float fwaviness; | ||||
varying vec2 WindCosSin; | varying vec2 WindCosSin; | ||||
#if USE_SHADOW && USE_SHADOWS_ON_WATER | #if USE_SHADOW && USE_SHADOWS_ON_WATER | ||||
varying vec4 v_shadow; | varying vec4 v_shadow; | ||||
#endif | #endif | ||||
attribute vec3 a_vertex; | attribute vec3 a_vertex; | ||||
attribute vec2 a_waterInfo; | attribute vec2 a_waterInfo; | ||||
attribute vec3 a_otherPosition; | attribute vec3 a_otherPosition; | ||||
void main() | void main() | ||||
{ | { | ||||
worldPos = vec3(a_vertex.x,15.0,a_vertex.z); | worldPos = a_vertex; | ||||
waterInfo = a_waterInfo; | waterInfo = a_waterInfo; | ||||
waterDepth = a_waterInfo.g; | waterDepth = a_waterInfo.g; | ||||
WindCosSin = vec2(cos(-windAngle),sin(-windAngle)); | WindCosSin = vec2(cos(-windAngle), sin(-windAngle)); | ||||
float newX = a_vertex.x * WindCosSin.x - a_vertex.z * WindCosSin.y; | float newX = a_vertex.x * WindCosSin.x - a_vertex.z * WindCosSin.y; | ||||
float newY = a_vertex.x * WindCosSin.y + a_vertex.z * WindCosSin.x; | float newY = a_vertex.x * WindCosSin.y + a_vertex.z * WindCosSin.x; | ||||
normalCoords = vec4(newX,newY,time,0.0); | normalCoords = vec4(newX, newY, time, 0.0); | ||||
normalCoords.xy *= repeatScale; | normalCoords.xy *= repeatScale; | ||||
reflectionCoords = (reflectionMatrix * vec4(a_vertex, 1.0)).rga; // projective texturing | // Projective texturing | ||||
reflectionCoords = (reflectionMatrix * vec4(a_vertex, 1.0)).rga; | |||||
refractionCoords = (refractionMatrix * vec4(a_vertex, 1.0)).rga; | refractionCoords = (refractionMatrix * vec4(a_vertex, 1.0)).rga; | ||||
losCoords = (losMatrix * vec4(a_vertex, 1.0)).rg; | losCoords = (losMatrix * vec4(a_vertex, 1.0)).rg; | ||||
#if USE_SHADOW && USE_SHADOWS_ON_WATER | #if USE_SHADOW && USE_SHADOWS_ON_WATER | ||||
v_shadow = shadowTransform * vec4(a_vertex, 1.0); | v_shadow = shadowTransform * vec4(a_vertex, 1.0); | ||||
#if USE_SHADOW_SAMPLER && USE_SHADOW_PCF | #if USE_SHADOW_SAMPLER && USE_SHADOW_PCF | ||||
v_shadow.xy *= shadowScale.xy; | v_shadow.xy *= shadowScale.xy; | ||||
#endif | #endif | ||||
#endif | #endif | ||||
v = normalize(cameraPos - worldPos); | v = normalize(cameraPos - worldPos); | ||||
moddedTime = mod(time * 60.0, 8.0) / 8.0; | moddedTime = mod(time * 60.0, 8.0) / 8.0; | ||||
// Fix the waviness for local wind strength | // Fix the waviness for local wind strength | ||||
fwaviness = waviness * ((0.15+a_waterInfo.r/1.15)); | fwaviness = waviness * (0.15 + a_waterInfo.r / 1.15); | ||||
gl_Position = transform * vec4(a_vertex, 1.0); | gl_Position = transform * vec4(a_vertex, 1.0); | ||||
} | } |
Wildfire Games · Phabricator