Orthographic depth

Node-based Shader Editor

Orthographic depth

Postby empika » Tue Feb 19, 2019 4:17 am

Hi there,

I'm trying to recreate a toon water shader that uses depth for the water colour and edge foam but I'm having some issues using it with an orthographic camera.

https://roystan.net/articles/toon-water.html https://github.com/IronWarrior/ToonWate ... ter.shader

When in perspective mode it looks like the depth texture is getting fetched correctly

Image

The rear plane is actually angles underneath the water, and the tilemap underneath that has a missing tile hence the large dar square.

However in orthographic mode it looks like the depth map needs some kind of transform done to it, rather than the plane of water having a linear color it fades in the z axis when there is nothing underneath it.

Image

I've read a couple of posts on here that say I should not convert the depth texture to linear (as it already is linear), I am also adjusting the clipping planes to bring the texture resolution up. I've also tried adding some controls to my shader to adjust the clipping plane and depth but I still think the problem lies in the Z axis.

Here's my node graph:

Image

Any advice on how to get this working in orthographic perspective?

Many thanks,
Edd
empika
 
Posts: 4
Joined: Thu Feb 07, 2019 3:53 am

Re: Orthographic depth

Postby empika » Tue Feb 19, 2019 7:16 am

With help from the folks in the Unity discord I got this working:

Image

I switched to using the 0-1 depth space, and then remapped that to the clipping planes. The most important part was subtracting the surface depth from the remapped screen depth rather than the screenPos.w.
empika
 
Posts: 4
Joined: Thu Feb 07, 2019 3:53 am

Re: Orthographic depth

Postby Amplify_Borba » Tue Feb 19, 2019 2:03 pm

Hello, thank you for sharing your findings with us, we really appreciate it!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 15 guests