No setBoolean for ShaderMaterial

Just as the title says, there’s no setBool, is there another way around this.

Can you do it as a setInt and then in the shader cast it to a bool bool(myIntUniform)?

I know float(bool) works not sure if the other way around works though.

do you particularly need a boolean? or could you get away with an int, or even some #if defines?

I’ll try that.

It might not be hard to change but having it has boolean is easier to code.

what about #define myBool bool(myUniformInt)

they are in structs like:

struct PointLight {
            bool enabled;
            vec3 position;
            vec3 irradiance;
            float const_atten;
            float linear_atten;
            float quad_atten;

and I read in an earlier topic that to use structs I use it like shdr.setVector3("pointLight.position", pos);

Apparently this works: shdr.setInt("pointLight.enabled", 1);

1 Like