Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualWFP

Posted 28 March 2013 - 04:13 PM

My idea above seems to have worked for the most part!  Here's the new code to recalculate the view ray for the random sample:

 

		// sample a point near position within the occlusion radius
		float3 q = position + flip * gOcclusionRadius * offset;
		// new viewRay calculation
		float3 viewRay = float3(q.xy / q.z, 1.0f);

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

		// find nearest depth value along ray from eye to q
		float rz = depthStencilTexture.SampleLevel(samNormalDepth, projQ.xy, 0.0f).r;

		// reconstruct full view space position r = (rx, ry, rz)
		linearDepth = projectionB / (rz - projectionA);
		// use newly calculated viewRay
		float3 r = viewRay * linearDepth;

 

I've added a result screenshot below (still pre-blurring).  If there are any other glaring deficiencies you see with this result or the way I'm calculating it please let me know! smile.png

 

Thanks!


#1WFP

Posted 28 March 2013 - 04:13 PM

My idea above seems to have worked for the most part!  Here's the new code to recalculate the view ray for the random sample:

 

		// sample a point near position within the occlusion radius
		float3 q = position + flip * gOcclusionRadius * offset;
		// new viewRay calculation
		float3 viewRay = float3(q.xy / q.z, 1.0f);

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

		// find nearest depth value along ray from eye to q
		float rz = depthStencilTexture.SampleLevel(samNormalDepth, projQ.xy, 0.0f).r;

		// reconstruct full view space position r = (rx, ry, rz)
		linearDepth = projectionB / (rz - projectionA);
		// use newly calculated viewRay
		float3 r = viewRay * linearDepth;

 

I've added a result screenshot below (still pre-blurring).  If there are any other glaring deficiencies you see with this result or the way I'm calculating it please let me know! :)

 

Thanks!


PARTNERS