-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
changed toon shader to step the accumulated light instead of each light separately #36271
Conversation
Great fix! If this also applies to GLES2 then it would be nice to merge to master as well. |
@asheraryam unfortunately it's not possible to implement this fix for GLES2, which is why it won't be merged. There is an open source toon shader linked in the issue, I recommend to use that one, which looks really pretty even with the banding issue. |
8eb193d
to
69c1805
Compare
#ifdef DIFFUSE_TOON | ||
|
||
diffuse_light *= step(0.1, max(diffuse_light.r, max(diffuse_light.g, diffuse_light.b))); | ||
|
||
|
||
# endif // DIFFUSE_TOON |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style issues (indentation should be tabs, and two empty lines of separation is too much):
#ifdef DIFFUSE_TOON | |
diffuse_light *= step(0.1, max(diffuse_light.r, max(diffuse_light.g, diffuse_light.b))); | |
# endif // DIFFUSE_TOON | |
#ifdef DIFFUSE_TOON | |
diffuse_light *= step(0.1, max(diffuse_light.r, max(diffuse_light.g, diffuse_light.b))); | |
# endif // DIFFUSE_TOON |
The godot-vrm project contains a shader which illustrates some techniques that can be used to recreate toon shaded output using existing Godot functionality. https://github.com/V-Sekai/godot-vrm/blob/godot3/addons/Godot-MToon-Shader/mtoon.shader Though the above shader simply adds each light and does not need post-light, one technique that can be used to emulate this proposal would be to accumulate the lighting into a "fragment-to-light varying" variable, and assign the post-lighting function directly to DIFFUSE_LIGHT each time light is called. See here for an example of a "post_light" type function implemented using current 3.4 branch: https://gist.github.com/lyuma/a1a2093637f8216e5c53ec9e4081cd31 [Note that the shader I linked above depends on overriding NORMAL to get a single irradiance sample, but this disrupts metallic / PBR type materials (SPECULAR_LIGHT != 0) if they are to be mixed with toon shading, such as the MiHoYo style. These PBR toon shaders with specular light would require GLSL or engine modificaitons] |
There are some toon shaders here: https://godotshaders.com/?s=toon Someone smarter than me figured out how to do it :D For the time being, I'm closing this issue. |
In this proposal the issue is highlighted. This is a different solution than the one proposed, but breaks compatibility with existing toon shaded games.
Here you can see on the left current Godot's toon shader, and on the right the look with this implementation
