1 | float4x4 mvp : ModelViewProjection;
|
---|
2 | float4x4 mv : ModelView;
|
---|
3 | float4x4 mvit : ModelViewIT;
|
---|
4 | float3 refFactor = float3(1.1,1.3,1.5);
|
---|
5 | float fresOffset = 0.1;
|
---|
6 | float fresScale = 0.3;
|
---|
7 | float fresPower = 0.2;
|
---|
8 |
|
---|
9 | samplerCUBE skybox : SKYBOX;
|
---|
10 | string jointGeo = "cylinder.obj";
|
---|
11 |
|
---|
12 | float4 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 |
|
---|
32 | float3 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 |
|
---|
40 | float3 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 |
|
---|
47 | float4 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 |
|
---|
59 | technique red <string target = "both";>
|
---|
60 | {
|
---|
61 | pass p0
|
---|
62 | {
|
---|
63 | VertexProgram = compile arbvp1 vertex(mvp, mv, mvit);
|
---|
64 | FragmentProgram = compile arbfp1 rainbow();
|
---|
65 | }
|
---|
66 | } |
---|