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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Realtime shadows and lightmapped surfaces

Discussion in 'Shaders' started by NathanFuentes, Feb 16, 2023.

  1. NathanFuentes

    NathanFuentes

    Joined:
    Nov 5, 2018
    Posts:
    9
    I have the following problem. I'm trying to give the player a shadow (not just a proyector with a blurry shadow) but a real shadow generated by a directional Realtime light.
    The problem is that as all the surfaces are already lightmapped, if I add this light, they all look washed out, but the shadows works as expected. If I darken this light the lightmapped surface looks good but again no shadow.
    Is there any option to cast only a shadow that don't add light to the surfaces.
    Currently what I'm trying to do via shaders (in shadergraph) is to get the main light (sun light) that is black color so don't affect the ightmapped surfaces, and get the shadow and that apply it darkening the emission color.
    (taking as a base:
    https://blog.unity.com/technology/custom-lighting-in-shader-graph-expanding-your-graphs-in-2019)
    So far it hasn't worked, but still trying.
    Anybody has any other idea of how to achieve this? I'm really open to suggestions
    Thanks
     
  2. NathanFuentes

    NathanFuentes

    Joined:
    Nov 5, 2018
    Posts:
    9
    Ok It worked with the approach I mention earlier:
    upload_2023-2-16_15-3-37.png