Skip to content

Fix lighting for BSP model entities#1903

Open
slipher wants to merge 2 commits intoDaemonEngine:masterfrom
slipher:lightbspmodel2
Open

Fix lighting for BSP model entities#1903
slipher wants to merge 2 commits intoDaemonEngine:masterfrom
slipher:lightbspmodel2

Conversation

@slipher
Copy link
Member

@slipher slipher commented Feb 18, 2026

There is some code to skip a world surface if it has already been
added in the current view. Don't do this for BSP entities because it
is useless. Also if the gamelogic wants to draw more than one instance
of a BSP entity in different places, it should be allowed to.

Also skip per-surface culling for BSP entity surfaces since we already
did culling for the BSP entity as a whole. This is more debatable since
the entity could be huge with many sub-surfaces, but the single check
seems like enough to me.
Make sure to use the model matrix in the lightMapping shader,
so that they get correct normals and dynamic light locations.

The bug was that a code path without a model matrix was used
when the shader's USE_BSP_SURFACE macro was enabled. Change
it to always use the model matrix.

Fixes Unvanquished/Unvanquished#3474
@illwieckz
Copy link
Member

Thanks! Also it's small.

So that whole Position stuff was just garbage?

@slipher
Copy link
Member Author

slipher commented Feb 18, 2026

There was an attempt to optimize the BSP surface case by skipping multiplication by the model matrix, but this did not work for movable entities, since for those you need the model matrix to get the entity's position. And it wouldn't be worth having a shader variant just for the micro-optimization of skipping a couple matrix multiplications.

@illwieckz
Copy link
Member

Ah I see now ! Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants