Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Custom shader for unlit wall to receive uniform shadow without gradients?

Discussion in 'Shaders' started by nicmarxp, Jul 11, 2019.

  1. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    297
    I'm testing my 2D game in a 3D environment, to make use of lighting and colliders, similar to how Enter the gungeon was made.

    In the pictures below, I have a cube (fridge) and an orthographic camera angled down 22 degrees, and a point light to the right.

    We hand draw textures that have shadows, but we want some objects to cast shadows on floors and walls. However, I want to avoid any gradients, and only have either 100% the original unlit color, or a shadow, for example 30% black.

    I made an illustration of three images:
    1) Unlit shader, here it doesn't receive any shadows, it's 100% unlit
    2) Standard shader, it receives shadows correctly, but the wall is gradiently coloured depending on the position of the light
    3) Custom shader (Faked in photoshop) what I want it to look like.

    Also I'd like the same material (the fridge) to react to light, but only "all or nothing", so if there is a blue light for example, the entire fridge is tinted blue, without any gradients. But I guess this might be a different part of the shader?

    Thanks for any ideas!

     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,808
  3. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    297
    Thanks! We are currently going back to fully 2D to cut down on development time, we'll see if this gets useful later.. :)
     
unityunity