Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Help with global illumination removing my cel shaded effect

Discussion in 'Shaders' started by supersulu, Aug 6, 2020.

  1. supersulu

    supersulu

    Joined:
    Feb 7, 2019
    Posts:
    6
    So I am using this toon shader I got from the asset store that supports global illumination. However it seems like the global illumination destroys the cell shaded effect, and when in shadow it looks no different from the standard shader. Could anyone who is knowledgeable about shaders weigh in on what I could do in this situation? Thanks so much!
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Unity's ambient lighting system is inherently designed around Lambertian directional ambient lighting. If you're using the built in baked lighting via light probes, or even default ambient light based off of the skybox, it's going to be directional data it's passing to the shader. There's no real way around that apart from implementing your own system from scratch.

    The "fix" is in the shader ignore the surface normals when calculating the ambient light. This can take several forms. You could always sample the ambient light from "up", though that won't work if you want the character's lighting to be affected by bounced light from the ground or walls. You could use the view direction, but that has similar issues.

    The "best" option is to sample the ambient light from multiple directions and add them together or average the results. Could do up & down, or the 6 axes, or 4 (one up, three down in a triangle, like the points of a tetrahedron). Depending on how that asset works, that can be really easy to implement, or really, really hard.
     
    echu33 and supersulu like this.