source: java/client_3D/static/shared/res/shaders/candy.cgfx @ 72

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

added sources of the 3D client for the Framsticks server

File size: 1.9 KB
Line 
1float4x4 mvp : ModelViewProjection;
2float4x4 mv : ModelView;
3float4x4 mvit : ModelViewIT;
4float3 refFactor = float3(1.1,1.3,1.5);
5float fresOffset = 0.1;
6float fresScale = 0.3;
7float fresPower = 0.2;
8
9samplerCUBE skybox : SKYBOX;
10string jointGeo = "cylinder.obj";
11
12float4 vertex(uniform float4x4 modelViewProj,
13              uniform float4x4 modelView,
14              uniform float4x4 modelViewIT,
15              float4 P : POSITION,
16              float4 N : NORMAL,
17              float2 uvIn : TEXCOORD0,
18                 in float4 Cin : COLOR0,
19
20              out float3 CC : COLOR0,
21                          out float2 uv : TEXCOORD0,
22              out float3 Pcam : TEXCOORD1,
23              out float3 Ncam : TEXCOORD2) : POSITION
24{
25    CC.xyz =  normalize(N.xyz);
26    uv = uvIn;
27    Pcam = mul(modelView, P).xyz;
28    Ncam = mul(modelView, N).xyz;
29    return mul(modelViewProj, P);
30}
31
32float3 toRGB(float hue)
33{
34        float r = max(min(hue*3-2, 1), 0) + max(min(1-hue*3, 1), 0);
35        float g = max(min(hue*3-0, 1), 0) - max(min(hue*3-1, 1), 0);
36        float b = max(min(hue*3-1, 1), 0) - max(min(hue*3-2, 1), 0);
37        return float3(r,g,b);
38}
39
40float3 toRGB2(float hue)
41{
42        float b = max(min(hue*2, 1), 0) - max(min(hue*2-1, 1), 0);
43        float g = 1-b;
44        return float3(0,g,b);
45}
46
47float4 rainbow(   float4 col : COLOR0,
48                  float3 texcoord : TEXCOORD0,
49                  float3 Pcam : TEXCOORD1,
50                  float3 Ncam : TEXCOORD2) : COLOR
51{
52        float dist = sqrt(Pcam.x*Pcam.x + Pcam.y*Pcam.y + Pcam.z*Pcam.z);
53        float angle = dot(-normalize(Pcam), normalize(Ncam));
54        float factor = (cos(dist*70)+1)/2;  //see stronger 'interference' effect: (1-angle)*(cos(dist*10000)+1)/2;
55        float3 c = toRGB(factor);
56        return float4(c, 1);
57}
58
59technique red <string target = "both";>
60{
61        pass p0
62        {
63                VertexProgram = compile arbvp1 vertex(mvp, mv, mvit);
64                FragmentProgram = compile arbfp1 rainbow();
65        }
66}
Note: See TracBrowser for help on using the repository browser.