diff options
Diffstat (limited to 'linden/indra/newview/app_settings/shaders/class2/deferred/waterV.glsl')
-rw-r--r-- | linden/indra/newview/app_settings/shaders/class2/deferred/waterV.glsl | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/waterV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/waterV.glsl new file mode 100644 index 0000000..b45e5c5 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class2/deferred/waterV.glsl | |||
@@ -0,0 +1,76 @@ | |||
1 | /** | ||
2 | * @file waterV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | void calcAtmospherics(vec3 inPositionEye); | ||
9 | |||
10 | uniform vec2 d1; | ||
11 | uniform vec2 d2; | ||
12 | uniform float time; | ||
13 | uniform vec3 eyeVec; | ||
14 | uniform float waterHeight; | ||
15 | |||
16 | varying vec4 refCoord; | ||
17 | varying vec4 littleWave; | ||
18 | varying vec4 view; | ||
19 | |||
20 | varying vec4 vary_position; | ||
21 | |||
22 | float wave(vec2 v, float t, float f, vec2 d, float s) | ||
23 | { | ||
24 | return (dot(d, v)*f + t*s)*f; | ||
25 | } | ||
26 | |||
27 | void main() | ||
28 | { | ||
29 | //transform vertex | ||
30 | vec4 position = gl_Vertex; | ||
31 | mat4 modelViewProj = gl_ModelViewProjectionMatrix; | ||
32 | |||
33 | vec4 oPosition; | ||
34 | |||
35 | //get view vector | ||
36 | vec3 oEyeVec; | ||
37 | oEyeVec.xyz = position.xyz-eyeVec; | ||
38 | |||
39 | float d = length(oEyeVec.xy); | ||
40 | float ld = min(d, 2560.0); | ||
41 | |||
42 | position.xy = eyeVec.xy + oEyeVec.xy/d*ld; | ||
43 | view.xyz = oEyeVec; | ||
44 | |||
45 | d = clamp(ld/1536.0-0.5, 0.0, 1.0); | ||
46 | d *= d; | ||
47 | |||
48 | oPosition = position; | ||
49 | oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); | ||
50 | vary_position = gl_ModelViewMatrix * oPosition; | ||
51 | oPosition = modelViewProj * oPosition; | ||
52 | |||
53 | refCoord.xyz = oPosition.xyz + vec3(0,0,0.2); | ||
54 | |||
55 | //get wave position parameter (create sweeping horizontal waves) | ||
56 | vec3 v = position.xyz; | ||
57 | v.x += (cos(v.x*0.08/*+time*0.01*/)+sin(v.y*0.02))*6.0; | ||
58 | |||
59 | //push position for further horizon effect. | ||
60 | position.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z); | ||
61 | position.w = 1.0; | ||
62 | position = position*gl_ModelViewMatrix; | ||
63 | |||
64 | calcAtmospherics((gl_ModelViewMatrix * gl_Vertex).xyz); | ||
65 | |||
66 | |||
67 | //pass wave parameters to pixel shader | ||
68 | vec2 bigWave = (v.xy) * vec2(0.04,0.04) + d1 * time * 0.055; | ||
69 | //get two normal map (detail map) texture coordinates | ||
70 | littleWave.xy = (v.xy) * vec2(0.45, 0.9) + d2 * time * 0.13; | ||
71 | littleWave.zw = (v.xy) * vec2(0.1, 0.2) + d1 * time * 0.1; | ||
72 | view.w = bigWave.y; | ||
73 | refCoord.w = bigWave.x; | ||
74 | |||
75 | gl_Position = oPosition; | ||
76 | } | ||