Dynamic Color change on object with glow map

I’m trying to change the color of a model that I’m loading from a bam file. The model has a texture applied to it, in a texturestage that is set to ModulateGlow.

Obviously, just calling setColor on the model’s NodePath doesn’t work.

I know I could change the color with a flipbook of textures, but I’d rather do it in code so as not to need all the images that would require.

The end goal is just to have a laser beam fade from a bright color to a more dim color over a short period of time. I know I could turn off the lights on the model instead of using a glow map to ensure that the object is always “fully illuminated”, but if I were to do that how would I ensure that my bloom filter works on it?

Is this even possible?

Nevermind, I’m an idiot.

As long as the model doesn’t have a material or a texture on it, I can just setLightOff() and setShaderOff() to get exactly what I want.

Out of curiousity though, is there anyway to dynamically adjust a texture’s rgb channels in code? That’s what I was originally looking for to make this happen, and I can think of several other uses for something like that.

You can, of course, directly manipulate the texture’s pixels if you need to, but this is unwieldy and slow.

There’s a 4-component color that you can associated with a TextureStage, in TextureStage.setColor(). This color value can be used in the texture combine modes if you specify CSConstant as one of the texture sources. Thus, you could construct a combine mode that multiplies the texture pixel color by the TextureStage color, and applies that to the model; and then you could modulate the resulting color by reducing the TextureStage color.

But this doesn’t work when you’re using the shader, which you need for ModulateGlow, of course. I don’t know whether the shader generator has any features that respect this or other color inputs at runtime.

David

Giving up the Auto Shader on something that’s completely glowing isn’t a big deal since such things should ignore illumination completely and thus don’t need per-pixel lighting. On other stuff, though, that’s a big disadvantage.

Well, I’ll keep TextureStage.setColor in mind in case a situation where I could use it and don’t need per-pixel lighting comes up.

Thanks.