Announcement

Collapse
No announcement yet.

Toon Shading Models, Stylized Rendering Experiments

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

    ZkarmaKun hey, thx for the update! Way cool you're still looking into it. I like your idea about combining the 3 techniques to get colored bands. Unfortunately, I've never used curve atlases...so I can't help without researching. You're going into uncharted territory, hehe.

    2 concerns

    1) I have no idea what pin we should use to specify the curve.

    2) I'm pretty sure we/you have to make sure bands only work on the toon shaders. The implementation the Japanese guy did made it so most/all shader models had bands. IMHO, we have to avoid that. Ideally, we need a way to specify no bands (preferably, no bands would be default) on a per material basis.

    Comment


      Hello, yeah I have bad and good news

      First the good one, I got it working.
      Originally posted by kusogaki77 View Post
      ZkarmaKun hey, thx for the update! Way cool you're still looking into it. I like your idea about combining the 3 techniques to get colored bands. Unfortunately, I've never used curve atlases...so I can't help without researching. You're going into uncharted territory, hehe.

      2 concerns

      1) I have no idea what pin we should use to specify the curve.

      2) I'm pretty sure we/you have to make sure bands only work on the toon shaders. The implementation the Japanese guy did made it so most/all shader models had bands. IMHO, we have to avoid that. Ideally, we need a way to specify no bands (preferably, no bands would be default) on a per material basis.
      Don't worry man I got you cover.

      For your first concern:
      For the pin I am using, like in the prev iteration I have created a new one called Toon Band. before it was working just to pass an int for the shader and later with a smoothstep function I was making the bands. Now because I got a texture atlas to define the bands I re-purposed this pin to catch a UV.y location float, with that you can choose what index you want to use from your curve atlas. The curve atlas is nothing more than a dynamic texture that generates a LUT for each row based in the curve linear color assets array that you set manually in the atlas options. This atlas texture is loaded at the editor's starting, exactly in the same way the japanese guy is doing, To be able to load the texture we define a new string reference variable which point to my curve atlas asset in the content browser, that string is manipulated through a .ini file, that means you can use a different atlas per project with obviously different LUTs per project.

      Now for your second concern
      I am not modifying at all the pretty maths that doomfest got, they are soo pretty, what I am doing is just modifying a little bit how he's calculating the NoL ( NoL = dot(Normals, LightVector) for those unaware, this is a basic Lambert ) for the light falloff and finally that NoL is driven by the curve atlas, so yes the atlas and the new pin Toon Band are only in use by the Toon Shader Models. No other shader model is aware of them.

      Now here is the video I got:



      In the video you will see the Pin I described before, also I created a new material expression called ToonAtlasParameter, this new material expression is meant only to be connected directly to the Toon Band pin, this new expression accept a curve atlas + the color curve, it works exactly in the same way the unreal's normal curve atlas parameter, except for 1 thing!, it is not outputting any color information from the output pin, it is actually calculating the UV.y position for the curve you want to use!! that's how I made the compiler understand I want to change the curve haha!

      Now a happy bug, because we are using a LUT with color information, you can actually tint every band with different colors, also maybe tint the shadow, but that is not relevant for the moment, so I am not doing that.

      Now the sadness, the bad news I mentioned before, when I injected the texture atlas into the ShadingModels.ush I did'nt know that raytracing needs to be aware of that, so basically the raytracing shaders are broken and I have no idea how to repair such error haha!!!, I think I can include the texture and the samplers in the raytrace global shaders or more maybe mask them with #defines in the shading code.

      PD: you can still use the shadow offset to create scratch effects like in the original implementation, the only thing I really change was the roughness driving the shadow softness for obvious reasons.

      EDIT: apparently I have an error with the atlas position in UV space, I think is because I am loading the texture with filtering and I need full precision to by able to choose 1 single pixel row
      Last edited by ZkarmaKun; 11-11-2019, 12:11 AM.

      Comment


        ZkarmaKun Hey! Sorry for the late reply. This is really cool the approach you've taken to this. I appreciate you taking the time to completely detail how you did it.
        I glossed over raytracing a while back. I only have a general idea of what it's doing, so that's not enough to help.
        Originally posted by ZkarmaKun View Post
        I think I can include the texture and the samplers in the raytrace global shaders or more maybe mask them with #defines in the shading code.

        EDIT: apparently I have an error with the atlas position in UV space, I think is because I am loading the texture with filtering and I need full precision to by able to choose 1 single pixel row
        If you get totally stuck, think you can upload the files you changed to gdrive or something? Might not hurt to get some extra eyes on it.
        This is an awesome job you've done, man!
        Last edited by kusogaki77; 11-07-2019, 09:49 PM.

        Comment


          hey kusogaki77 thanks for your comments, yes I haven't update my version to 4.23.1 and apparently 4.24 is comming soon, it might be a good idea thing about it. Anyhow the raytrace problem is still there I haven't had any chance to check that, also I just discorvered that for a material with too many textures samples they are crashing, no Idea why haha!, unfurtunately life reached me so I will be busy with other stuff, I will try to update and commit really quick this next week if you agree with it?

          Cheers!

          Comment


            ZkarmaKun
            Sounds good. I'd imagine 4.24 will come out sometime in December. I will implement the toon shaders into it as soon as the release drops.
            Of course, just let me know whenever you're ready. No rush.

            Dark Shift Productions & those whom it might concern

            I submitted a bug report to Epic about the Set Material Attributes node not showing renamed pins once the Shader model is set.
            It's not that big of an issue on vanilla UE4, so I doubt it'll get fixed anytime soon.

            Comment


              Hi! First of all, thank you so much for this contribution, I'm sure it has helped lots of developers.

              I'm having trouble in achieving flat shadows (i'm using toonskin and toon). By default I have some kind of soft shadows, I tried changing some parameters, but I think I'm missing something. Disabling the skylight makes the shadow flat, but full black. The left image is default skylight, right is with "Afects world tick disabled".

              Click image for larger version

Name:	ToonShadows.png
Views:	628
Size:	428.7 KB
ID:	1685362
              Click image for larger version

Name:	ToonShadows_Toon6.PNG
Views:	625
Size:	433.1 KB
ID:	1685365

              In Toon shader there is a parameter called Flatten Indirect Light, but it doesn't seem to affect. I'm using 4.22 version. There is a commit with "add controls for flat shading" back in 2018 (link), so it's implemented. Can someone point to what i'm missing?

              Thank you in advanced
              Attached Files

              Comment


                Sdruvie
                Hey, sorry for the late reply. I think the soft shadow issue you're talking about is unrelated to the flat shading bits you're referencing.
                If you want sharper shadows you have to change a setting on the lights>

                Select the light and adjust the "Shadow Filter Sharpen" parameter.
                You can crank it up to like 10 or whatever - you have to manually input it, as the slide-able value is capped at 1, and 1 is still soft.

                I haven't messed with the Flatten Indirect Light value before, as I don't use the toonskin shader model. I'll look into it and see what it does specifically. Kinda busy right now though.

                Edit:
                What material are you using? Flatten Indirect Light didnt ring a bell when you mentioned it, but I don't use ToonSkin so I thought it was something with the default skin shader maybe. I searched the engine for it, and nothing came up so it must be just a custom scalar in the material you're using.

                I'm guessing you took some other material (someone else made?), and just changed the shader model on it to Toon. Is that correct?
                There's nothing in vanilla UE4 or this Toon fork for Flatten Indirect Lighting.

                Regardless, if you want sharper shadows you have to adjust the sharpness on the lights, via "Shadow Filer Sharpen", as previously described.

                Edit #2:
                It looks like there's an issue with having stuff plugged into the Normal (at least on 4.23). If anything is plugged into there, the offset (for lit and unlit) gets distorted.

                With nothing plugged into normal, it should look like this, granted your Offset doesn't go over 0.5!
                Attached Files
                Last edited by kusogaki77; 11-12-2019, 07:03 AM.

                Comment


                  Hey, thank you for helping. The value of "shadow filter sharpener" does not fix what I've expected. I think I haven't explained well enough, sorry for that, English is not my first language. What I'm trying to solve is the soft flat shadow, not the hardness of the transition. I've set the color of the materials to almost white, and in the shadow I have different values of grey, and I expected the same value.
                  I've tried different things:
                  - Delete normal map (I used a flat normal map, so it's no problem)
                  - Change shadow filter sharpener: does not solve the problem.
                  - Offset value is 0.5, and I'm using toon skin material, and toon material.
                  - In post process volume set ambient occlusion to 0: helps, but I want to keep ambient occlusion to other objects, so it can't be a solution. Setting this to 0.5 or more results in soft shadows.
                  - Change value for "Lower Hemisphere is Solid Color", in the skylight settings. Setting this to false change the shadow to a flat color, this is what I want, but I'm not sure if this is the way to do it. (If the value is true and the color is white the result is the same). See the attachments, in blue, color 1A is the same as 1B in one image but not in the other.

                  I don't remember changing anything from the main material or having custom scalar parameters, but, for testing, I've downloaded your version 4.23.1 and I'm currently installing it. (link). I'll try a default scene with the default toon materials. I'll post the results in a few hours.
                  Attached Files

                  Comment


                    Sdruvie
                    Thanks for the info. You say you're setting the AO in post process. This would affect everything unless you use a custom depth stencil.
                    Using a PP to affect the shadows shouldnt be necessary though.

                    Have you tried setting the AO to 0 on the material itself? When I do that, my shadows become solid - at least for the standard toon shader.
                    You want to upload a simplified version of your project to gdrive or something with the material that has the problem? That'd make it easier to look at.
                    Btw, your English is not an issue! Regardless, none of the math for the toon shaders changed between 4.22 and 4.23. It should function the same on both.

                    Edit:
                    Toonskin seems to be working fine.

                    Note: 4.23.x doesn't have the lower hemisphere settings for lights. I enabled the SKS specified cubemap (dont have the grey one you're using tho).
                    There is no PP involved here. All of the settings are on this one specific toonskin material.
                    Attached Files
                    Last edited by kusogaki77; 11-19-2019, 02:06 AM.

                    Comment


                      Fyi: From 4.24 I'mma change the way I make branches. Up until now I've had a separate branch for each hotfix. In general, hotfixes don't introduce new bugs - they bring stability to the previous branch. So, assuming that pattern will continue, I'm gonna just make 1 4.2XToon branch, and keep updating that with its corresponding hotfixes. That way you wouldn't have to mess with changing the upstream repo each time there's a new engine release or hotfix.

                      You guys think that's OK? Or, would it be better to keep doing the same (new hotfix, new branch)?
                      Or, what about just rolling all the toon stuff and engine hotfixes into the fork's Release branch?

                      Personally, I think making 1 new 4.2XToon branch, and updating it with all the hotfixes is the best of both worlds.
                      Last edited by kusogaki77; 11-21-2019, 03:41 AM.

                      Comment


                        Originally posted by kusogaki77 View Post
                        Hi, how can i access to your repository? when i click, it says error 404 page not found

                        Comment


                          Originally posted by Corrado0 View Post

                          Hi, how can i access to your repository? when i click, it says error 404 page not found
                          https://www.unrealengine.com/en-US/ue4-on-github
                          VR/AR Development [Portfolio | YouTube | LinkedIn]

                          Comment


                            Originally posted by VirtualLilies View Post
                            Thank you so much!

                            Comment


                              Looks like 4.24 just dropped. I'll see if I can merge it. Hopefully it doesn't take too long, but I only have time to do it during downtime at work, so no ETA.

                              Comment


                                I guess you're gonna need an updated localized IBL
                                Follow me on Twitter!
                                Developer of Elium - Prison Escape
                                Local Image-Based Lighting for UE4

                                Comment

                                Working...
                                X