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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Toon shader and Ambient Occlusion

Discussion in 'Shaders' started by Burton-kun, Jun 16, 2016.

  1. Burton-kun

    Burton-kun

    Joined:
    Aug 6, 2015
    Posts:
    50
    Hello everybody, as you can understand by the title, I need some informations about these two graphic settings.
    What I'm trying to achieve is a toony effect on my game. The result I got with the Toon shader from Unity standard asset is exactly what I was looking for, with outlines and everything.
    The problem is that i need to keep a certain depth and i thought that ambient occlusion would have solved my problem.
    I applied the script to the main camera (ambient occlusion from standard asset as well) but there's no shadows. I'm working on a top-down RPG, and the only result I got is the objects' sides to be darker.
    Also, my recent experiece took me to understand that toon shader and alpha channel are not very friends, I can't give trasparency to a texture without hide what is behind and are clear to me the reasons but really there's no way to achieve these effects?
    I leave here some screenshots of games that show the effect I would like to achieve:



    Notice the shadows and the darker area on the ground close to the walls, in the corners, under the roofs. This is what I'd like to achieve.
    I'm still not able to write a shader 'cause is not something you learn from a day to another, but what i want to know is: Is there a shader or an effect i can find somewhere to get this result or someone has some tips to reach my goal?
    This is how my test looks like at the moment:
    example.PNG
    Thanks for the attention.
     
    Last edited: Jun 16, 2016
  2. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,469
    standard asset -> post effect -> edge detection
     
  3. Burton-kun

    Burton-kun

    Joined:
    Aug 6, 2015
    Posts:
    50
    You misunderstood, I wasn't asking for outlines, I asked for dark shades, shadows and scene depth in corners, close to walls and similiar. Something that don't happens on my screen.


    Something compatible with toon shader.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,248
    It's not an issue of making something compatible with the toon shader, but likely rather the opposite. I don't know of the top of my head why the toon shader wouldn't work with the included AO image effect though.

    Also it should be pointed out that the images you posted don't use an image effect, they're doing AO by coloring the mesh vertices, likely manually. That will likely require a minority customized shader though too as I don't remember if the toon shader uses vertex colors.
     
  5. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    121


    It will look like this toon shading and ambient occlusion
    but I don't know how to do this in code I get this image pdb molecular visualiser
    from here http://www.rcsb.org/