Flashlight additive blending

I’m currently using a projected texture for a flashlight, with MAdd as the texture stage blend mode. However, when I have the texture projection on, I can see the texture lighting up areas that aren’t fully lit, so it isn’t really “adding”. It just makes the area where the flashlight is pointing look like there’s no lighting in the scene. How could I fix this?

MAdd won’t set the texture color higher than (1, 1, 1, 1), or pure white. If you try to go higher than that, it clamps at white. And then, after the texture color has been clamped to white, it multiplies by the vertex color, which includes the effects of lighting.

I don’t know what you mean by “lighting up areas that aren’t fully lit”. Isn’t that what you want it to do? It certainly won’t light up areas that are fully lit.

In any case, the point is that MAdd adds to the texture color, not to the lighting color. If you want anything else, you may have to write a shader to do it.

David

It’s hard to explain, but the effect I’m looking for is how the light in this picture appears white on the blue background. Right now my flashlight just goes up to the texture color, which is barely noticeable in some well-lit areas. Is it possible to do this without shaders, or should I start working on a shader for this?

Actually, I just realized I got it wrong. The lighting effects are applied to vertices first, then the texture is applied on top of that. So an additive texture effect should certainly send your RGB to white.

In my experiments, this works fine for me. Of course, if your scene is already very bright, very nearly white, it can’t get any brighter than that. If this is your problem, you will just need to darken down your scene a bit.

If that’s not your problem, then I’m afraid I still don’t understand what’s going wrong. Can you show a screenshot or something?

David

Ah, I just thought of one thing. Make sure your flashlight texture stage has a higher sort value than the default texture. Set ts.setSort(100), for instance. You want your flashlight texture to appear on top of any other textures. If you don’t set the sort value, it might end up underneath your other textures, and therefore the other textures will darken the flashlight color.

David