03-21-2015, 01:47 PM
(This post was last modified: 03-21-2015, 05:45 PM by MirceaKitsune.)
One of my modern issues with Xonotic has been that, in an era where nearly all 3D engines use realtime lighting, Xonotic is still stuck with baked lightmaps. This is partly due to performance issues, and partly because that's how the existing maps have been designed. I previously suggested a port to idTech4 for this and other reasons... but since that's a huge effort and unlikely to get done, I thought it would be best to check what I can do with the existing engine instead.
I've been thinking for a while about creating a script which disables lightmaps and converts all static lights into realtime lights. My aim is basically to make the choice between using lightmaps and realtime map lighting entirely up to the user. However I want the method to work for all existing maps, without requiring recompilation or new light entities. Most maps include a rtlights file which only add dynamic lights in a few select locations... totally not what I'm looking for.
So I tried this out today, and actually got quite an impressive result. The good news is, I managed to create two scripts which can toggle between using lightmaps and using realtime lights, regardless whether the map has a rtlights file or not. It even supports realtime bounce lighting, and performance is only reduced to half on my machine! The bad news is that for some reason, it only works on a few maps. I asked the Darkplaces devs why, and apparently it depends on how the map is compiled, as my script relies on light entities still being present in the bsp file.
In either case, here are the scripts. Also a few screenshots: The first shows classic lightmap lighting, the second shows realtime lights with lightmaps completely disabled.
Activation script:
Deactivation script:
Before: http://pics.nexuizninjaz.com/images/qiw2...js2xbu.jpg
After: http://pics.nexuizninjaz.com/images/imo7...qcd45y.jpg
Before: http://pics.nexuizninjaz.com/images/r9ok...l2xlnn.jpg
After: http://pics.nexuizninjaz.com/images/ku7r...k5zc29.jpg
Again, this will only work on maps compiled with the _keeplights parameter, otherwise it will just make the world dark. So far this includes my maps Arboria and Old Steel Complex. Either way, try it out where it works and let me know what you think!
I've been thinking for a while about creating a script which disables lightmaps and converts all static lights into realtime lights. My aim is basically to make the choice between using lightmaps and realtime map lighting entirely up to the user. However I want the method to work for all existing maps, without requiring recompilation or new light entities. Most maps include a rtlights file which only add dynamic lights in a few select locations... totally not what I'm looking for.
So I tried this out today, and actually got quite an impressive result. The good news is, I managed to create two scripts which can toggle between using lightmaps and using realtime lights, regardless whether the map has a rtlights file or not. It even supports realtime bounce lighting, and performance is only reduced to half on my machine! The bad news is that for some reason, it only works on a few maps. I asked the Darkplaces devs why, and apparently it depends on how the map is compiled, as my script relies on light entities still being present in the bsp file.
In either case, here are the scripts. Also a few screenshots: The first shows classic lightmap lighting, the second shows realtime lights with lightmaps completely disabled.
Activation script:
Code:
// Replace lightmap lighting with realtime lights
set r_shadow_realtime_world 1
set r_shadow_realtime_world_lightmaps 0
set r_shadow_realtime_world_importlightentitiesfrommap 2
set r_shadow_quakelightsizescale 1.5
set r_shadow_bouncegrid 1
r_editlights_reload
Deactivation script:
Code:
// Replace realtime lights with lightmap lighting
set r_shadow_realtime_world 1
set r_shadow_realtime_world_lightmaps 1
set r_shadow_realtime_world_importlightentitiesfrommap 1
set r_shadow_quakelightsizescale 1
set r_shadow_bouncegrid 0
r_editlights_reload
Before: http://pics.nexuizninjaz.com/images/qiw2...js2xbu.jpg
After: http://pics.nexuizninjaz.com/images/imo7...qcd45y.jpg
Before: http://pics.nexuizninjaz.com/images/r9ok...l2xlnn.jpg
After: http://pics.nexuizninjaz.com/images/ku7r...k5zc29.jpg
Again, this will only work on maps compiled with the _keeplights parameter, otherwise it will just make the world dark. So far this includes my maps Arboria and Old Steel Complex. Either way, try it out where it works and let me know what you think!