Depth Blend with orthographic camera

Node-based Shader Editor

Depth Blend with orthographic camera

Postby Spyrou » Sun Jan 28, 2018 12:30 pm

Hello guys !
As a beginner in all the shader stuff, I followed all your tutorials. One of them was about depth fog, a very interesting effect. I noticed this tutorial only work with a perspective camera. I was wondering if you have some hints to make the same effect with an orthographic camera.

The effect: https://ibb.co/mmmeib
The shader from tutorial: https://ibb.co/h59X3b

Thanks,

Konrad
Spyrou
 
Posts: 2
Joined: Sat Jan 27, 2018 12:22 pm

Re: Depth Blend with orthographic camera

Postby Ricardo Teixeira » Mon Jan 29, 2018 11:51 am

Hello,

Thank you for using ASE, we really appreciate it. Unfortunately, Depth Fade is not ideal under orthographic setups.

To give a bit of a clarification on what's happening under the hood, the Screen Depth node is fetching depth values directly from the depth buffer. These values, when working on a perspective projection are in a logarithmic scale. This is done to have better precision on values closer to the camera that the ones furthest away. On the ASE side, when fetching those values, we need to transform them into a linear space so they can be used by other nodes ( which do linear operations ).

When using an Orthographic camera, the depth values are instead stored on the depth buffer as linear depth values. This is because in orthographic projection you always see the objects at the same size independently on the distance they have from the camera, so there's no reason to have better accuracy on closer objects.

In order to approximate the effect you will have to disable "Convert To Linear" in the Screen Depth node and adjust your camera Far/Near Clip values. I attached a simple example for quick reference, do keep in mind that, as mentioned above, the results we'll be slightly different as Depth Fade is not ideal for orthographic cameras.

Alternatively, depending on your current requirements, consider using Fog or simple position based transparency. Do note that Transparency is not a perfect solution, it really depends on what you intend to create.

Image

Looking forward to your feedback.
Attachments
fade.zip
(1.51 KiB) Downloaded 169 times
Sales & 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
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: Depth Blend with orthographic camera

Postby Spyrou » Sun Feb 04, 2018 5:11 pm

Hello !

Thanks for your reply. Sorry for the delay, I didn't get a notification.

The world position fade seems to be the better effect for what I want to achieve. Actually, I was thinking to create a cloud ocean around my board. (like this image)

I take some time to experiment with the world and vertex position. I thought I could put a cube next to my board to create the fade effect on it and not directly on the board. But when I switch values, the top vertices are not displayed.
https://ibb.co/euLcQc
https://ibb.co/ezyLdx

Unless there is another solution, I think I will go for the world position fade on my board.

What Fog are you talking about ? The Unity one within the post-processing stack ? With particles ?

Thanks.

Konrad.
Spyrou
 
Posts: 2
Joined: Sat Jan 27, 2018 12:22 pm

Re: Depth Blend with orthographic camera

Postby Ricardo Teixeira » Mon Feb 05, 2018 11:40 am

Spyrou wrote:Hello !

Thanks for your reply. Sorry for the delay, I didn't get a notification.

The world position fade seems to be the better effect for what I want to achieve. Actually, I was thinking to create a cloud ocean around my board. (like this image)

I take some time to experiment with the world and vertex position. I thought I could put a cube next to my board to create the fade effect on it and not directly on the board. But when I switch values, the top vertices are not displayed.
https://ibb.co/euLcQc
https://ibb.co/ezyLdx

Unless there is another solution, I think I will go for the world position fade on my board.

What Fog are you talking about ? The Unity one within the post-processing stack ? With particles ?

Thanks.

Konrad.


Hello Konrad,

If you find that the world space mask is too limiting, consider using a texture mask. I'm not entirely sure what the expected results should be but, in your screenshot, given that the mask is inverted and the top vertices alpha is 0, the top face will not be visible.

I was referring to the default Unity fog.

Let me know if you have any followup questions, I would be happy to help.

Thanks!
Sales & 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
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 0 guests