source: java/client_3D/static/shared/res/shaders/amber.cgfx @ 1325

Last change on this file since 1325 was 65, checked in by Maciej Komosinski, 14 years ago

added sources of the 3D client for the Framsticks server

File size: 2.0 KB
Line 
1float4x4 mvp : ModelViewProjection;
2float4x4 mv : ModelView;
3float4x4 mvit : ModelViewIT;
4
5samplerCUBE skybox : SKYBOX;
6
7sampler2D amberTex <string fileName = "amber.jpg";> = sampler_state {
8  minFilter = Linear;
9  magFilter = Linear;
10  wrapS = Repeat;
11  wrapT = Repeat;
12};
13
14float4 vertex(uniform float4x4 modelViewProj,
15              uniform float4x4 modelView,
16              uniform float4x4 modelViewIT,
17              float4 P : POSITION,
18              float4 N : NORMAL,
19                  float2 uvIn : TEXCOORD0,
20                   in float4 Cin : COLOR0,
21              out float4 CC : COLOR0,
22              out float3 Pcam : TEXCOORD1,
23              out float3 Ncam : TEXCOORD2,
24              out float2 uv : TEXCOORD0) : POSITION
25{
26    CC.xyz =  normalize(N.xyz);
27    Pcam = mul(modelView, P).xyz;
28    float3x3 rotation = (float3x3)modelView;
29    Ncam.xyz = mul(rotation,N.xyz);
30    uv = uvIn;
31    return mul(modelViewProj, P);
32}
33
34
35float4 light(in float3 texcoord,
36                float3 Pcam : TEXCOORD1,
37                float3 Ncam : TEXCOORD2) : COLOR
38{
39   float3 Nn = normalize(Ncam);
40
41   // Reflection and refraction.
42   float3 refl = reflect(Pcam,Nn);
43   float3 refrRed = refract(Pcam,Nn, 1.3);
44   float3 refrYellow = refract(Pcam,Nn,1.5);
45   
46   float3 reflCol = texCUBE(skybox,refl).rgb;
47   reflCol.b = 0;
48   
49   float3 refrRedCol;
50   refrRedCol.r = texCUBE(skybox,refrRed).r;
51   
52   float3 refrYellowCol;
53   refrYellowCol.r = texCUBE(skybox,refrYellow).r;
54   refrYellowCol.g = texCUBE(skybox,refrYellow).g;
55   
56   float3 refCol = (reflCol + refrRedCol + refrYellowCol) / 3.0;
57   
58   // Amber Texture:
59   float3 amberCol = tex2D(amberTex, texcoord);
60   
61   // Random factor:
62   float3 randomCol = normalize(Pcam);
63   randomCol.b *= .25;
64
65   float3 finalCol = (5.0 * refCol + 5.0 * amberCol + 0.0 * randomCol) / 10.0;
66   return float4(finalCol, 1);
67}
68
69technique red <string target = "both";>
70{
71        pass p0
72        {
73                VertexProgram = compile arbvp1 vertex(mvp, mv, mvit);
74                FragmentProgram = compile arbfp1 light();
75        }
76}
Note: See TracBrowser for help on using the repository browser.