tr_shader: fix loose texture lighting, fix #289 #290
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before (light mapping/vertex lighting):
After (light mapping/vertex lighting):
Don't mind the weird artifacts visible with vertex lighting, they come from another issue that is not yet tracked down (introduced between
0.50.0and0.51.1).For some reason the loose textures were set to
DIFFUSEMAPstageType (that seems correct) while the colorGen was set toCGEN_VERTEX(that seems not correct):Daemon/src/engine/renderer/tr_shader.cpp
Lines 5464 to 5470 in 390a243
That seems not correct because the rest of the code sets and expects
CGEN_IDENTITYcolorGen for textures withDIFFUSEMAPstageType:Daemon/src/engine/renderer/tr_shader.cpp
Lines 1530 to 1536 in 390a243
The issue was reproduced on 0.6.0 release and the wrong colorGen was seen in the very first commit of the repository:
Daemon/src/engine/rendererGL/tr_shader.c
Lines 5558 to 5564 in eb73a11
The bug was not visible before because the diffuse map lighting code had blending disabled (that was disabling alpha blending too), the bug was uncovered when alpha blending was enabled for multitexture materials (they use diffuse map lighting code), see #277 (glsl/lightmapping: fix terrain alpha blending for collapsed materials).