struct VOut { float4 p : POSITION; float2 uv : TEXCOORD0; float3 a : TEXCOORD1; float4 ssaoUV : TEXCOORD2; }; VOut ambient_vs( in float4 p : POSITION, in float2 uv : TEXCOORD0, uniform float3 ambient, uniform float4x4 wvp ) { VOut OUT; OUT.p = mul(wvp, p); // just use projective texture which == OUT.p OUT.ssaoUV = OUT.p; OUT.a = ambient; OUT.uv = uv; return OUT; } struct PIn { float2 uv : TEXCOORD0; float3 a : TEXCOORD1; float4 ssaoUV : TEXCOORD2; }; float4 ambient_ps(PIn IN, uniform sampler2D diffuseTex : TEXUNIT0, uniform sampler2D ssaoTex : TEXUNIT1): COLOR0 { float2 ssaoUV = IN.ssaoUV.xy / IN.ssaoUV.w; // perspective divide // move into texture space ssaoUV = (float2(ssaoUV.x, -ssaoUV.y) + 1.0) * 0.5; float3 ssao = tex2D(ssaoTex, ssaoUV).rgb; float3 diffuse = tex2D(diffuseTex, IN.uv).rgb; return float4(diffuse * IN.a/* * ssao*/, 1); }