-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
renderer: merge lightmap and vertex (lightgrid) world and entity lighting #301
Conversation
Once this is merged, merging cube reflection within diffuse lighting stage would only require to edit one glsl code instead of three, same for any future feature we would want to add. Maybe one day we would be able to also merge the liquid code. |
The “invisible surface” bug related to viewing angle is probably not in GLSL code. The bug is probably not in On C++ side, there is low chance the bug would be in |
One interesting thing is that the code stores lighgrid1 (used to compute light color) as lightmap when lightmap is disabled or unavailable, and stores lightgrid2 (used to compute light direction) as deluxemap when deluxe map is disabled or unavailable. This way there is only two binds for light color and light direction whatever the combination of features used. Then some |
PR is now ready, #309 was required to make it working. There is now a single function in Those scenarii are now possible:
At this point, it is expected to reproduce existing bugs. Scenario 2. currently looks wrong. The fix seems to be easy: apply on lightgrid color used for normal mapping the same tweak we apply on lightmap and discussed in #299 and #306 fixes it, but then entity lighting may be wrong, at least not what we are accustomed to. It looks like light grid lighting is wrong and too much bright (see also #313). Note: the fact the same code is used for entities and map models would allow us to avoid the bug of moving models with moving shadows by lighting moving models with lightgrid, it would also mean moving map models would have their lighting changing with ambient light, which would be very cool. |
This PR deletes almost 680 lines, does not remove features, allow more feature combinations, make new features possible, make the code more tested, will make maintenance easier, and would prevent some bugs to be introduced or fix forgotten by oversight. |
I added a commit to fix the lighting on the “lightmap light color but lightgrid light direction” scenario. I still thing there is an issue with lightgrid light color but that would be something else. |
So, the current status:
Fix for 4. is out of topic of this PR. At least this PR does not change legacy behaviour. |
Lightmap-based light color with deluxemap-based light direction: Lightmap-based light color with lightgrid-based light direction: Lightgrid-based light color with deluxemap-based light direction: Lightgrid-based light color with lightgrid-based light direction: The one before the last one is obviously wrong but we don't have to take care about it at this time. This last one does not looks that bad, but it's a bit too much bright, that can be seen especially on the building. See #313. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a pretty good cleanup!
0a1c05a
to
a2d234e
Compare
I currently disabled the feature to do normal/specular mapping on bsp surfaces because of #324. It would be cool to fix #324 to revert this change, even if we don't care about that feature: this workaround is very intrusive and I would like to get rid of it. This workaround makes sure those surfaces are rendered the same before and after the merge is done. See also #320 for a related issue about lighting that may be related to #324, and #299 for the deluxemap counterpart of #324. |
I also noticed current master fixed #326 (blend issue with internal lightmap), probably thanks to #309 (tell a surface belongs to the bsp, properly select the renderer). But the light map/light grid code merge re-introduced a variant of it. So that was likely an issue related to the fact that when the code for grid lighting and light map lighting is merged, we have to take care of the fact the light grid must not be used if there is no lightmap but light mapping is disabled. Because of the design, no lightmap use lightmap code but with a white image. So I added a commit to:
|
…en with lightgrid direction, ref DaemonEngine#299, DaemonEngine#306 The feature discussed in DaemonEngine#299 and DaemonEngine#306 to restore original light color to feed the normal-based light computation was only applied on surface using deluxe maps, leading to anomalous dark lighting with maps without deluxemaps, or when deluxe mapping is disabled. It's not related to deluxe maps but to light maps any way
… color but missing deluxe map direction, ref DaemonEngine#324 Workaround DaemonEngine#324, restore the unavailability of this feature.
…shader, fix DaemonEngine#326 - enable lightmapping with whiteimage on nolightmap shader, fix DaemonEngine#326 - enable lightmapping with whiteimage when there is no lightmap neither lightgrid - enable deluxemapping with blackimage when there is no deluxemap - rework the code and functions around those features
…ightMapping Render_lightMapping is the only function using GetLightMap and GetDeluxeMap
Let's do it. |
This merges world lightmapping glsl, world lightgrid lighting glsl (wrongly called vertex world) and entity lightgrid glsl (wrongly called vertex entity).
This prevent the risk of mistakes by not copy pasting 90% of the same code between files. This also helps to improve feature parity between all rendering options.
It makes possible to do or to implement:
Also it would be possible to implement rim lighting on world but I don't think there is any usage for that, in any way it would be very easy to do.
The implementation is rendering properly world and entities using either light maps or light grid, and normal maps are rendererd properly using either deluxe maps or light grid.