rjfalconer

RenderMonkey - Simple HLSL diffuse lighting shader jitters

Discussion created by rjfalconer on Mar 31, 2010
Latest reply on Apr 22, 2010 by Byron

Simple shader (see attached) compiles, but flickers and has artefects.

I'm expecting to see a sphere with a uniform gradient from white to black.

Effect workspace has matWorldInverseTranspose and matWorldViewProjection defined, as their predefined matricies.

(Running on ATi Radeon 4800 series)

Is it something I am doing wrong?

//Vertex float4x4 matWorldViewProjection; float4x4 matWorldInverseTranspose; float3 LightDirection : Direction = float3(1,0,0.5); struct VS_IN { float4 Position : POSITION; float3 Normal : NORMAL; }; struct VS_OUT { float4 Position : POSITION; float3 Light : TEXCOORD0; float3 Normal : TEXCOORD1; }; VS_OUT vs_main(VS_IN input) { VS_OUT output = (VS_OUT)0; output.Position = mul(input.Position,matWorldViewProjection); output.Light = normalize(LightDirection); output.Normal = normalize(mul(matWorldInverseTranspose,input.Normal)); return output; } //Pixel struct VS_OUT { float4 Position : POSITION; float3 Light : TEXCOORD0; float3 Normal : TEXCOORD1; }; struct PS_OUT { float4 Color : COLOR; }; PS_OUT ps_main(VS_OUT input) { PS_OUT output = (PS_OUT)0; output.Color = saturate(dot(input.Light,input.Normal)); return output; }

Outcomes