Skip to content

Doesn't properly work with orthographic camera #3

@STARasGAMES

Description

@STARasGAMES

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions