// input struct vtxin { float4 position: POSITION; float3 normal: NORMAL; float4 color: COLOR0; float4 texCoord: TEXCOORD0; }; // vtx output struct vtxout { float4 position: POSITION; // eye space float4 texCoord: TEXCOORD0; float4 color: COLOR0; float4 worldPos: TEXCOORD1; // world position float3 normal: TEXCOORD2; }; // fragment input struct fragin { float4 position: POSITION; // eye space float4 texCoord: TEXCOORD0; float4 projPos: WPOS; float4 color: COLOR0; float4 worldPos: TEXCOORD1; // world position float3 normal: TEXCOORD2; }; struct pixel { float4 col: COLOR0; float4 pos: COLOR1; float3 norm: COLOR2; }; vtxout vtx(vtxin IN, uniform float4x4 ModelViewProj) { vtxout OUT; // transform the vertex position into eye space OUT.position = mul(ModelViewProj, IN.position); OUT.color = IN.color; OUT.texCoord = IN.texCoord; OUT.worldPos = IN.position; // eye pos with linear depth //OUT.worldPos = OUT.position; OUT.normal = IN.normal; return OUT; } pixel frag(fragin IN, uniform sampler2D tex, uniform float maxDepth) { pixel pix; pix.col = tex2D(tex, IN.texCoord.xy); pix.pos = IN.worldPos * maxDepth; pix.pos.w = IN.projPos.w; pix.norm = IN.normal; return pix; }