Depth Fade to Object's Own Backfaces

Your feedback is very important to us. We are listening.

Depth Fade to Object's Own Backfaces

Postby Bitcoon » Thu Jul 26, 2018 5:20 am

Hi! I've been working with Amplify Shader Editor trying to get an effect that represents the "volume" of the transparent object you're looking through. Think of it like looking through a solid mass of light in the air - if you're looking through a really thin strip then it's not very bright, but if you look through a thicker portion it would be a lot lighter. I thought Depth Fade would accomplish this but I can't seem to find the right settings to accomplish this.

As I understand it, Depth Fade is looking at the depth of the solid objects rendered first, and comparing that to the depth of the current object being rendered in the Transparent queue. The difference between them is what it outputs. That much I understand, and it makes sense. Most people want to use this to 'detect' edges near objects for stuff like water intersecting land, but my use case is a bit different.

I could just accept that it won't work because the backfaces and front faces aren't both rendered separately onto different depth buffers so the method used here wouldn't do what I'm hoping it would. But the Wiki page seems to show that you can: http://wiki.amplify.pt/index.php?title= ... Depth_Fade

That page shows exactly the effect I'm going for, if I can also render it additive. I just can't figure out what settings were used to create this output. The box appears to detect not only other objects but also its own backfaces when determining depth and I'm hoping to do the same. Everything I try just seems to ignore the object's own depth, only comparing it with objects in the Geometry queue.

Any help you can give would be greatly appreciated! If I could just replicate what's shown on the Depth Fade page on the Wiki then I'd probably be all set to build this shader the way I wanted~
Bitcoon
 
Posts: 5
Joined: Thu May 24, 2018 10:19 pm

Re: Depth Fade to Object's Own Backfaces

Postby Amplify_Borba » Thu Jul 26, 2018 5:00 pm

Hello, thank you for getting in touch and for your support!

You should be able to produce the same effect from the node wiki page in the following way:

Image

In the example above, I haven't set the shader as Unlit, but the effect is still similar.
You also need to make sure you've set your Blend Mode to Translucent or Transparent.

It's important to note that there are also walls behind the objects from the screenshot on the wiki page, which influence the gradient.

If by some reason you're having trouble reproducing it, could you please share with us your Unity and ASE versions, together with a shader sample with the issue present and a screenshot of your scene and game views?
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

Re: Depth Fade to Object's Own Backfaces

Postby Bitcoon » Thu Jul 26, 2018 5:31 pm

Thanks for your prompt reply!

I hadn't noticed the walls behind the object. I thought it was using its own backfaces for its depth calculations but I suppose it is the walls and floor causing it to render that way. I guess I already had the settings, but I can't always put solid walls behind my gravity fields to get this effect.

Is there a way to get the depth of the object itself, like the distance from the front faces to the backfaces? Perhaps using multiple passes or another method? I guess what I'm looking for is a 'volumetric' effect but I'm not sure where to start if depth fade doesn't do the trick. So close!
Bitcoon
 
Posts: 5
Joined: Thu May 24, 2018 10:19 pm

Re: Depth Fade to Object's Own Backfaces

Postby Amplify_Borba » Fri Jul 27, 2018 2:24 pm

It always depends on the type of effect you wish to create, but it's likely that you'll require additional scripting, which unfortunately is beyond the scope of our editor.

Honestly, I'm not quite sure on what to suggest, but you might find additional information in this thread and this article.
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

Re: Depth Fade to Object's Own Backfaces

Postby Bitcoon » Sat Jul 28, 2018 7:37 am

I'm still getting my footing with the concepts possible in Amplify, but this looks like it could be a much more expensive and difficult effect to pull off than I hoped. I've tried going down the rabbit hole with what you linked but so far, no dice. I may have to eventually give up on this one and come back later with more shader experience under my belt, as I'm still learning. But nevertheless if I'm learning anyway, it helps to keep cracking at this until I can figure something out.

