+3
Under review

vertex offset depth buffer

vincent 11 years ago updated by Matthew DeLucas 7 years ago 18
I created and opaque shader that uses vertex offset. I use this for a coral polyps plant. So the polyps move around. 
The problem is with the image effects. Effects like DOF do not take the vertex movement in account.
This causes that the DOF shows the default outline of the model. So the 'outline' is not moving with the vertices.Image 206 
I'm having this exact issue right now and it's really a pain. Not sure how to get around it.
Under review
Does this happen in 5.0 as well?
I'm not sure. I'm still using 4.6.2.
I believe this isn't an issue anymore in Unity 5, though you may not be able to check

Darn it! Having the same problem and we're still on Unity 4. We're going to switch on the next project.

No one managed to get this to work on Unity 4?

+1

There's a long and silly reason as for why this is a problem.

The short answer is that Unity renders depth separately for each shader, by reading a special shader file that has a bunch of tags in them. Based on which tag your shader has, it will use one of those to render depth. So what you need to do, is to download Unity's builtin shaders, find the shader with the depth passes (I forgot the name of it), and then add your own shader to it by hand, rendering only depth, and make sure that the tags match, so that it will use that shader for depth rendering. You'll have to do this for every shader that has custom depth behavior, which is a bit of a mess

Love you Joachim! I think I can handle that, great!

Is this something that you think will be solved in a later release of Shaderforge?


If not, would you mind sharing up a little more info on the solution? I'm not completely clear on what you mean.


Thanks!

It's rather involved, and I don't remember the whole process myself! This shouldn't be an issue in Unity 5 though, is it?

+1

nope not for Unity 5

+1

Using Unity 5.22 here.

I believe this is what my problem is. We use vertex offset to handle a lot of swaying materials, like grass or leaves.


The problem is that the depth buffer for these objects don't seem to line up with the offset, visible material. In some cases, the visible material will flicker between the offset and non-offset version.


You can see here a simple offset opaque material that the test Ambient Occlusion is not following the material, though the shadow caster is.


Further, here's an example that the AO is moving completely offset from the visible material.


This has been hindering my project for months now, if there is a lead I can follow, I would be quite happy to pursue it. Thank you.

Did you ever find a solution to this?  I'm using Unity 5.6.2f1 and having the same issue now myself.

More on this issue:


You can see here the shadow caster(?) moving in a desynced manner from the visible pass.


When the angle of view changes, the visible pass appears to twitch between the shadow caster location and the actual location.

Interesting. Toggling Receive Shadows removes the twitching. (But the shadows are still wrong)

+1

After hours or research into this, I can confidently say that this is a problem with dynamic batching and not shaderforge.


Now if I could just find a way to disable dynamic batching on the shadowcaster, I'd be in business.

Can you disable dynamic batching for just the shader? https://twitter.com/andyman404/status/614176222222880769

I can, yes.... well not quite.

Activating it does keep the visible pass from twitching about, but it seems to have no effect on the shadowcaster pass regardless of toggle.