For mover entities like func_bobbing or func_plat you can set a light and a color key to have it emit (dynamic) light. I noticed, however, that the light is working very oddly in-game. I set a "color" key like "1.0 0.0 0.0" and for some reason it only projects a very faint red glow on the ceiling. Nothing on the floor or wall, even though the "light" key (intensity) is set to 400.
What I did is that I looked at the sourcecode and it turns out that the client calls a method named trap_R_AddLightToScene and passes rgb values ranging from 0 to 255 to it. However, it seems that this method should accept values ranging from 0.0 to 1.0 instead. I made a fix in my own mod to scale the values back and now it appears to work as I would expect.
However, maybe I'm making incorrect assumptions about how it's supposed to work. Was I doing something wrong? Are there maps where this is used succesfully? I'm thinking of keeping my code change in the mod, but if there is a better way of making it work properly, then I'd rather leave it as it is.
constantlight on func_ entities?
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: constantlight on func_ entities?
Yes, it's a bug. trap_R_AddLightToScene() maps to RE_AddLightToScene() and that function operates on normalized colors. func_* spawn functions shouldn't upscale the color key to 8-bits RGB.
Re: constantlight on func_ entities?
Yeah, thought so. That upscaling is done because the R, G, B and intensity values are stored as a single int value though. The client code should transform it back to normalized colors again.