DaemonEngine / Daemon

The Dæmon game engine. With some bits of ioq3 and XreaL.
https://unvanquished.net
BSD 3-Clause "New" or "Revised" License
306 stars 60 forks source link

Wrong realtime lighting for vertex-lit surfaces #1415

Open slipher opened 2 weeks ago

slipher commented 2 weeks ago

With vertex lighting, the wrong diffuse color is used for realtime lights. Instead of the basic diffuse texture, the result of multiplying the diffuse with the vertex color is used. This comes from the line diffuse *= var_Color; in lightMapping_fp.glsl. So dynamic lights are practically impossible to see on dimly lit vertex-lit surfaces such as parts of the station15 evergreen trees.

I guess it's structured this way because vertex lighting is a type of "rgbGen", at least in explicitly specified vertex lighting shaders where the syntax is rgbGen vertex. In principle, any rgbGen operation should be included in the diffuse. But obviously this is the wrong idea for vertex lighting, so we should try to detect the vertex lighting case and exclude that calculation from the diffuse used for lighting purposes. I guess the criteria for detecting vertex lighting can be rgbgen vertex + is bsp surface + no lightmap, in a lightmap stage.

VReaperV commented 2 weeks ago

Isn't vertex lighting supposed to be part of diffuse? If not, how is it expected to contribute to the final colour?

slipher commented 2 weeks ago

Diffuse color multiplied by vertex color. Vertex color is a light color serving the same function as lightmaps.