Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't properly work with orthographic camera #3

Open
STARasGAMES opened this issue May 31, 2022 · 0 comments
Open

Doesn't properly work with orthographic camera #3

STARasGAMES opened this issue May 31, 2022 · 0 comments

Comments

@STARasGAMES
Copy link

Title.

The problem is that depth texture produced by orthographic camera is linear, not exponential like in a perspective camera. Therefore, using LinearEyeDepth is not correct for orthographic camera.

To fix this issue you need to change GTAO.cginc
At line ~30 change from

inline half4 ConvertDepth( const half2 aUV, const half aSampledDepth )
{
	const half viewDepth = LinearEyeDepth( aSampledDepth );

...

to

float CorrectDepth(float rawDepth)
{
	float persp = LinearEyeDepth(rawDepth);
	float ortho = (_ProjectionParams.z-_ProjectionParams.y)*(1-rawDepth)+_ProjectionParams.y;
	return lerp(persp,ortho,unity_OrthoParams.w);
}

inline half4 ConvertDepth( const half2 aUV, const half aSampledDepth )
{
	const half viewDepth = CorrectDepth( aSampledDepth );

...

Hope this helps someone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant