Announcement

Collapse
No announcement yet.

Toon shading model

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    The shader code in version 4.20 has been greatly changed.
    It takes some consideration to reintegrate existing code.
    One of the biggest differences: you can no longer see the variable NoL explicitly.

    Comment


      My model looks perfect if I choose unlit shading and choose Emissive Color, but then the shadows don't affect my character. Is there a way I can obtain the same style with this toon shader? I already downloaded it but I'm trying stuff at random, don't really understand and it works.

      Comment


        I was looking to add this effect to my current project. I'm not currently using this as a post process, but would love to get this working by editing the code. Would anyone be willing to teach me how to add this to my project as I'm fairly new to this source code editing stuff.
        Thanks

        Comment


          Originally posted by IOchair View Post
          The shader code in version 4.20 has been greatly changed.
          It takes some consideration to reintegrate existing code.
          One of the biggest differences: you can no longer see the variable NoL explicitly.
          Some updates on this? Is there an 4.20 fork somewhere?
          @CarstenZarbock - Follow me on Twitter, thank you

          Comment


            Originally posted by KrautPotato View Post

            Some updates on this? Is there an 4.20 fork somewhere?
            I am considering integrating the functionality of Arnage's original implementation into one or two files by modifying the clearcoat shading model.
            This will result in the loss of the clearcoat shading model, but it will save the inconvenience of modifying C++ and recompiling.
            Tell me if you are interested.

            Comment


              Originally posted by IOchair View Post

              I am considering integrating the functionality of Arnage's original implementation into one or two files by modifying the clearcoat shading model.
              This will result in the loss of the clearcoat shading model, but it will save the inconvenience of modifying C++ and recompiling.
              Tell me if you are interested.
              That'd be great! I don't think anyone would need both toon shading and clear coat in one project anyway! If you need test or any support let us know!
              The problem is that whether it'd be convenient to support mobile platform, as I see Arnage's original implementation have some modifications for mobile forward rendering pipeline.
              Last edited by renwei2; 08-27-2018, 05:49 AM.

              Comment


                Originally posted by IOchair View Post

                I am considering integrating the functionality of Arnage's original implementation into one or two files by modifying the clearcoat shading model.
                This will result in the loss of the clearcoat shading model, but it will save the inconvenience of modifying C++ and recompiling.
                Tell me if you are interested.

                I would definitely like to see that. To be honest, I refresh this thread every few days, hoping for something like that to make the process of updating engine versions easier. I'm currently using a build of 4.19 with this shader. However, I'm building a VR project and would love native Windows Mixed Reality support. So, for that plugin, I'm faced with the need to migrate to 4.21 pretty soon.

                I would tremendously appreciate it you posted a simple way to get the toon shader working in newer versions (even if it were just a clearly written instructional). Thanks, by the way, for all your posts on this topic. They've been quite informative.

                Comment


                  Originally posted by renwei2 View Post

                  The problem is that whether it'd be convenient to support mobile platform
                  The only reason the Toon Shading model can't be used under forward shading is that it uses GBuffer.CustomData. Simply replacing the CustomData with a fixed value will make the Toon Shading model work.
                  Originally posted by bhicks85 View Post


                  I refresh this thread every few days
                  This topic has a new reply on average for a few days. I think this is why Toon Shading for UE4 is slow to develop.
                  So I hope to promote this shading model by making it easier for more people to use it.

                  Also, I’m currently working on the documentation for the Google Filament project, which has tremendous help in developing the Shading Model.
                  https://google.github.io/filament/Filament.md.html

                  Comment


                    I think I managed to make this work in 4.20 (I am in a 4.20.2 source build). Seems like 4.19 to 4.20, the lighting was refactored, so it took me some diffing between versions to situate myself. But I think it works looking at my screenshot.

                    Comment


                      Originally posted by shahrizai View Post
                      I think I managed to make this work in 4.20 (I am in a 4.20.2 source build). Seems like 4.19 to 4.20, the lighting was refactored, so it took me some diffing between versions to situate myself. But I think it works looking at my screenshot.

                      Well, the picture is a little confusing. Are the face edges on the cylinder brought by toon shading, or are they not in the same smooth group in the model to begin with? Toon shading doesn't mean you see all the face edges like those in low poly style games. It's still smooth, but has stepped lighting, like cartoon.

                      Comment


                        Click image for larger version

Name:	f1.png
Views:	2
Size:	383.0 KB
ID:	1527269Click image for larger version

Name:	Cel.png
Views:	2
Size:	411.8 KB
ID:	1527268
                        I just discovered a really simple Cel Shading approach that doesn't require any line of code to be modified.
                        This method is suitable for all Shading Models except hair, and is suitable for all types of light (other types of light other than directional light can only be used as fill light).
                        Can be used for forward rendering, for dynamic objects, and partially for static objects.
                        The reflection is not very good, please increase the roughness or reduce the specular highlights.

                        Comment


                          Originally posted by renwei2 View Post


                          Well, the picture is a little confusing. Are the face edges on the cylinder brought by toon shading, or are they not in the same smooth group in the model to begin with? Toon shading doesn't mean you see all the face edges like those in low poly style games. It's still smooth, but has stepped lighting, like cartoon.
                          It's UE's cylinder, the edges you see are actually just the stepped lighting.

                          Comment


                            IOchair
                            Thanks for posting this. It's really clean.
                            How might you change the limit to something other than NoL .5?

                            Also, how would you go about changing the hue of the shaded area?
                            The color of the shaded area appears to be completely dependent on the base color. (Emissive has no effect)

                            Comment


                              Originally posted by kusogaki77 View Post
                              IOchair
                              How might you change the limit to something other than NoL .5?

                              Also, how would you go about changing the hue of the shaded area?

                              This is simple, giving B of the if function a value other than 0.
                              In addition, if you want a soft transition, you can also set the normal as follows:
                              Code:
                              Normal = VertexNormal + NoL * _softScale * LightVec;
                              Click image for larger version

Name:	shadowColor.png
Views:	1
Size:	201.2 KB
ID:	1531942
                              Set the shading model to two sided foilage, and then you can control the shadow color separately by subsurface color.
                              The effect is limited, but it does work.


                              Comment


                                Originally posted by IOchair View Post

                                Code:
                                Normal = VertexNormal + NoL * _softScale * LightVec;
                                Good Idea.
                                Can I see the tree because I can not understand the code?

                                Comment

                                Working...
                                X