Hello,
I'm implementing SSAO for my engine but I noticed the kernel wasn't rotating properly.
What happens is when I sample my random-vector texture I always get the same result, regardless of input texture coordinates.
Here's my shader:
Texture2D randomTexture : register(t2);
SamplerState smplr
{
Filter = D3D11_FILTER_ANISOTROPIC;
AddressU = Wrap;
AddressV = Wrap;
};
float4 PS_main( in float4 screenPos : SV_Position) : SV_TARGET0
{
//screensize 1280x720, randomTexture size 64x64
float2 rvecCoord = float2(screenPos.x * 1280.f / 64.f, screenPos.y * 720.f / 64.f);
float3 rvec = randomTexture.Sample(smplr, rvecCoord).xyz;
return float4(rvec, 1.0f);
}
Off-topic code omitted.
I cant for the love of my life figure out why this sample would always give me the same result.
Changing the line :
float2 rvecCoord = float2(screenPos.x * 1280.f / 64.f, screenPos.y * 720.f / 64.f);
to
float2 rvecCoord = float2(screenPos.xy);
seems to make no difference.
Here's a print of the shader state.
Any help appreciated! ❤️