Broxxar / GlowingObjectOutlines

A technique for Glowing Object Outlines in Unity.
The Unlicense
161 stars 50 forks source link

Occlusion for outline glow #3

Closed akulahalfi closed 6 years ago

akulahalfi commented 6 years ago

How do we achieve the occlusion of the outline if an object is in front of the outlined one?

akulahalfi commented 6 years ago

I sent an email to @Broxxar and this is his response:

Hi Alfie,

I've been a bit busy this week so I haven't had time to reply to your issue!

To do this, you'd have to draw the non-glowing objects as occluders in solid black to the glow buffer. If this would mean for your scene that you are effectively redrawing the scene twice, than this might actually be a good case to use Multiple Render Targets. MRTs are like having more than render texture bound and you have to output fragment colors to all the targets you have bound in your shaders. This is a bit like writing your own lightweight Deferred renderer, except that you'll do regular forward rendering into on target, and just use the other target to store emissive/glow values.

The documentation on MRT in Unity is a bit lacking but it's absolutely possible. MRT would actually be a great video I could do in the near future so thanks for turning my attention towards that idea!

Hope this gets you pointed in the direction.

Cheers, Dan

I tried his suggestion and it worked perfectly. Thank you Daniel :)

qq995002966 commented 5 years ago

hi ~ @akulahalfi Could you share your outline shader with occlusion? I'm a newbee for shader program. I have tried my best to program one. And this is my email jiangjinhao@vip.qq.com