Search Unity

Can I project a normal map onto a wall?

Discussion in 'General Graphics' started by Reverend-Speed, Jul 8, 2019.

  1. Reverend-Speed

    Reverend-Speed

    Joined:
    Mar 28, 2011
    Posts:
    284
    Hey there. I'm looking to project a normal map onto a wall, so that I can move the image of the object (a stereo jack) across multiple surfaces, making it appear that the object is moving beneath the deforming surface.

    * I've done a little research with Projectors (from here), but I'm unsure of how to get that shader to work with normal maps, or integrate with the Standard Shader.

    * I've also looked into cookies for Spot lights, but these don't seem to be able to use normal maps.

    * I've found a Decal Projector Component, but there doesn't seem to be any documentation for it.

    Can anybody suggest a way to project normal maps onto surfaces? I'm ready with maps...!
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Legacy projectors aren't compatible with any kind of built in lighting systems. So no, they cannot do normal maps.

    Spot light cookies modify the color of the light being projected, but cannot modify the angle of the lighting like normal maps do.

    Decal projectors are a feature of the new High Definition Render Pipeline, and do support normal maps. But it requires you use the HDRP and not a built in render path.
    https://github.com/Unity-Technologies/ScriptableRenderPipeline/wiki/Decal-Projector


    To do this with the forward rendering path would require using custom shaders in which you're passing the decal's texture and transform matrix to the objects' materials. This is possible if you've got only a small handful of objects on screen, and very limited number of decals, but does require you know how to write shaders.

    To do this with the deferred rendering path requires some form of deferred decals. There are several assets on the store to do this, as well as free examples posted elsewhere (including by Unity).
    https://www.google.com/search?q=unity+deferred+decals
     
  3. Reverend-Speed

    Reverend-Speed

    Joined:
    Mar 28, 2011
    Posts:
    284
    Thanks so much, @bgolus ! Ideally there should be very few objects in this environment - it's mostly an organic tunnel with objects pushing out through the membrane of the wall, then receding. A few of the smaller objects will need to travel across the walls, which is where I started thinking about Normal Maps and projectors...
    Here's an example of the visuals... (obviously an early test).

    We are using HDRP, but I'm still not 100% certain that the Decals are our solution, as they need to traverse across the skin of the tunnel (maaaan, projectors would have been a huge help there).

    I'm a moderately experience Unity dev, but without much experience writing shaders. I'm ready to give it a go - but any advice would be appreciated.

    Time to do some reading...
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    If you're using the HDRP already, then Decal Projectors are what you want. They are the same thing as deferred decals, and have most of the benefits of legacy projectors with much lower cost and greater flexibility.