Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Scriptable renderer feature drawing on top of unaffected objects

Discussion in 'Shaders' started by ChichoRD, Sep 14, 2021.

  1. ChichoRD


    Jul 31, 2020
    I'm developing a 3d game and decided to give it a low poly look. For that, I searched on the internet for what it's called a screen space curvature render feature and found the one I'm trying to fix (I attached the files, they were developed and distributted by @MalyaWka in this thread Voxel Edge Smooth Effect - Unity Forum).

    (Desired look)

    The pass is quite customizable, however one feature does not work as I pretended, the layerMask: In the DepthNormalsPass.cs file you can see it being used in the constructor of the FilteringSettings (line 97) used in the DrawRenderers method after it. So that pass gets the normals that are gonna be used then to draw the effect I'm looking for.
    However when you exclude a layer from the pass, instead of not drawing the effect in areas covered by objects in other layers, it just draws the cavities and the valleys over them:


    (Red box (the player that is in a non included layer because I don't wanna give him the effect) has the effects of the geometry behing rendered over it (Not the whole mesh, just the valleys and cavities, the player is not transparent))

    Any idea of how to fix that?

    I tried to implement a texture subtraction, with the intention of passing the whole screen render texture to the shaders that work behind (not included shaders in the message because they are fine), then passing the render texture of only the excluded layers (but did not figure out how to mask the screen render texture based on layermasks) and then subtracting them in oreder to only draw the effects over objects witthin the layers

    The only thing that "works" is setting the player material render queue to over LastGeometry (> 2500), so it renders in an order as it were a transparent (it is not).

    Should you have any solution or idea, please tell me, and really thank you for reading my message

    Attached Files: