Home Unity

Decal clip shader

polycounter lvl 19
Offline / Send Message
MikeF polycounter lvl 19
Hey guys,

I'm trying to figure out a solution to properly render decals applied to a surface while avoiding any overhang (see attachment)

Basically a simple plane is grabbed from a pool, moved to the proper position in world space, then the blood splat material is applied. This works well enough but if the decal is applied on the edge of any geometry you get this super noticeable overhang.

I had an idea to create a shader that would only render at locations where another surface is behind the decal, but i'm not quite sure how to go about something like this.

I would just use projectors but they're a huge hit on performance so i'm after something shader based ideally.

Any ideas?

Replies

  • SlyRipper
    Options
    Offline / Send Message
    SlyRipper polycounter lvl 6
    You could try projectors, you can set them up to just show the image within a distance as i remember, and they only work on geometry. so try those, for example the basic blob projector and replace the image with yours, maybe that works? :) at least it will be the way with lowest effort.
  • MikeF
    Options
    Offline / Send Message
    MikeF polycounter lvl 19
    Heheheh yeah i'd love to use projectors but the performance hit and general buggyness makes that one a no go. Thanks though!
  • Brendan
    Options
    Offline / Send Message
    Brendan polycounter lvl 8
    What you want is basically a depth difference shader.

    If you use ShaderForge or Strumpy's I think they both have it (maybe). Basically, you want to check that the depth of the decal and the scene depth (of solid objects only) are within a small range (indicating they are close).

    If you can't find the node (or it isn't there) or if you want to write it by hand, look for the Soft Edge Particle shader. It blends alpha when the particle intersects with things - you basically want to do the opposite!
  • MikeF
    Options
    Offline / Send Message
    MikeF polycounter lvl 19
    Ah Excellent idea Brendan! thanks a lot i'll look into this
Sign In or Register to comment.