Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question Help understanding how decals work

Discussion in 'General Graphics' started by MMeyers23, Jun 27, 2020.

  1. MMeyers23


    Dec 29, 2019
    I am working on a post processing effect that will (hopefully) map a texture onto ground surface like a projector or a decal would. So far it only works in one plane (xz) and stretching in other directions.

    I retrieve world space coordinate of pixels via depth texture. I have basically worked out how to get world normals of a scene as well (it is acting a little odd, I think due to how I am feeding my matrix into my shader) :

    I assume decal shaders combine world position and world normals somehow, if this is the case could someone help me understand how exactly to combine the two to make my texture project correctly across surfaces like a decal shader would? Ideally, I would also like to be able to change the projection angle to mimic the main directional light.

    I am using post processing stack v2 in URP, so I have to use hlsl includes, not cginc. Thanks for any insight!