Search Unity

Assets DD Standard Toon

Discussion in 'Works In Progress - Archive' started by DominoM, Sep 22, 2017.

  1. IanNicolades

    IanNicolades

    Joined:
    Oct 1, 2016
    Posts:
    40
    Ah, that makes sense now - "Draw Distance" sounds more accurate, yeah. However, even if I turn it all the way up, I'm still not getting outlines. I'm also not sure where I should be finding the new context window for generating toon data, or if that's related.

    As for the second scenario - would there be a way to set a flag to flip that behavior for a mesh (or even a triangle group in a mesh?). If I'm understanding how it functions, then simply flipping it for areas with flipped normals should result in the expected result.
     
  2. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    Are you using Forward shading? The deferred version is a long way behind in features and doesn't have outlines. Another thing to check is the alpha channel on the outline color. I'm thinking the selection outline probably hid my outline when I thought I saw the problem. With your test project, I literally just opened it and adjusted the fade and the outline appeared.

    The toon data shouldn't have any effect. The data is just stored in the vertex colors, so even if you haven't generated it and enable toon data, you should get the default white color which will give an outline that looks a bit like a drop shadow. To generate the data right click on the mesh:

    MeshExtensions1.jpg

    To make the change permanent, use Save As and then select the saved version in the mesh filter for the object. It's likely I'll change the toon data format in future, but I've not decided whether that'll be just for the Enhanced version.

    That behaviour is actually why I chose my Unity chan outline colors. Before I added the cull selector, all the double sided parts only showed the outline color (her skirt and hair) - I really thought someone might have noticed the solid chunks of outline pretending to be mesh before I added the cull off feature to fix her :)

    Could you explain your use case for the flipped normals? They seem an unusual choice for a PBR style workflow. The front/back face selection is done via culling, so it relies on having correct normals and trying to workaround that would give a large performance hit.

    One solution that may work is adding backfaces for those parts and assigning them to part of the texture with 0 in the alpha channel. If you use fade or cutout mode that 0 alpha would turn off the outlines for those invisible faces.
     
    Last edited: Nov 15, 2017
  3. IanNicolades

    IanNicolades

    Joined:
    Oct 1, 2016
    Posts:
    40
    I am using Forward shading - checked in both the graphics settings and in the camera settings. I still can't seem to get it working on my end -

    toon_nooutline.png

    And as I've been seriously using Unity for about two weeks I'm rather clueless about the intricacies of its inspector - could you explain how I can get that window to show up like I'm five? :D

    As for my use case, imagine a ball rolling through a cylindrical tube with flipped normals. The user can rotate the camera around to view it from any angle, and will always see the far side of the tube behind the ball. The alpha channel sounds promising - as it's a rather niche use case I don't mind additional setup work, so long as the functionality is possible.
     
  4. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    "Line Taper" or "Line Scale" would probably be better than "Draw Distance" since it actually tapers the line, and "Draw Distance" means how far you can see in the world -- unless this actually affects the line in this case, then it'd be "Line Distance" or something imo.
     
  5. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    You can fix this on the geometry level -- i.e. you don't need flipped normals if your geometry is correct. Multiple ways of doing this depending on whether you're looking at the outside of the cylinder too, or only the inside. One way to do the latter is to create a cylinder as you would with a primitive and delete all the other geometry except the inside faces. If you need both, just create two cylinders. You can also use the "Flip Faces" function to achieve the appearance of backside faces without them actually being "inverted" normals (if I remember correctly Blender has this functionality someplace).

    Or is there some reason you can't work with the geometry this way? Might be more helpful to post a screenshot if you can to illustrate your issue.
     
    Last edited: Nov 15, 2017
  6. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    You could use non flipped normals and let the shader do the work. You'd leave your ball with Cull Mode as Front, and any object the ball goes into, change the Cull Mode to Back.

    CullDemo1.jpg

    I should be uploading a new version later today tomorrow with a fix for your outline issue. I didn't allow for Windows having a reverse Z buffer correctly. There's another bug fix as well - the above demo showed up a z fighting issue I needed to correct.

    Edit: didn't get chance to sort out the update, hopefully tomorrow now.
     
    Last edited: Nov 15, 2017
    Starpaq2 likes this.
  7. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    @ubergeekgames New version is up, could you check if outlines work for you now please?
     
  8. IanNicolades

    IanNicolades

    Joined:
    Oct 1, 2016
    Posts:
    40
    New version's outlines work for me! And thank you for the guidance on the cylinder issue, I will play around with back and culling as you described and see if that works the way I need it to.
     
    DominoM likes this.
  9. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    Great thanks for the update. One other thing, I wouldn't recommend using outlines in cut-out mode on tree foliage. It'd be a lot more performance friendly and visually accurate to add the outlines to the cutout textures and use the alpha threshold to control how much outline to add.
     
  10. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    I've was doing some experiments and one sparked an idea for a fade out effect. I got a bit carried away implementing it and it's now a very flexible image fade effect shader. Writing the controller scripts for it is my next job.

    DD_ImageFade2.jpg
     
    Starpaq2 likes this.
  11. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Nice job there man!

    Could that somehow be changing between scenes -- or is that just moving to a different location in the same scene?
     
  12. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    It's actually just fading to an image. You could use a render texture for that image, so it should fade to anything a camera can see. I'm going to make sure it plays nice with timeline so advanced fades can be configured that way.
     
  13. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Ah, okay. That'd be really cool to use a RenderTexture to do this for Timeline.

    I wonder if fading between scenes could actually be accomplished by overwriting a texture asset in the assets folder with a RenderTexture, then plugging that into your script to perform the fade at scene load...
     
  14. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    Yeah, that sounds like it should work. Save current screen to image, new scene has fade down from that image to the camera.

    I've added support for fading to a render texture as well now, though performance isn't great doing it that way. I've also got it working with timeline. GUI is my next job.
     
  15. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    Still a bit of polishing to do with the GUI for Image Fade. I keep finding new uses for it during testing (and adding options to support them!). Here it's adding a canvas effect to my painterly test scene. Same technique works for a halftone dot look by adjusting the fade window and pattern tiling.
    DD_ImageFade3.jpg
     
  16. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    That looks really nice dude! -- Does it support cast shadows too?

    It kind of look like it does close to the bottom of the image.
     
  17. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    The toon shader does yes. It uses the full Unity lighting system so any options available there also work with the Standard Toon shader. That picture was using the deferred version which only lets you do per scene settings for the lighting stylisation.

    Image Fade has the Black & White Tints which I've since renamed to Shifts to more accurately describe what they do. The Black Shift can be used to tint shadows.
     
  18. ZoeZoePixel

    ZoeZoePixel

    Joined:
    Feb 4, 2015
    Posts:
    16
    @DominoM are you still developing this shader? i have been have props with the shader...
    for some odd reason when i change my characters head material with this shader... the texture looks weird :/
    are my settings wrong?
     

    Attached Files:

  19. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    The lightwarp looks odd. Try without it as a first step.
     
  20. ZoeZoePixel

    ZoeZoePixel

    Joined:
    Feb 4, 2015
    Posts:
    16
    well the lightmap was the skin lightwarp tht was included i however... after trial and error finally got vertext colors working.... however for some odd reason they only work on a mesh filter... not askined mesh renenderer...
    the one on the left is using a mesh filter while the one on the right is using the skined mesh renderer... they both are using the same material and instance of mesh

    edit: just noticed i didnt use the lightwarp included in this example
     

    Attached Files:

  21. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    It's been awhile since I used this shader, I'll make some time over the weekend to refresh my memory on it. I do know I couldn't do everything I wanted using the Standard shader as a base so development switched to designing my own shaders from scratch, and currently that's on hold waiting for a Linux 2018 version of Unity. It could be that I switched focus and left a bug in, but I'll need to double check that.
     
  22. ZoeZoePixel

    ZoeZoePixel

    Joined:
    Feb 4, 2015
    Posts:
    16
    k thx :)
    edit: just noticed something... while using a different toon shader it does the same thing :/
    i havent notice the other toon shader does this... i am using 2018.1b6..... could tht be the prob?

    Edit1: changing the vertex colors to worldspace fixes the prob!
    v.color.rgb = UnityObjectToWorldNormal(v.color.rgb);
    float3 norm = v.color.rgb;
     
    Last edited: Feb 20, 2018
  23. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    Thanks for posting the fix. Things got a bit complicated for me - I've switched from 2017.1 Unity on Kubuntu 14.04 and ATI HD6850 graphics to 2017.3 on Solus 3 and GTX 1050ti since I last loaded the project with this shader and things looked very different from how I remembered them. Finally tracked it down to mostly a difference in how bloom is handled, but I didn't get chance to look into the shader yet. I came here to apologize for my slow response and noticed your edit.
     
  24. ZoeZoePixel

    ZoeZoePixel

    Joined:
    Feb 4, 2015
    Posts:
    16
    its ok :)
     
  25. Bud-Leiser

    Bud-Leiser

    Joined:
    Aug 21, 2013
    Posts:
    93
    I love that this turns lots of different styles into a super stylized comic book style. Keep up the good work.
     
  26. mdsaidov98

    mdsaidov98

    Joined:
    Nov 26, 2018
    Posts:
    5
    Thanks, it is awesome