Seems like the most straightforward option (as seen in this thread here https://forum.unity.com/threads/renderi ... er.355235/ ) would require multiple passes. I guess it's time to take a crack at shader templates, then.
Bitcoon
 
Posts: 5
Joined: Thu May 24, 2018 10:19 pm

Re: Depth Fade to Object's Own Backfaces

Postby Amplify_Borba » Mon Jul 30, 2018 9:02 am

It does seem that multi-pass might be necessary to achieve this effect since they do mention the use of at least 2 passes, however, do note that he also seems to be using multiple cameras.

Please let us know if you have any further questions, thanks!
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

Re: Depth Fade to Object's Own Backfaces

Postby Bitcoon » Tue Jul 31, 2018 5:17 am

Thanks for all your help so far. I keep getting close but I just can't wrap my head around this one thing now.

I think I have the 'on paper' idea figured out, but the specifics just seem to break my brain. Perhaps you can help me piece together how to do this.

Here's the basic outline of what I think should work:

-Rendering in transparent queue, so I can use additive effect.
-The shader renders the front faces - just their depth needed this pass.
-Pretty straightforward, I think - probably Surface Depth, Camera Depth Fade... something like that.
-Now I need this pass to output in some way the next pass can make use of... some kind of render to texture? I don't think I actually want it to render on-screen, I just want to use the data from here while rendering on the backfaces. Really I just need to send along the results of the node I use in this pass so the next pass can make use of it.

-In another pass, I render the backfaces.
-Using the same method, get the depth of the backfaces.
-Subtract front face depth from backface depth and get "volume"
-From there it's possible to apply whatever textures, effects, etc I want.

I feel like it's really, really simple, but I don't know how to get to the desired result. Seems like there should be a way to get a shader pass to output to a render texture and then use that in the next pass, but it's all a bit over my head.
Bitcoon
 
Posts: 5
Joined: Thu May 24, 2018 10:19 pm

Re: Depth Fade to Object's Own Backfaces

Postby Amplify_Borba » Tue Jul 31, 2018 10:22 am

Could you share with us what you've built so far and what issues did you find specifically? We might be able to point you in the right direction.
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

Re: Depth Fade to Object's Own Backfaces

Postby Bitcoon » Sun Aug 05, 2018 6:13 am

After a while deliberating and trying different things, I think the best solution might be to go with the relatively cheaper method of a single pass using depth to backfaces. All the trouble of adding another pass could hurt performance too much.

Honestly, it's doing a decent job simulating the effect, though I don't really like how more distant objects will have the full (clamped) brightness due to being so far from the camera. Ultimately it's the best version of this effect I've gotten so far with only one small downside, so it's a start:
https://www.dropbox.com/s/ntk1ooal9huk9 ... 7.png?dl=0

But I also feel like I'm using that as an excuse, because I absolutely can't figure out multi-pass for some reason. Just trying to get a multi-pass shader to work in the first place has been a non-starter for me. I try taking a functional shader and adding a Pass{ } around the subshader contents with hopes that I can copy-paste that Pass and edit how the second pass works, and that refused to compile even with just the one Pass. I try the legacy multi-pass shader in ASE and can't figure out how to use the other pass at all. I tried duplicating the object on top of iteself and using identical shaders that render depth additively and multiplicatively (come to think of it, subtractive is what I should have gone for but that wasn't an option I saw), one with front faces culled and the other backface culled. Still the effect doesn't even start to look right.

Here's the idea of what I want to do: Create a multi-pass ASE shader where the first pass doesn't render to the screen, instead rendering to a texture the second pass can grab and use. Is that possible? Really all I want to do with it is render the Camera Depth Fade effect on front faces, and pass that result on to the 'final' render pass that culls front faces and renders the back. Creating an ASE shader (or any functional shader at all) has been a real challenge for me, and it's a bit unfortunate that I find myself feeling like I need to buckle down and seriously learn my way around shaders before I'm even fully familiarized with the ASE toolset.
Bitcoon
 
Posts: 5
Joined: Thu May 24, 2018 10:19 pm

Re: Depth Fade to Object's Own Backfaces

Postby Amplify_Borba » Mon Aug 06, 2018 2:27 pm

Although you don't need to be an expert shader developer, there are some concepts that you must know in order to create your own shaders, as ASE only provides the toolds to build them.

Did you have particular issues with our Shader Templates and Multi-Pass documentation? Any feedback regarding our samples and documentation is welcome as it will help us improve upon what we currently offer.

In any case, we'll do our best to guide you in regards to Multi-Pass, I'll be passing this topic to our developer as he should be able to provide further insight regarding your questions better than anyone.
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 General Discussion

Who is online

Users browsing this forum: Google [Bot] and 2 guests