float4x4 mvp : ModelViewProjection; float4x4 mv : ModelView; float4x4 mvit : ModelViewIT; float3 refFactor = float3(1.1,1.3,1.5); float fresOffset = 0.1; float fresScale = 0.3; float fresPower = 0.2; samplerCUBE skybox : SKYBOX; string jointGeo = "cylinder.obj"; float4 vertex(uniform float4x4 modelViewProj, uniform float4x4 modelView, uniform float4x4 modelViewIT, float4 P : POSITION, float4 N : NORMAL, float2 uvIn : TEXCOORD0, in float4 Cin : COLOR0, out float3 CC : COLOR0, out float2 uv : TEXCOORD0, out float3 Pcam : TEXCOORD1, out float3 Ncam : TEXCOORD2) : POSITION { CC.xyz = normalize(N.xyz); uv = uvIn; Pcam = mul(modelView, P).xyz; Ncam = mul(modelView, N).xyz; return mul(modelViewProj, P); } float3 toRGB(float hue) { float r = max(min(hue*3-2, 1), 0) + max(min(1-hue*3, 1), 0); float g = max(min(hue*3-0, 1), 0) - max(min(hue*3-1, 1), 0); float b = max(min(hue*3-1, 1), 0) - max(min(hue*3-2, 1), 0); return float3(r,g,b); } float3 toRGB2(float hue) { float b = max(min(hue*2, 1), 0) - max(min(hue*2-1, 1), 0); float g = 1-b; return float3(0,g,b); } float4 rainbow( float4 col : COLOR0, float3 texcoord : TEXCOORD0, float3 Pcam : TEXCOORD1, float3 Ncam : TEXCOORD2) : COLOR { float dist = sqrt(Pcam.x*Pcam.x + Pcam.y*Pcam.y + Pcam.z*Pcam.z); float angle = dot(-normalize(Pcam), normalize(Ncam)); float factor = (cos(dist*70)+1)/2; //see stronger 'interference' effect: (1-angle)*(cos(dist*10000)+1)/2; float3 c = toRGB(factor); return float4(c, 1); } technique red { pass p0 { VertexProgram = compile arbvp1 vertex(mvp, mv, mvit); FragmentProgram = compile arbfp1 rainbow(); } }