Search Unity

Toony Colors Pro+Mobile 2

Discussion in 'Assets and Asset Store' started by Jean-Moreno, Mar 7, 2015.

  1. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    231
    Fantastic! I can't wait for it!
     
  2. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    @Guideborn I've looked into it, and adding screen-space UVs for masks is a little more complicated than anticipated, especially to make it work nicely with all the other features from the Shader Generator, and I don't think it's worth the trouble for such an exotic feature.

    I'd rather make you a custom template that matches what you want exactly, please send me an email with the details on how you'd see this screen-space mask to work.
     
  3. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    231
    Done. Thanks for checking it out.
     
  4. pleasantPretzel

    pleasantPretzel

    Joined:
    Jun 12, 2013
    Posts:
    34
    Hi Jean-Moreno! Really loving TCP2. Thanks for all you do. :)

    I'm also very interested in removing smooth fall-off for spot and point light shadows. Being able to have my models simultaneously cast and receive hard shadows from directional, spot, and point lights would really make some of my projects shine. I'm using very hard fixed ramp textures (often just 60% black, the rest white) and so far with directional lights, it's working beautifully.

    Is this feature still in the plan for future updates? Or is there a way to implement this now that I might be unaware of? I'm still learning all the features of TCP2. :D

    EDIT: I know that I might not be very clear here - sorry! My interest above is completely concerned with real time hard shadows. Hope I'm phrasing things alright.
     
    Last edited: May 3, 2017
  5. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    Point an spot light falloff bypassing is coming to the next update - I'm still ironing out the last few changes and will release it soon hopefully.

    Note however that this is to override Unity's falloff texture when it comes to direct lighting - i.e. the texture that makes point lights fade more and more as the they are moved further from the object.
    It is not related to cast shadows: these are handled by Unity with shadowmaps, and they actually don't have any falloff (the only "smoothing" you can get on them is by using soft shadows which will apply a PCF filter).
     
  6. pleasantPretzel

    pleasantPretzel

    Joined:
    Jun 12, 2013
    Posts:
    34
    Ok, gotcha! Looks like I was pretty confused with my question, but you still got what I was trying to say, so thanks for the response and clarification! I appreciate it. Looking forward to the update ;)
     
  7. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    FYI Toony Colors Pro 2 v2.3.3 has been released, here are the release notes:
     
    chiapet1021 likes this.
  8. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    231
    Is turning a texture into grayscale through the Unity inspector the only way to get it to work with Sketch Overlay? I wanted to maintain the texture's original colors for the sketch effect.
     
  9. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    That's because the shader will only take the alpha channel from the sketch texture.
    You can modify it manually though, search for this line:
    Code (shader):
    1. fixed sketch = tex2D(_SketchTex, s.ScreenUVs).a;
    and replace it with
    Code (shader):
    1. fixed3 sketch = tex2D(_SketchTex, s.ScreenUVs).rgb;
    and that should work.
    (you can also do this change in a custom template, this way you'll always get that option in all your generated shaders)
     
    Guideborn likes this.
  10. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    231
    Awesome! It worked. Since I'm using the Screenspace custom template you made me, is there a way to apply it to the screenspace UV that's using Mask 1? I'm using the Mask1 from Detail Texture if you must know.
     
    Last edited: May 15, 2017
  11. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    Not sure what you mean. The sketch texture itself is independent from the screen-space UVs, it just uses them - same for Mask1 in the custom template. So the fact that the sketch texture is RGB or alpha only wouldn't change anything for the mask.
    What do you want to achieve exactly?
     
  12. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    231
    Just to simply let the screenspace UV use its original RGB color.
     
  13. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    Well... that still doesn't make sense.
    UVs are coordinates, they simply tell where to sample the texture. In this case, they are in screen-space, meaning that the texture will match the screen, rather than the mesh's UVs.
    Thus UVs don't interfere in whether a texture should use its RGB or alpha channel.

    Which texture would you want to use its RGB color? What's the goal visually?
     
  14. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    231
    I apologize for not being clear.

    Changing the "a" to "rgb" helped with the sketch effect, meaning any texture I apply for the sketch effect will use its original RGB without having to force the texture to grayscale in order to work.

    However, for the custom screenspace UV effect, the texture I'm using for that still will not show without forcing it to grayscale through the Unity inspector. In the picture, it shows me using the Main Color to add color to the grayscaled (through Unity) plaid texture I'm using, but as you can see, it appears washed out without all its original colors.

     
  15. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    @Guideborn Ah, I think I understand better now. Since this concerns a custom shader template though, let's continue the discussion by email!
     
  16. Andrith

    Andrith

    Joined:
    Apr 11, 2015
    Posts:
    3
    Hey mate,
    I have been playing around with your awesome shader and I am lamenting the lack of vegetation animation options. So, I did some experimenting and found that if I use the sin wave feature from the water template and adjust the direction of the waves & set the vertex influence to alpha it works quite nicely. However, the water shader lacks an alpha cut out option as well as options for shadows.

    Now, I have tried to use my limited experience with shaders to solve this issue by playing with your templates, but, it's like a kid throwing cubes at round holes. Is there any advice you can give me to put me on the right track?
    Thanks,
    Andrith
     
  17. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    Vertex animation for vegetation has been requested before so I'll look into adding it for a future update.

    But if you want to do things manually, here are some tips (SG = Shader Generator)
    • The SG templates are structured like this:
      • SG-specific blocks with various meta data (e.g. #FEATURES contains the UI for the template), that start with #BLOCK and end with #END
      • Shader code with SG condition blocks (that start with ///) that will activate based on the selected features in the UI
      • This is basically it, but because the file is so big (so many features!) it can look a bit daunting
      • I use notepad++ with a ShaderLab syntax highlighting plugin to easily visualize the file (the /// blocks will appear green there) (I've attached the np++ XML file to this post, had to zip it to be accepted by the forums)
    • Here you want to animate the vertices, so you need to hook your code in the vertex function:
      • Look for the following function:
        Code (shader):
        1. void vert(inout appdata_tcp2 v, out Input o)
        And hook your code there, at least after the UNITY_INITIALIZE_OUTPUT line.
        For example this would give you a sine-based animation on the local X axis of your meshes:
        Code (shader):
        1. v.vertex += sin(v.vertex.y * 4 + _Time.z) * 0.1;
      • You also need to make sure that the vertex function is enabled (because by default it is only enabled when needed by the selected options), so in the #KEYWORDS block at the beginning of the file, add this line:
        Code (Shader Generator template):
        1. enable_kw    VERTEX_FUNC
        (note this should be a tab separating the two words, not spaces!)
    This should hopefully give you a good start at making your own template!
     

    Attached Files:

  18. Andrith

    Andrith

    Joined:
    Apr 11, 2015
    Posts:
    3
    Hey mate,
    First, you are a legend. This really did help me out big time.

    On top of having the vegetation move now I have also added the vertex alpha to it with some jury rigging and copying of code (I still ain't got too good a grasp on shader terminology.) I have now managed to craft a pretty lush vegetation shader. My game now looks more alive! So mega props to you for helping me out with it, a billion cookies for you!

    Quick question, am I cool to pop up the template file here?
    Massive thanks again,
    Andrith

     
  19. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    Using either a generated shader or the Standard PBS shader with cast shadows off and receive shadows on (no self shadowing) in Unity 5.5.1f1, shadows cast by a directional light (set to hard, realtime shadows) go through objects and are cast on both sides like this: http://imgur.com/a/77tpu

    Is there any way around this?
     
  20. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    Well, even though it's in its own format it contains a lot of code from TCP2, so please don't pose it here.
    You can send me your template by email if you want me to take a look and see if I can add some of those things in a future update.

    I couldn't reproduce your issue. Any chance you're using transparency somewhere? Transparent objects aren't supposed to receive shadows, but when they do the mapping is incorrect and it can give this kind of artifacts.
    Could you send me that example by email so that I can take a direct look at it?
     
  21. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    No transparency is used. I sent you a stripped down example project.
     
  22. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    Ok, I took a look at your example and found out the cause - but it's actually part of Unity, and I don't have any solution for you.

    The shadow you see is actually part of Unity's shadow system and is correctly mapped, but it should be hidden by the shading (the 'artifact' shadow would lie in the terminator where no light is received).
    But in your TCP2 shader, you have set it to use a ramp texture, yet no ramp is defined. This means that the shader won't get any direct lighting, but only shadows - hence why you see that shadow behind the model.

    Here's an image to help illustrate the default behavior with the Standard shader:
    UnityShadowIssue.png
     
  23. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    I do have a ramp defined, which I forgot to include with the example project. I sent you another message with the material's ramp texture.
     
  24. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    Ok got it. The issue is related though: the ramp you are using doesn't start with a pure black color, but a gray one. Thus the N·L shading will be brighter than the shadow (which is pure black), and the shadow will show on top of it.
    I think you can achieve what you want by using a ramp texture that starts with a pure black color, and then set a brighter Shadow Color in the material.
    Here's the ramp you sent me but leveled so that it is pure black:
    ramp_black.png
     
  25. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    Thanks for looking into it.

    Ultimately, I had to enable wrapped lighting on the shader and use a ramp that was half 100% black. That really complicates adding lighting complexity to solidly colored low poly meshes. And, being restricted by realistic lighting limitations with a toony aesthetic is pretty frustrating. But, it does hide the second shadow
     
  26. arvzg

    arvzg

    Joined:
    Jun 28, 2009
    Posts:
    619
    Hi @Jean-Moreno im playing around with this in 5.6.2 now, and in the Demo TCP2 scene I'm getting tons of errors like this:

    Code (CSharp):
    1. [TCP2 Demo] Can't find shader for keywords: "OUTLINES,TCP2_BUMP,TCP2_OUTLINE_TEXTURED,TCP2_RIM,TCP2_SPEC,TCP2_ZSMOOTH_ON" in material "TCP2_Demo ethan_eyes"
    2. The missing shaders probably need to be unpacked. See TCP2 Documentation!
    3. UnityEngine.Debug:LogError(Object)
    4. TCP2_Demo:UpdateShader() (at Assets/JMO Assets/Toony Colors Pro/Demo TCP2/TCP2 Demo Assets/Misc/TCP2_Demo.cs:269)
    5. TCP2_Demo:Awake() (at Assets/JMO Assets/Toony Colors Pro/Demo TCP2/TCP2 Demo Assets/Misc/TCP2_Demo.cs:51)
    This is imported into a new project. Any idea what's happening here?
     
  27. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    Have you unpacked the shaders as described in the documentation?
    For the demo to work properly, all the desktop shaders should be unpacked.
     
    Last edited: Jul 18, 2017
  28. arvzg

    arvzg

    Joined:
    Jun 28, 2009
    Posts:
    619
    Yep, figured that out eventually and got it working now, thanks!
     
  29. Docm30

    Docm30

    Joined:
    Dec 15, 2013
    Posts:
    19
    Hey, I was wondering if there was any way to generate a shader with this that uses a texture for shadow colour? That would be enormously useful to me.

    Thanks.
     
  30. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
  31. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    This is actually coming in the next update (2.3.33), planned to be released this week!

    Don't worry, I check both threads but I've had a lot to do recently hence my late reply! I've answered you on the other thread.
     
    Arkade likes this.
  32. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    I'm adding water that the player can swim in and thus need a surface that acts as an animated transparent overlay, ideally with world aligned UVs. The illusion of volume will be created by simply coloring the walls and floor under the water's surface. So, I generated a TCP2 water shader with transparency.

    Initial tests look promising: http://imgur.com/a/4aE9i
    But, there are some points that are still a bit awkward for this use case.

    First, even with culling set to off (double-sided), the water is only visible on the top of the surface quad. Duplicating and flipping geometry kinda works, but the ramp threshold has to be set to 0 to avoid the underside being unusually dark. And, duplicating and flipping complex geometry created by spline tools (for rivers) can be rather awkward.

    Also, since I wanted to tint the surface when seen from below, I added an additional quad for that purpose. Ideally, and particularly for spline geometry, an underside tint would be a material property instead.

    Another anomaly I noticed is that the surface does some weird snapping at specific camera angles: https://gfycat.com/gifs/detail/FrailShockedKatydid I sent you a PM with the shader I generated and its material in case you want to look into this.

    There's also the matter of falls. I quite like the stretched out appearance of the world aligned UVs seen in the editor when a water surface is angled. It could potentially make a nice waterfall, naturally increasing the perceived flow rate without actually changing the scroll speed. However, at runtime, the texture doesn't appear stretched at all, instead doing a sort of shimmer: http://imgur.com/a/e2tpA

    And, on a related note, while this is more related to tools than shaders, I feel like this could really use a specially made spline tool for building rivers with integrated waterfalls (ideally, with waterfall-specific settings), similar to this: https://www.assetstore.unity3d.com/en/#!/content/71677 Particularly with bobbing and scrolling water, getting a smooth connection to a waterfall that shouldn't bob and that would otherwise possibly need a unique material would be awkward.

    Overall, my impression is that TCP2 water, in its current state, looks really great for solid bodies of water that the player cannot dive into. But, for anything else—flowing rivers, falls, underwater—it has some usability hitches.
     
    Last edited: Jul 25, 2017
  33. Docm30

    Docm30

    Joined:
    Dec 15, 2013
    Posts:
    19
    Fantastic. Thanks.
     
  34. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    Double-sided seems to work fine on my end, however it does not when depth-based foam is enabled (you will get foam all over the backfaces).
    I'll work on a way to solve that issue in a future update.

    Special color tint for backfaces sounds like a good idea, I'll look into that.

    I couldn't reproduce that with the shader you sent me. My first guess would be that it's related to dynamic batching - do you still see the problem if you disable dynamic batching in the project settings?

    That looks really weird... maybe related to the UV sine animation combined with dynamic batching.

    Could you send me a little project with all these issues showing properly? It'll be better for me to be able to reproduce them and then investigate!

    Note that TCP2 is mainly a shader suite, so I don't plan to add these kind of tools to it. But I don't see any reason why meshes generated with another tool, such as the one you linked, wouldn't work with TCP2's shaders!
     
  35. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    Does / Could TCP2 have a water shader that uses mesh boundaries to do its foam effects (rather than depth-buffer based) ?

    I noticed performance problems on my mobile VR game after getting the WindWaker water shader working by enabling the depth buffer. It turns out enabling the depth-buffer took rendering down from 55-60 FPS to 25-30 FPS -- not really acceptable for VR.

    This seems more viable if one had a perfectly fitting water mesh (such as one created by https://www.assetstore.unity3d.com/en/#!/content/71677 as pointed out by @OhiraKyou -- awesome find btw -- I'll likely buy it!). I guess the challenge is sloping sides at the same time as vertex displacement? I.e. it might rise and lower at the edges (letting the user peek under). What might be the best solution if this is the case? Perhaps we could restrict which vertices to displace with a value in vertex colours or a texture map channel? (I'm thinking aloud here, i.e. throwing ideas around -- if this is already all implemented, please forgive!)

    Thanks!
     
  36. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    This is indeed the biggest limitation of the depth-based foam, as it doesn't take any edge information. This article explains it nicely: https://madewith.unity.com/stories/the-stylized-water-of-flotsam
    The issue is that a shader doesn't have any notion of "mesh boundaries", so this isn't something that can be solved in the shader only.
    There are different approaches to solve it though, for example:
    - using a different mesh for the foam, specially tailored to be at the edges of the water surface - Zelda Wind Waker does that for example, with 2 textures scrolling in opposite directions to simulate the foam look
    - using vertex colors could work also, basically use one of the RGB channel as a mask for the foam texture to show, so you'd only color the edges of the mesh for example
    Note that none of these techniques would work with dynamic objects though, and this is where the depth technique works nicely even with its limitations.

    Another idea I had reading the Flotsam article would be to use the stencil buffer: render your dynamic objects extruded along their normals to the stencil buffer only, and then in the water shader render the foam where it intersects with this stencil value... but that's a little more involved and just an idea at this point. It would also double the drawcalls for the objects since the stencil one would be its own.
     
  37. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    Turns out, disabling depth based foam and and dynamic batching solved the visual artifacts. I should have expected the batching issue since I experienced something similar in UE4.

    Could the DisableBatching tag be added as a generator option to avoid having to disable dynamic batching entirely?
     
  38. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    Yes, good idea! I'll add that in the next update.
     
  39. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    I have another suggestion for the default shader: animated underwater light caustics with two separately animated textures. Could also possibly be used for surface energy effects.

    Currently, the best alternative I've found is using a generated water shader. However, it lacks a setting for a texture that doesn't animate. So, I can't apply my color palette texture to the material.

    Missing its color palette though it may be, here's what it currently looks like: https://twitter.com/OhiraKyou/status/901416553899536384
     
  40. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    That sounds very very specific! I'd recommend modifying the output shader to add the functionnality, or make your own shader template with this feature in it if you want to keep the Shader Generator's flexibility.
    I can help you get that added in if you don't know much about writing shaders, but I'd love some specific details in an email (what kind of animation would he caustics texture have for example).
     
  41. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    I basically just want a toony shader with the water shader's animation added on top as an overlay. Or, as a second best, a water shader with the opposite: a mesh UV based texture that doesn't distort so that I can apply an undistorted color texture. It's not as specific as it sounds when you consider caustics just one of its uses. Other examples:
    • energy field overlays
    • a thin layer of liquid on wet objects
    • conveyor belts (using just the UV scrolling)
    • fake animated shadows (like shadows on the ground in forest of swaying trees)
    I'll see if I can add a generator template for it some time.
     
  42. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    TCP2 needs an equivalent to the sRGB (Color Texture) property of image files. I use the same color palette for texturing and vertex coloring and need to seamlessly transition between the two. I'm working in the linear color space in the player settings for accurate light calculations. Here's an album with a couple of images with descriptions illustrating what I mean: https://imgur.com/a/uU47p
     
    Last edited: Sep 19, 2017
  43. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    I'll look into adding this as an option in the Shader Generator.
    But I think you should be able to solve that by converting the vertex colors directly from gamma to linear space beforehand.

    EDIT: the "Gamma to Linar space" option for vertex colors will be added in the next update.
     
    Last edited: Sep 26, 2017
    OhiraKyou likes this.
  44. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    Awesome, thanks!
     
  45. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    There doesn't seem to be a way to make opaque liquids with the water shader generator; with alpha blending and depth effects all disabled, you still get something like this example above a void: https://imgur.com/7DVQ3YK That's the skybox and a wall hanging down there. Placing an opaque object below the liquid is a hack that works for most, but not all cases.

    So, there should be a method of generating truly opaque liquids, particularly for designing hazards. Even the lava example is transparent, which doesn't make a lot of sense. Example: https://imgur.com/Ty1Lr3e
     
    Last edited: Sep 27, 2017
  46. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    Without any option enabled, the water shaders are actually opaque. With depth-based effects, they are still technically opaque but use the depth buffer to simulate the presence of other objects behind (this is the case for the example lava shaders in the "Demo TCP2 ShaderGenerator.unity" scene).

    Are you sure that alpha blending is disabled?
    Are you sure that these are not shadow artifacts because "Shadow Receiving" is enabled on the water/lava mesh, yet "Enable Shadows" is disabled/unavailable in the Shader Generator?

    If so, please send me your generated shader along with its .meta file and I'll take a look at it! (+ the Unity version you are using)
     
  47. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    Whoa, OK. Turns out, it was, indeed, caused by forgetting to disable shadows. I actually intended to do that after reading the info box but got either sidetracked or interrupted and totally forgot about it.

    Thanks again! This acid looks pretty cool now: https://imgur.com/ehVtxIJ
     
  48. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    So, same issue from a different perspective: I have determined that the global fog image effect's height fog is visible through TCP2 generated water. That is to say that objects affected by height fog that are behind the water will have their height fog visible on top of the water. Here's an example: https://imgur.com/1pwzJmu

    This happens even with depth color, depth foam, and fog disabled. I tried generating with the new version, since it mentions depth bleeding, but it looks the same.

    I had the same problem when I was trying to make a pure black unlit shader for simulating holes. Ultimately, I had to just use a hacky material with Unity's standard shader to avoid the image effect being visible through the object.
     
  49. Jean-Moreno

    Jean-Moreno

    Joined:
    Jul 23, 2012
    Posts:
    593
    In your generated .shader file, at the end you should have the following comment:
    Code (csharp):
    1. //Fallback "Diffuse"
    Uncomment it:
    Code (csharp):
    1. Fallback "Diffuse"
    And it should hopefully work nicely with global fog now.

    It looks like the global fog effect needs the shader to have a shadow caster pass for it to work properly. I'll set that as the default in the water template for the next update!
     
  50. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    Sick, that worked! Thanks!