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

Wind Waker type of toon shading

Discussion in 'Shaders' started by Samantha, Jun 20, 2006.

  1. Samantha

    Samantha

    Joined:
    Aug 31, 2005
    Posts:
    609
    I'm working on a cartoon-ish project, and I want to achieve a certain look using shaders, but I'm WAY over my head when it comes to shaders. Therefore, I'm looking for some help :)

    The problem I'm having with the Toon-Basic shader, is that the cubemap warps around the mesh according to the camera's postion. Then, the Toon-Lighted shader doesn't warp the cubemap at all. What I would like to do is either warp the cubemap according to light positions, sort of like this picture from Wind Waker.

    I've looked over the included shaders but still don't know where to start. If someone can give me some help, I'd be greatly appreciative.
     

    Attached Files:

  2. greenland

    greenland

    Joined:
    Oct 22, 2005
    Posts:
    205
    I am also interested in something like this. It seems just like there is a 50% threshhold instead of actual... like... shading. I'm sure it can't have much overhead cost and it would be fairly easy to do... but I have no idea how to do it... or how to start.
     
  3. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    I don't know the nitty gritty of writing pixel-shaders but the theory is fairly straightforward, and you've essentially written the algorithm in your post:

    given the lighting strength (which I believe you get given), if it's above some threshold, return the color map value, otherwise, return some fraction of the color map value.

    If I understand correctly, you can only add custom shaders with a pro license though.

    It seems like you should be able to tune one of the existing toon shaders to deliver this result though.
     
  4. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    Not at all, you get ShaderLab with both. It's clear here: https://secure.otee.dk/shop/
     
  5. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    Oh so it is :)

    Regardless, it should be possible to use an existing toon shader to get this effect.
     
  6. Samantha

    Samantha

    Joined:
    Aug 31, 2005
    Posts:
    609
    Actually, you don't need Pro to write custom shaders. Pro users get: Windows Publishing, Full-screen image effects, and Render to Texture. People seem to have a lot of misconceptions about what you can't do with Indie, but Indie users really get 95% of Unity's functionality.

    As far as looking at the other shaders, I've looked at the differences between the lit and non-lit toon shaders, and they both seem somewhat over my head. In looking at the Toon-Lighted shader behavior, it doesn't seem to show direction of light like the diffuse shader does. Mostly, it just makes the entire mesh a little brighter as light gets closer to it. I had some fun with the spotlight and the toon-lighted shader, actually.
     
  7. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Well, warping the lighting when camera moves is not correct in a physical sense (diffuse lighting does not change when camera moves), but yes it's done often and looks better.

    Can't you get the same effect by just adding a light that is parented to the camera and always illuminates the view at the constant angle?
     
  8. Samantha

    Samantha

    Joined:
    Aug 31, 2005
    Posts:
    609
    So this looks like a user error. Unity is already capable of this, but I wasn't using it correctly. For my experiments, I had been using a light that was set to Force Vertex, so I was getting all sorts of weird behaviors. But after setting the light to Force Pixel, I noticed that the Toon-Lighted shader DOES wrap the cubemap based on a directional light.

    From there, it was just a matter of making a light map to convert to a cubemap, and voila!
     

    Attached Files:

  9. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,223
    Thanks--I've been having fun today modifying the cubemaps in the standard toon package. I've been trying color variations and noise to make an "imperfectly inked" look and it's not bad.

    For some reason I can't seem to get any outlines, but I'll keep playing.

    I take it that hardware that doesn't support cubemaps will simply fail gracefully and show the solid color?
     
  10. llavigne

    llavigne

    Joined:
    Dec 27, 2007
    Posts:
    977
    Is this a shadow or a clever trick ?
    And this normal grub, did you figure out how to smooth it out ? My very much lores objects are showing the same artifacts, baking normal map from higher res might work but I'd have to UV the bugger.
     

    Attached Files:

  11. Samantha

    Samantha

    Joined:
    Aug 31, 2005
    Posts:
    609
    Wow, that's an ooooold version of the Neko. The attached image shows how the cubemaps look with the current version of the object.

    The shadow isn't a real shadow or a clever trick, it's simply the way the cubemap toon shading looks based on the curved surface of the face.

    The "grubs" you're talking about, which I assume you mean the graphical artifacts... those were being caused by the compression of the cubemap texture. If you turn off compression of your cubemap texture in the its import settings, it should look a lot cleaner for you.

    There are still a few artifacts because of the mesh density, but the camera never really gets this close in the real game so it's acceptable to me as the designer.
     

    Attached Files:

  12. llavigne

    llavigne

    Joined:
    Dec 27, 2007
    Posts:
    977
    Awesome look!

    Can you multiply that with baked vertex color ?
    Or multiply it with another cubemap ?
     
  13. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Yes. The built-in Toon shaders do this look; but you can change them to multiply with vertex colors, with another cubemap, or whatever you like.
     
  14. AGhost

    AGhost

    Joined:
    Apr 13, 2006
    Posts:
    90
    Is it the toon shader that provided the dark outlines, the cubemap or your model/texture?

    AGhost
     
  15. llavigne

    llavigne

    Joined:
    Dec 27, 2007
    Posts:
    977
    I know everything is possible but since pass is only additive I think it's more involved than just copy and paste... example would help
     
  16. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Then say what exactly do you want :)

    1) Multiply per-vertex color with the one produced by the current toon shader?
    2) Add additional cubemap? Or Multiply with additional cubemap? Something else?
    3) The additional cubemap - for what it would be used? Simulate reflection? Simulate lighting? Something else?
    4) Some combination of the three points above?
     
  17. llavigne

    llavigne

    Joined:
    Dec 27, 2007
    Posts:
    977
    I want peace in the world.

    In the meantime I'll settle for 4) - the combination of the three points above :)
     
  18. G[3z]

    G[3z]

    Joined:
    Apr 9, 2008
    Posts:
    46
  19. SrBilyon

    SrBilyon

    Joined:
    Jul 13, 2010
    Posts:
    291
    DO you have this version of the shader still? This looks awesome! I hope I didn't just bring this post back from the dead! :D
     
  20. hizral

    hizral

    Joined:
    Apr 27, 2010
    Posts:
    568
    I would like to ask about the "Force Vertex" and "Force Pixel" ..where do you change the setting??

    I used Unity3
     
    Last edited: Oct 21, 2010