Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/script_engine/shaders/water.frag @ 4061

Last change on this file since 4061 was 3542, checked in by bensch, 19 years ago

data: new shaders

File size: 718 bytes
Line 
1sampler Tex: register(s0);
2sampler Env: register(s1);
3float off;
4
5float4 main(float2 texCoord: TEXCOORD0, float3 viewVec: TEXCOORD1) : COLOR {
6        const float4 waterColor = float4(0.3, 0.4, 1.0, 0.0);
7
8        float4 s = tex2D(Tex, texCoord) - 0.5;
9        float sobelX = s.z;
10        float sobelY = s.w;
11
12        float3 normal = float3(sobelX, 0.04, sobelY);
13
14        normal  = normalize(normal);
15        viewVec = normalize(viewVec);
16
17        float3 reflVec = reflect(viewVec, normal);
18        float4 refl = texCUBE(Env, reflVec) * 0.9;
19
20        float3 refrVec = refract(viewVec, normal, 0.85);
21        float4 refr = texCUBE(Env, refrVec) * waterColor;
22
23        return lerp(refl, refr, -dot(viewVec, normal));
24}
Note: See TracBrowser for help on using the repository browser.