Render modes as uniforms

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SIsilicon

Is it possible to set render modes through uniform variables or something.
I’ve created a volume shader plugin for Godot but don’t know how to change blend modes from gdscript.

I have the same question - I would like to “dynamically” set render_mode to cull_disabled based on a ‘uniform’ parameter set by the calling script.

I guess an obvious workaround is to duplicate the shader with appropriate variations (with or without cull_disabled set), but it would be nice to be able to change it dynamically.

Achenar | 2020-09-25 02:02

:bust_in_silhouette: Reply From: Zylann

Blend modes can be changed using keywords at the beginning of the shader:

I’m not aware of a way to choose blending using a uniform, even in regular GLSL.

I am aware that blend modes can be changed using render mode. What I a am interested in is how to change said blend modes outside of the shader.

SIsilicon | 2018-04-20 14:29

I am not aware of a way to do this. It sounds feasible because normally, blend mode is not part of a shader, it’s part of the states set by the renderer when binding a material AFAIK. I wonder myself if that’s a feature to ask in the Godot API.

I also wonder why you want to change the blend mode of a ShaderMaterial dynamically? Just curious about the use case

Zylann | 2018-04-21 00:31

Because I have this addon where I want to have the blend mode customizable. Just like you can change blend mode in a regular SpatialMaterial.

SIsilicon | 2018-04-27 15:49