2012-02-09 18:55:25 +01:00
|
|
|
#version 110
|
|
|
|
|
2008-09-18 04:14:05 +02:00
|
|
|
uniform mat4 reflectionMatrix;
|
|
|
|
uniform mat4 refractionMatrix;
|
2011-02-03 02:12:24 +01:00
|
|
|
uniform mat4 losMatrix;
|
2012-10-31 19:42:17 +01:00
|
|
|
uniform mat4 shadowTransform;
|
2011-07-13 01:48:05 +02:00
|
|
|
uniform float repeatScale;
|
2014-07-03 22:07:15 +02:00
|
|
|
uniform float windAngle;
|
2012-10-31 19:42:17 +01:00
|
|
|
uniform float waviness; // "Wildness" of the reflections and refractions; choose based on texture
|
2014-07-28 12:14:00 +02:00
|
|
|
uniform vec3 sunDir;
|
2012-10-31 19:42:17 +01:00
|
|
|
|
|
|
|
#if USE_SHADOW_SAMPLER && USE_SHADOW_PCF
|
|
|
|
uniform vec4 shadowScale;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
uniform float time;
|
|
|
|
uniform float mapSize;
|
2008-09-18 04:14:05 +02:00
|
|
|
|
2014-07-28 12:14:00 +02:00
|
|
|
uniform mat4 transform;
|
|
|
|
|
2008-09-18 04:14:05 +02:00
|
|
|
varying vec3 worldPos;
|
|
|
|
varying float waterDepth;
|
2014-07-28 12:14:00 +02:00
|
|
|
varying vec2 waterInfo;
|
|
|
|
|
2014-08-02 14:54:45 +02:00
|
|
|
varying vec4 normalCoords;
|
|
|
|
varying vec3 reflectionCoords;
|
|
|
|
varying vec3 refractionCoords;
|
|
|
|
varying vec2 losCoords;
|
|
|
|
|
2014-07-28 12:14:00 +02:00
|
|
|
varying float fwaviness;
|
|
|
|
varying vec2 WindCosSin;
|
2014-07-01 18:05:05 +02:00
|
|
|
|
|
|
|
#if USE_SHADOW && USE_SHADOWS_ON_WATER
|
2012-11-04 16:54:36 +01:00
|
|
|
varying vec4 v_shadow;
|
|
|
|
#endif
|
2014-07-28 12:14:00 +02:00
|
|
|
|
2012-02-13 15:02:14 +01:00
|
|
|
attribute vec3 a_vertex;
|
2014-07-28 12:14:00 +02:00
|
|
|
attribute vec2 a_waterInfo;
|
|
|
|
attribute vec3 a_otherPosition;
|
|
|
|
|
2008-09-18 04:14:05 +02:00
|
|
|
void main()
|
|
|
|
{
|
2014-07-28 12:14:00 +02:00
|
|
|
worldPos = vec3(a_vertex.x,15.0,a_vertex.z);
|
2013-04-27 14:20:42 +02:00
|
|
|
waterInfo = a_waterInfo;
|
2014-07-28 12:14:00 +02:00
|
|
|
waterDepth = a_waterInfo.g;
|
|
|
|
|
|
|
|
WindCosSin = vec2(cos(-windAngle),sin(-windAngle));
|
2012-10-31 19:42:17 +01:00
|
|
|
|
2014-07-28 12:14:00 +02:00
|
|
|
float newX = a_vertex.x * WindCosSin.x - a_vertex.z * WindCosSin.y;
|
|
|
|
float newY = a_vertex.x * WindCosSin.y + a_vertex.z * WindCosSin.x;
|
2014-07-05 12:20:30 +02:00
|
|
|
|
2014-08-02 14:54:45 +02:00
|
|
|
normalCoords = vec4(newX,newY,time,0.0);
|
|
|
|
normalCoords.xy *= repeatScale;
|
|
|
|
reflectionCoords = (reflectionMatrix * vec4(a_vertex, 1.0)).rga; // projective texturing
|
|
|
|
refractionCoords = (refractionMatrix * vec4(a_vertex, 1.0)).rga;
|
|
|
|
losCoords = (losMatrix * vec4(a_vertex, 1.0)).rg;
|
2012-10-31 19:42:17 +01:00
|
|
|
|
2014-07-01 18:05:05 +02:00
|
|
|
#if USE_SHADOW && USE_SHADOWS_ON_WATER
|
2012-10-31 19:42:17 +01:00
|
|
|
v_shadow = shadowTransform * vec4(a_vertex, 1.0);
|
|
|
|
#if USE_SHADOW_SAMPLER && USE_SHADOW_PCF
|
|
|
|
v_shadow.xy *= shadowScale.xy;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2014-07-28 12:14:00 +02:00
|
|
|
// Fix the waviness for local wind strength
|
|
|
|
fwaviness = waviness * ((0.15+a_waterInfo.r/1.15));
|
|
|
|
|
|
|
|
gl_Position = transform * vec4(a_vertex, 1.0);
|
2008-09-18 04:14:05 +02:00
|
|
|
}
|