Search Unity

Question Geometry shader not receiving shadows

Discussion in 'Shaders' started by grybas, Jan 10, 2021.

  1. grybas

    grybas

    Joined:
    Apr 8, 2013
    Posts:
    5
    Hello, I am trying to simulate directional (sun) shadows in top down 2D game. So far I have managed to use geometry shader to extrude sprites and cast shadow, but I can't find a way for the extruded sprites to receive shadows. I am not good at writing shaders, googled some solutions, but all of them produce pink shader, I think some shaders are not compatible with URP?. Can someone help?

    Also is it possible to write such shader with Shader Graph? That way it would be much easier for me to edit shader

    P.S. I am using Universal Render Pipeline.
    upload_2021-1-10_12-58-3.png
    Extrude shader https://pastebin.com/sErBwa0E
    Shader demonstration
     
    Last edited: Jan 10, 2021
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Shader Graph is not capable of using geometry shaders. Nor is it likely that Unity will adding support for them.

    URP uses completely different shaders than the built in renderer (though they made it so unlit shaders mostly just work). You cannot use lit shaders created for the built in forward rendering with the URP. You may be better off not using geometry shaders, and instead use cube meshes set to shadow only.