Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Giving shadows a texture

Discussion in 'Shader Graph' started by Firgof, Jun 13, 2021.

  1. Firgof

    Firgof

    Joined:
    Mar 7, 2013
    Posts:
    26
    As title, I'm trying to build a shader graph network which takes a texture and applies it to shadows cast in the scene but I'm very new to both shader construction and the shader pipeline. The idea is to ultimately make the shadows look 'feathered' or 'painted' rather than just their normal soft/hard edge.

    Visually, it looks like the shader should output the results I'm wanting from the Material Preview -- but in-scene and in-game the effect I built isn't being shown. Is this a shader graph error or a project settings error?

    Only thing I can figure is somehow Unity is overriding my shadows at some later step (or I'm using the wrong keywords?). This is an Unlit-type shader though and I'm grabbing all the lighting information manually.

    Any help (even and including suggestions of better approaches to solve the problem) would or advice would be appreciated.This is a Unity 2020.3.11f1 LTS project running with the URP v10.5.0 pipeline.

    Screenshots:
    (A) Top Layer of Shader Graph

    (B) Zoom-in on CalculateLights Subgraph (top-route mutates the cast shadows, bottom route is the normal shadows which are then pushed up some to allow that top route to be blended in)

    (C) Material set-up and preview in Inspector (matches intent, though it's being applied to UVs rather than screen-space but I've yet to learn how to make that happen)

    (D) In-game and Scene View, showing normal shadows rather than the modified shadows
     
  2. Peter-Bailey

    Peter-Bailey

    Joined:
    Oct 12, 2012
    Posts:
    35
    I've been developing a shader that does just that. It's a lit graph though, but as long as you're getting shadows it should work. Just use a blend node set to overlay or soft light and blend the shadow attenuation with a texture. If you want the texture in screen space, plug a screen position node into the uv of your texture.
     
    Firgof likes this.