Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. 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

Official Toon Shader

Discussion in 'Open Projects' started by Cibbi, Oct 1, 2020.

  1. Cibbi

    Cibbi

    Joined:
    Nov 22, 2017
    Posts:
    5
    Hi, i'm looking at the current implementation of the toon shader given in the project to see if i can add my own contribution to it.

    Seems a nice time to actually learn a bit more about shading in urp since i've been mostly on the legacy pipeline until now.

    RIght now i'm fiddling with the main toon gradient sampling and i got a couple of questions:
    1) About the gradient itself: is there a particular reason to keep it an internal structure instead of having a texture containing a gradient to sample? The latter would give way more freedom to the artists to edit them.
    2) Is there a general limit on how much should be done inside a single custom function?
     
  2. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    I actually left the Toon Shader a bit half baked, I was going to go back to it. Let me push a few changes tomorrow, and we can resume the conversation?

    In any case:
    You're totally right, although I don't know if different toon materials should have different gradients

    I don't think so because, at the end of the day, either you write it yourself or you use multiple nodes to make it, the resulting HLSL code is the same (or, almost).
     
  3. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    I also made the thread the official discussion thread about Toon Shader (roadmap card)
     
  4. Cibbi

    Cibbi

    Joined:
    Nov 22, 2017
    Posts:
    5
    Up until now i just played a bit with it without making important progress, since i have to understand where things are compared to legacy, i'll wait the updates before doing anything important to it.
     
  5. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    5,570
    Keeping a tab on this,

    Although I don't see the need for gradient given the concept art style full of harsh colour transition.

    But if it was me I would probably ditch toon shading for a vertex color shader with split baked shadow vertex and distance illumination of light, aka no ndotl compute, and post process line art extracted with normal depth and a color channel as a mask. That would allow a one to one replication of the illustrative style of the concept art instead of the usual sad sorry and sloppy toon shader we see people defaulting to. But it out the burden on modelling to work on keeping the dynamic shape of the illustration. Its probably not on the skill level of the artists though

    If you go toon shader at least take cues from the Japanese unite talks about unity Chan or the English talk of miyoho at unite Korea about honkai impact. Just because it's anime don't mean the lesson aren't universal. And since they already solved major hurdle you won't have to reinvent the wheel and per time chasing solutions.
     
    daneobyrd and polemical like this.
  6. Cibbi

    Cibbi

    Joined:
    Nov 22, 2017
    Posts:
    5
    The idea for a gradient in this case is to let artists author different types of harsh transitions easily. The fact that it could theoretically support smoother transitions as well is more of a side effect rather than the intention. We could predefine a finite amount of hardcoded transitions, but i personally prefer the flexibility of editing a gradient for that.

    It would be nice to try, but it would make artists job harder, and make harder later down the line to make changes and adjustments to the style as needed.
     
  7. Cibbi

    Cibbi

    Joined:
    Nov 22, 2017
    Posts:
    5
    Since i haven't seen any updates on the shading branch of the repo i went on and started building up a separate shader as a test.

    Currently supported:
    • Main light Diffuse and Specular highlight
    • Additional Lights Diffuse and Specular highlight
    • Shadows
    To do:
    • Baked GI
    • Ambient color
    Current Issues:
    • High intensity lights tend to blow up the character a bit too much, but that may be due to missing post processing in the test scene. Needs more testing.

    The shader uses 2 separate gradient textures for diffuse and specular, so that the artist can tweak each one separately.

    Shadow attenuation is also being kept into consideration while sampling the gradients, so casted shadows will behave accordingly to the gradient as well instead of being an effect on top. Unity_Gf6YI4xoW6.png
    Unity_THDq4sKw8p.png
     
  8. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    191
    It better use gradient texture created by script so it's easy to control
     
  9. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    It's been only 2 days since I last posted, and it's the weekend :(

    Looks good! Is it coded or Shader Graph?
     
    mottz94 likes this.
  10. Cibbi

    Cibbi

    Joined:
    Nov 22, 2017
    Posts:
    5
    Ahahahahah sorry, it's just that I only have the weekends free to dedicate time on that.

    It's shader graph with the main lighting functions being coded in an hlsl file and used in custom function nodes.
     
  11. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
  12. Smurjo

    Smurjo

    Joined:
    Dec 25, 2019
    Posts:
    84
    Are there specific requirements to the UVs resulting from the toon shader? When making the 3D models, we need to know. I am specifically thinking about
    - no overlapping UV (the same spot on the texture used twice or more)?
    - not wrapping texture around sharp edges, instead making separate island with xxx pixels inbetween?
     
  13. dylannorth

    dylannorth

    Joined:
    Dec 26, 2015
    Posts:
    4
    2020-11-08 20 42 15.png
    2020-11-08 20 42 03.png
    Hi great work on the toon shader so far! I am having a problem with the latest change which separated the toon shader into sub-graphs. The top screenshot is the toon shader when it was all contained within a single shadergraph applied to the ground while the second screenshot is with the latest shader.
    As you can see, now that it's been split into subgraphs objects no longer cast real time shadows onto each other. I tried to investigate all the subgraphs to find any differences in implementation but I couldn't spot anything changed that would make the difference. Any ideas?
     
  14. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    I think I found the issue!
    Both the Toon and ToonPlusWind shaders don't have the keywords related to lighting. They were lost in the merge, which is very strange since you can see the shader with the wind just before your post, in @treivize's post.
    Interesting.

    Screenshot 2020-11-09 at 15.45.17.png

    I'll add them back and see if it fixes it.
     
    Amel-Unity likes this.
  15. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    Yes, fixed (and pushed to the art-assets branch).

    Screenshot 2020-11-09 at 16.02.19.png
     
    dylannorth, treivize and Amel-Unity like this.
  16. treivize

    treivize

    Joined:
    Jan 27, 2016
    Posts:
    71
    wow! I was trying to figure out the problem too right now. Indeed, I had the impression it was working when I opened the PR. About the keywords, I am not sure how they work, but maybe they are not propagated over two sub graph level...
    Because for sure, if the Toon shader is defined like done in ToonShading sub graph, shadows are cast without having to specify the keywords again.

    A ticket to raise to Unity Shader Graph team maybe ;)
     
  17. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    In the latest commit, they were not there at all. Not in the top-level graph.
    Somewhere along the way, the two ShaderGraph files lost all keywords, not sure how. So it was "working as intended", but we should try to understand for the future how we lost them (if it was my mistake, or indeed a bug). Let's just keep an eye out if we happen to subgraph things again.
     
  18. treivize

    treivize

    Joined:
    Jan 27, 2016
    Posts:
    71
    Hi shader lovers,

    I am thinking about the task "Emission support", how do you imagine it will work with the constraint of the project (URP + Unlit shaders)?

    The solutions I can figure out are:
    - Add extra mesh placed over the glowing area and the area around with transparent additive color shader
    - Add an image effect shader over the camera frustum to post effect the image with glow effect.

    Do I miss something here? What should be the most appropriated solution according to you?
     
  19. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    191
    "Emission support" means HDR map, not glow effect itself.
    Extra mesh is not a good idea for this, especially with skinned meshes.

    And I think we need custom paintish post effects for Bloom and DoF.
     
  20. treivize

    treivize

    Joined:
    Jan 27, 2016
    Posts:
    71
    Ok, thanks for your feedback Neonage, so it is what I had in mind with my second option. Ok I will have a look how to go with this option then :)

    Sorry another thing I wanted to share with you before going to sleep. Transparency support, I did some tests with the lantern and a suggestion will be to split the geometry into two part, the glass and the metallic caps to apply a dedicated shader to the glass:

    transparent_support_1.gif
     
    Neonage likes this.
  21. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    191
    And I'm playing around with Strokes map:

    strokes_map_1.gif
    (don't mind ugly fresnel effect at the end xp)
     
    daneobyrd and treivize like this.
  22. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    I think it should be much easier: if the final colour value is above 1, then the object will glow.

    So you just need to Add a Colour value * Multiplier on top of the original value colour, and that should give us the ability to bring the final brightness of the pixel to like 1.5 or 2, so if we set the Bloom effect to pick up from a treshold of 1.3, for instance, the object would start to glow.

    Also, Add means that even if the object has black lines or dark details or shadows on it, the values will be "elevated" so a 0 would go to 1.5, and so on.

    In any case, no need for extra geometry!
     
    treivize likes this.
  23. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    I probably agree, it's good because it avoids artifacts on the non-transparent parts, plus the cost of those pixels is reduced because they are completely occluding anything behind it, so there is no overdraw.

    However, this is true for the lantern where we want semi-transparency.

    For the future, we might have objects that have cutout transparency, at which point we need to implement transparency support in the main shader. Think for instance a bush or tree with a few leaf "cards", or a character that has hair cards, or something like that.
     
    treivize likes this.
  24. treivize

    treivize

    Joined:
    Jan 27, 2016
    Posts:
    71
    Again, thanks for your feedback!

    Regarding the implementation of transparency support in the main shader to enable cutout transparency, It seems that the following change should be enough:

    Actually the idea is to force the alpha channel to be 1 along the pipeline and from the tint color (not sure what should be the usage of alpha channel for tint color) and next inject back the alpha of the color map at the end of the process.

    ToonShading:
    upload_2020-11-13_15-27-51.png

    Toon:
    upload_2020-11-13_15-28-22.png

    Example of result with the lantern color map where the glass is transparent:
    upload_2020-11-13_15-28-1.png

    I will update my PR to add this change in the main toon shaders.
    And for Glass Shader, I can simplified it to remove the refraction part.
     
    Last edited: Nov 13, 2020
  25. treivize

    treivize

    Joined:
    Jan 27, 2016
    Posts:
    71
    Here is a new proposal for the lantern based on your @cirocontinisio feedback.

    To change the habit here is the final result:
    upload_2020-11-13_17-17-47.png

    The solution:
    - I removed the refraction part of the shader and add a Fresnel effect to highlight the curvature of the glass what do you think about it?
    upload_2020-11-13_17-0-8.png

    - The mesh is not split anymore just assigned 2 materials to different face set in mesh edit mode in Blender:
    upload_2020-11-13_16-44-11.png

    And stack two materials in the MeshRenderer in Unity:
    upload_2020-11-13_16-45-26.png
     
  26. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    191
    Fresnel / Rim effect needs to be stylised as well.

    Here's how glass looks in my game right now (super WIP):
    wip_glass_shader.gif
    It has two-step rim:
    - Sharp outline-bevel-like to show the thickness of glass.
    - Smooth to highlight the curvature.
    Then alpha is multiplied by that amount of fresnel.

    I took inspiration from Super Mario 3D World:


    You may notice that there is little Refraction pass that is half visible and affects only background objects outside of glass.
    And you can clearly see that thick parts have much solid refraction to catch the lighting and highlight surrounding nicely.
    Maybe we can do the same?
     
  27. treivize

    treivize

    Joined:
    Jan 27, 2016
    Posts:
    71
    Hello @Neonage, thanks for the feedback.

    I agree with you about stylizing the Fresnel effect to make it more toon style. So no gradient but more a tick border.
    To achieve that I have just added a step node after the Fresnel one to control the thickness.

    upload_2020-11-13_23-55-50.png

    (I removed the glow effect on the phoenix before pushing my code for the PR)

    Regarding refraction, I agreed with @cirocontinisio, the glass of this lantern might be too thin to generate a noticeable refraction. My initial idea to introduce refraction was to make the glass noticeable and not just fully transparent or semi transparent, but I think Fresnel effect might be enough for the need here.
    In Mario, these tubes of glass are really a main asset of the game design, so it makes sense to invest on a polish glass rendering. But not sure for this game that a mind blowing glass effect is expected by the players.

    I have opened a brand new PR for this contribution, it was simpler to start from scratch for me, especially because I also added the transparency cutoff support to the main toon shader, as seen here with the leaf.
     
    Last edited: Nov 13, 2020
  28. AlienBoyGames

    AlienBoyGames

    Joined:
    Feb 12, 2020
    Posts:
    16
    Does anyone know how to add normal map support?
     
  29. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    We do, but it's not a plan for this game. Why?
     
  30. AlienBoyGames

    AlienBoyGames

    Joined:
    Feb 12, 2020
    Posts:
    16
    It's for my own project. I was searching for a toon shader for a long time and this one fits my game really well but I use a lot of normal maps.
     
  31. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    It should be relatively easy. Open the shader and find the Custom Function node that picks up the light. You see how the shader does a Dot product with the surface normal?

    upload_2020-11-19_20-46-21.png

    That determines "how much the LightDirection and the Normal point in the same direction". Now you just need to insert your normals in there, somehow. You can use a Normals Blend node to do that. That should be enough (?)

    Try and feel free to link some images, without derailing the conversation too much maybe :) (I can detach it, in case)
     
  32. AlienBoyGames

    AlienBoyGames

    Joined:
    Feb 12, 2020
    Posts:
    16
    That did it. Thank you.
    Please read and tell me if there is a more performant way to do this since I am going to use this for mobile.

    For anyone interested here is how I did it.

    Opened "MainLight" subgraph, added a Texture2D property, plugged it in a Sample Texture 2D, plugged that in "B" from a Normal Blend node, and in "A" I plugged the Direction output from the Custom Function.

    To make this public and be able to add a Normal Map texture from the inspector I had to add the same ("Normal Map") Texutre2D property in: ToonLightingModel, ToonShading and in the Toon. And don't forget to connect everything up.

    Untitled-2.png


    I'm interested to see how would a normal map with the outline implemented look. I think that will really sell the normal map lie. If anyone knows how to do this please tell me.
     
  33. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    Do you need the normal map? Having an extra texture read is never going to be more performant than not having it. The reason to use normal maps is to have much more details that you couldn't have as polygons.

    In your case, especially since it's a mobile game... is it worth it?
     
  34. AlienBoyGames

    AlienBoyGames

    Joined:
    Feb 12, 2020
    Posts:
    16
    I am in the middle of creating the 3D assets so I can't tell for sure. I am not expecting to use normal maps on Non-Static objects.
    But for terrain with dirt and cliff rocks, I am thinking it might help me reduce a lot of polygons.

    For the apple example, yeah it's almost useless.
     
    cirocontinisio likes this.
  35. AlienBoyGames

    AlienBoyGames

    Joined:
    Feb 12, 2020
    Posts:
    16
    I found a problem with the toon shader.

    The dynamic objects don't receive lighting information from lightprobes. You can test this by setting the directional lighting to baked. The objects become black.
     
  36. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    It should be set to Mixed.

    Something we need to look into though, they shouldn't be (?)
    There might be some gotcha, since we're technically using an Unlit shader and then calculating the lighting ourselves, manually. There might be some branching to do in the shader, but the main light will for sure stay Mixed because we need the black shadows on the ground, and they are realtime.
     
    AlienBoyGames likes this.
  37. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    I've done a BIG refactor of the toon shader, and with it the look of the game too. Among other things:
    - I've introduced some gradients in the lightmaps, which in my opinion make the scenery much more visually interesting. Now the darker shadows in crevices are actually captured and displayed. Before, they were just cut off and approximated together with mid-range shadows. And before you ask: no, doing this with hard cutoffs didn't give the same result (you'd need mutliple bands, which becomes visually noisy).

    upload_2020-11-29_2-21-28.png

    - I've removed the Specular colour and Light colour from the specular calculations, both in the Main light and in the Additional lights. This doesn't mean that the specular spot is not coloured, but just that the colour is not used in URP's function in the HLSL. I currently pass a white colour. This allows us to get a simpler output, which is then multiplied by the colour. Because these 2 parameters are not being taken to the respective HLSL nodes, there's also less stuff in the graph now :)
    Speculars are now easier to setup, because they respect the colour that is passed in the Inspector 1:1. What you set is what you will see!

    upload_2020-11-29_2-21-0.png

    - The realtime (black) shadows now fade in the distance so it's less evident when they disappear. This means I could pull the shadow distance closer (right now it's 50, 2 cascades), which means I was able to pull the shadow cascades closer, which means that when shadows are close they are more defined and, when animated, wiggle less.

    Still to do:
    - Tweak the appearance of additional point lights.
    - Tweak the contribution of light probes.
    - Bring the specularity texture input to the directional light specular calculations. Right now it's just ignored.

    I haven't pushed all these changes yet, it's just to have a note for myself :)
     
  38. daneobyrd

    daneobyrd

    Joined:
    Mar 29, 2018
    Posts:
    6
    That sounds great! I had been trying to remove specular color from ramping using colorspace conversion but I got too focused on a subgraph that allowed you to control which channels were ramped. My original idea was to ensure only Value was ramped and then pass in the specular color and possibly blend the albedo output into the specular color.

    I felt like this would be especially important for objects without specular masks, as different colored surfaces on the same object were receiving the same specular light color.

    I'm going to go ahead and push to my forked version of the repo - even if what I have doesn't get merged I have some ideas in there I'd like to explore here on the forum.

    https://github.com/daneobyrd/open-project-1/tree/art-assets

     
  39. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    That would still be possible with the method I use since the "strength" of the specular contribution (the Value, at the end of the day, given by a combination of all 3 channels) results in its transparency, so it can be used to merge that colour with what's under it.

    But you know, try out new ways, why not!
    The only thing I'd say, based on your video is: that is some complex setup! Keep in mind that all this stuff needs to be setup per material, and it can skyrocket out of control pretty quickly. I am already struggling with just the colour and the multiplier :D
    (also because we use multiple different shaders, so you can't just mass-select materials and tweak them all together in one go!)
     
    daneobyrd likes this.
  40. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    The mega-refactor is done. Some more changes it brought:

    - Speculars are much simplified now. Instead of being 1) calculated 2)"toonified" (ramped) and then 3) tinted to the colour of the light and 4) to the per-material Specular colour - all of this inside the Subgraphs, I moved the tinting outside of the individual Subgraphs and added it as a final stage inside the ToonShading Subgraph:

    upload_2020-11-29_20-35-32.png

    This basically removes the ability to pre-tint the specular according to the light that's producing it, so now speculars are white by default and then get tinted by the per-material colour. Simpler to handle, less weird results when lights overlap.

    Plus, the previous setup wasn't applying the specular mask to the specular coming from the main light, which is obviously wrong.

    - The contribution of LightProbes has been reworked. Before, the "neutral" value was 3.5, which is weird and if somebody didn't know, they would probably set it to 1 or to 5 (the previous maximum), creating a Material that would act in a completely different way. Now the complexity is hidden within the graph:

    upload_2020-11-29_20-48-22.png

    I've removed the exposed value, no point in allowing per-material tweaking.

    - I've tweaked the way the random tint shader works, but I'll bring those details later to the appropriate thread.

    The next thing I want to do it is to take a look at the shader for the jellies, and make it so it can have an outline like the others. Right now, the outline is very thin and can't be made thicker, not sure why.

    But most importantly, I want to eliminate this:

    upload_2020-11-29_20-51-12.png

    Right now all shaders except the jelly one have this hack inside them, which looks like unconnected properties.
    This is because of this calculation within the ToonShading Subgraph, which only concerns the jellies:

    upload_2020-11-29_20-52-42.png

    I want to take that calculation outside of the ToonShading subgraph. That very specific Lerp operation shouldn't be in the Subgraph used by all shaders.

    cc @treivize
     

    Attached Files:

  41. daneobyrd

    daneobyrd

    Joined:
    Mar 29, 2018
    Posts:
    6
    Haha I started to feel it was getting a little complex. I think that’s mainly because I started using lerps instead of branches to control how the specular was being handled. If I had more control over the Shader GUI I think it would look less confusing.

    I think the way you are handling it sounds much cleaner but I’m concerned that it might be harder to get more natural looking specular highlights. My main aim was to allow artists to control how the specular tint would blend with the albedo output/any light color in the scene. This includes harder opaque options (i.e. the slimes) and softer tones with transparency for shading character skin.

    Most of the fields on my inspector are determining when different factors are introduced. I combined many of these values into two vector4 properties thinking that the fewer total properties we have the better. I wasn't sure what impact bool and branch nodes had on performance so I opted for lerps. Many of these fields are contextual though, and I only left visible as a precaution (such as the stepped specular).

    Here’s a list of what I currently have:

    Ramp H S V | Specular Map (Vector4)

    • X, Y and Z ports independently set whether to ramp each HSV channel. These inputs are fed into a lerp node that intake a ramped and unramped color channel. HSV are then combined and converted to RGB and fed through the specular_out for whichever subgraph it is in.
    • If V is not ramped then I ignore the H and S multipliers in favor of ramping the RGB color input uniformly, a simple color ramp.
    • I did this mainly to preserve the way some things are currently set. For example, the additional light’s specular calculations was in RGB colorspace and used a color ramp.
    • Lastly the W port controls the specular map’s contribution (lerp).
    Specular Steps | Use (Vector4)
    • The slimes rely on a step node set to (0.5, 0.5, 0.5). This property does not need to be exposed but I did so just in case.
    • This allows you to ramp the specular light using only a step node rather than a sample gradient node. The step node receives RGB values so it is used as a color ramp.
    • The W port controls the step contribution vs using a gradient to ramp HSV values.
    Albedo / Specular Color Contribution (Vector2)
    • X blends the Tinted Albedo output with the specular calculations from the main light and additional light subgraphs. This could be swapped out with an emission map easily.
    • Y controls specular color contribution later in the graph, isolating ramping. This is essentially your method of removing light color from ramping, then using Specular Color to tint the specular light calculations. When color is used in the HLSL calculation, any light color other than white has some transparency. This allows for opaque tinted specular light without using steps.
    Albedo Post Hook Contribution (not exposed)
    • This property is used in the fresnel version of the shader for the slimes. It can be used similarly to the Albedo contribution I control with Albedo / Specular Color Contribution.
    Many of the choices I made were based on not wanting to impede how the slimes are being shaded @treivize. The first two properties listed are fed into a custom subgraph, SpecularColorContribution.
     
    Last edited: Nov 29, 2020 at 9:53 PM
  42. daneobyrd

    daneobyrd

    Joined:
    Mar 29, 2018
    Posts:
    6
    Also this looks great! I was typing up my other reply when you posted this. I had similarly combined both subgraph’s specular outputs in the ToonShading subgraph. I thought it would be nice to move the ramping to the main ToonShading subgraph but I was too timid to do it myself.
     
    Last edited: Nov 29, 2020 at 8:05 PM
  43. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    But then again, do we need all this control? Now you have 10-12 more numbers that don't really explain themselves, but most importantly, when combined give place to a lot of combinations.

    For instance, I might ask myself: why is the specular "big" at a certain point? Is it because the light is strong, because smoothness is low, because the texture is white in that spot, because the specular is ramped in a certain way, because of the Specular colour I'm using, or...
    There's a big potential for madness :D

    And this is because of the toon shading, eh. If this was a PBR shader, you'd distinguish a fresnel from what is emission, or the albedo contribution from the specular of different lights. Here, everything is a band of slightly brighter or slightly darker colour. I was making some tests before and I couldn't tell if a bright patch on the model was the specular from a point light or the light contribution itself... :confused:
     
  44. treivize

    treivize

    Joined:
    Jan 27, 2016
    Posts:
    71
    Maybe we will not encounter the need for it, but it seems a bit strange from my own point of view that darker the albedo is less reflective is the surface. A black smile critter for instance has almost no specular due to the multiply node between albedo and lights & speculars:

    upload_2020-11-29_22-37-34.png

    I am definitely not experienced enough in this domain to judge if what I am suggesting is the right thing to do, but if this multiply is needed, maybe we should add a capacity to over load the specular contribution with an Exp function controlled by a new Specular parameter...
     
    Last edited: Nov 29, 2020 at 11:47 PM
  45. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    No you're right, it, a black surface should be able to have reflections too.
    Is it a Multiply?! I see only Add from this image:

    (I don't have the project at hand)
     
  46. daneobyrd

    daneobyrd

    Joined:
    Mar 29, 2018
    Posts:
    6
    I have done it! I created two subgraphs, Albedo and Albedo_Fresnel. This eliminates those two inputs on the main ToonShading subgraph.

    Pull request: https://github.com/UnityTechnologies/open-project-1/pull/240

    upload_2020-11-29_17-6-19.png upload_2020-11-29_17-6-36.png
     
    Last edited: Nov 29, 2020 at 11:49 PM
  47. daneobyrd

    daneobyrd

    Joined:
    Mar 29, 2018
    Posts:
    6
    In all this testing I started to get confused too. At one point I wasn't sure which property was Hue Saturation or Value. I think it would be nice to have main light color contribution to the specular calculations but it does add a few headaches.

    One way to fake this would be to blend the Albedo output with the specular. This could be called Surface Color Contribtion. Maybe this is all solved with a specular map or an emission map. Your solution works great and in the end, Albedo contribution to specular light isn't a must-have, especially since you can manually tint the specular light.
     
  48. treivize

    treivize

    Joined:
    Jan 27, 2016
    Posts:
    71
    I am concerned by this one:
    upload_2020-11-30_0-44-3.png
     
  49. cirocontinisio

    cirocontinisio

    Unity Technologies

    Joined:
    Jun 20, 2016
    Posts:
    422
    Ah yes. So I guess we should first multiply (all) lighting with the Main Colour, then add (all) specular on top?
    This would allow specular to exist and be bright even on dark-coloured objects.
     
  50. treivize

    treivize

    Joined:
    Jan 27, 2016
    Posts:
    71
    Yes, it was my understanding too and my attempt in my last update in the slime critter PR (here there is a mistake since the specular color was already included in the output of the ToonLightning model:
     
unityunity