• Advertisement
Sign in to follow this  

SSAO issue with NDC to Texture Space

This topic is 970 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I recently found out why my SSAO isn't looking so grand. The following was grabbed from Frank Luna's SSAO code:

	
	XMMATRIX T = XMMATRIX(
		0.5f, 0.0f, 0.0f, 0.0f,
		0.0f, -0.5f, 0.0f, 0.0f,
		0.0f, 0.0f, 1.0f, 0.0f,
		0.5f, 0.5f, 0.0f, 1.0f);
	
//	T = XMMatrixTranspose(T);
	XMVECTOR det2;

//	XMMATRIX P = XMMatrixTranspose(PROJ);

	XMMATRIX PT = XMMatrixMultiply(PROJ,T);
	screenCB->gViewToTexSpace = PT;

The depth being sent to the final SSAO shader file is the input.position.z by world * view * projection.

Inside the SSAO shader where ProjQ is muliplied by the gViewToTexSpace (bringing NDC to Texture Space);


		// Project q and generate projective tex-coords.
		
		float4 projQ = mul(float4(q, 1.0f), gViewToTexSpace);
		
		projQ /= projQ.w;
	

I get the following result with blurred on top of it:

 

[attachment=28511:ScreenCaptured_nossao04207225.jpg]

 

As you can see it's pretty messy and doesn't look like Frank Luna's SSAO or any other typical SSAO.

 

It's a bummer too and I would like to get this to work. I'm bad at matrix math but I'm guessing the projected texspace is taking the projection matrix * 0.5f + 0.5f;

 

So here I am stuck

Share this post


Link to post
Share on other sites
Advertisement

To me I don't think this is correct projected texture space. [0,1]

 

In addition you'll see as I do see why it screws up the SSAO

 

[attachment=28512:ScreenCaptured_nossao46441625.jpg]

 

Is this correct or am I correct this is not correct projected texture space

Share this post


Link to post
Share on other sites


To me I don't think this is correct projected texture space. [0,1]

It sounds like the right space to me.

 

NDC coordinates are [-1, 1] (at least in the x and y dimensions), so you need to multiply by 0.5 and add 0.5 to obtain the range [0, 1].

Share this post


Link to post
Share on other sites

I went back to my SSAO sample for my engine after reading some others complaints getting it running. I viewed youtube video and it clearly doesn't look like mine. When you reconstruct the position from depth isn't it suppost to look like how normals in view space? Also is it the inversed perspective multiplied by the view when calculating the SSAO term on a screen quad? Or is it ortho and view inversed multipled?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement