-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Move material attributes from shader code to material properties #933
Comments
Underrated proposal: See the hack I had to do with MToon basically copying and pasting the same shader code 7 times, and even then I don't support all combinations, but I was forced to guess what users would probably want and provide those variants: One issue this proposal doesn't address is Transparent vs. Opaque shaders. Transparency is determined by whether the code contains "ALPHA = " anywhere in the code, and that cannot be changed with a render_mode, so unless this is addressed, you will still need at least two versions of each shader, unfortunately. I would like there to be a We don't have a proposal for stencils yet it seems, but that needs to happen, too. |
Stencil support was discussed in an issue a while ago, but no proposal has been opened yet. |
Note, this isn't quite true. Render modes change flags in Godot's main scene shader which can result in very different shader code being generated. For example, render mode |
Ok so I found the list of render_mode_defines in servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp and ./servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp I would argue that an exception ought to be made for DO_SIDE_CHECK: actions.render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n";
actions.render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n"; (it should be simply made togglable for performance if necessary) Then that leaves the following render_modes which do not change generated shader code (scene)
and this list (canvas_item)
So, this proposal should really be: move render_modes for blend_, depth_ and cull_ outside of the material, which was hinted at in the OP:
|
Up for this proposal. I find it very annoying to duplicate a shader just to change cull front/back (i often use double render pass) |
For toggling between a transparent and opaque shader with a |
Describe the project you are working on:
Summon Age (https://www.summonage.com) and other mobile 3D games in RPG/MOBA genre.
Describe the problem or limitation you are having in your project:
We have to create many shaders that are basically the same, but only differ in their render_mode declarations (culling, blending, depth testing). Godot then also wastes time compiling these shaders, even though these are not shader differences and the resulting (GLES) shader code is identical.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Move the render_mode settings that are not really part of shader but rather a material parameter to be a material property.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
The user will no longer have to create redundant shaders.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
No, and it will be used often.
Is there a reason why this should be core and not an add-on in the asset library?:
Can't be implemented as an addon.
See godotengine/godot#21105 for some earlier discussion of this feature. It also correctly notices that if stencil support is added to Godot in the future, it's better be as material parameters rather than within shader code.
The text was updated successfully, but these errors were encountered: