Fix lighting for movable BSP entities#1897
Fix lighting for movable BSP entities#1897slipher wants to merge 1 commit intoDaemonEngine:masterfrom
Conversation
BSP model surfaces were wrongly flagged with the `bspSurface` bit which only works for fixed-location world surfaces. This flag was causing the code to skip setting up the model matrix for the lightMapping shader, meaning normals and dynamic light positions were not correct. So stop flagging BSP models as `bspSurface`. Also skip the other things in R_AddWorldSurface, besides R_AddDrawSurf, because they are useless or redundant. This means that BSP entities (e.g. doors) will now generally be lit with grid lighting rather than lightmaps. Fixes Unvanquished/Unvanquished#3474.
|
This has the unwanted side effect of forcing all BSP models to be rendered with the lightgrid instead of their lightmap. Actually, I want to implement that feature of being able to render some BSP models with the lightgrid (it's useful for movers like doors or trains, to not move with their shadows), but we better not enforce that. BSP models are BSP surfaces and they are not wrongly flagged with the
As a start we may only focus on those two uses cases (to only fix the bug you found) :
Either we add more booleans, either we turn |
|
Such bitfield can have three values (better names can be found):
To fix the bug you found we would check that BSP_SURFACE is set but BSP_MODEL is not set, and since BSP_LIGHTMAP would always be set the lightmapping would still be correct. And in the future we would implement a code path to not set BSP_LIGHTMAP on some models (likely a map entity option) to disable the lightmap on a given model and enforce the lightgrid for it. |
|
The Vega map has many doors and can be used to test this. Among those doors is a vertical door with a known visible shadow moving with the door (that's the kind of door I would like to have an option to force the lightgrid on it). |
9bbe879 to
024cf00
Compare
I'm aware of that. I had written it in the commit message, but forgot to push the latest version. Lighting the models with the light grid seems like a correct default to me, since in general they are intended to move, meaning the fixed lightmap is wrong. Stuff is usually a BSP model rather than part of the main world model because it needs to move. Maybe there are some cases that don't move, but the gamelogic would have to flag those. |
BSP model surfaces were wrongly flagged with the
bspSurfacebit which only works for fixed-location world surfaces. This flag was causing the code to skip setting up the model matrix for the lightMapping shader, meaning normals and dynamic light positions were not correct.So stop flagging BSP models as
bspSurface. Also skip the other things in R_AddWorldSurface, besides R_AddDrawSurf, because they are useless or redundant.Fixes Unvanquished/Unvanquished#3474.