I have just finished major feature update for Urho3D Rebel Fork aka rbfx and it will be available in rbfx master branch in the nearest future.
Disclaimer: I know some people may not be very happy that I’m doing it in rbfx instead of main Urho repository. However, this project was extremely hard on its own, and implementing it in vanilla would have taken much more effort. Feel free to port my work to main Urho repository if you feel like doing it, you will have my support. Porting would be tedious, but totally doable. Currently the code is incompatible with Urho3D master and therefore I don’t post this in Code Exchange category.
As you could have guessed, this is integrated lightmapper in Urho (well, almost Urho), something I wanted to get for years. It may be buggy, but it is not some proof-of-concept or sample, this is feature-complete and ready-to-use functional.
It was inspired by unfinished Atomic Glow, but it shares literally zero lines of code with original work of Josh.
Features:
-
Integrated with Urho3D rendering pipeline. The only manual work you have to do in order to bake lightmaps is to specify LIGHTMAP shader defines for both pixel and vertex shaders and enable “Bake Lightmaps” for the object. The rest is automatic.
-
Supported fully baked lights (both direct and indirect lighting are baked) and baked indirect only. Dynamic lights work as usual. This list may be extended in the future.
-
Supported materials and textures. Objects with Emission actually light nearby objects, and objects with transparency cast semi-transparent colored shadows.
-
There is integrated utility for automatic lightmap UV generation.
-
Supported lightmaps for
StaticModel
with or without LODs andTerrain
-
Supported lighting of dynamic objects using light probes based on spherical harmonics. If you put light probes in the scene, dynamic objects will receive baked lighting. Note: Zone ambient lighting is applied dynamically on top of baked lighting from light probes.
-
Supported environmental lighting from
Zone
fog color orSkybox
. -
Supported physical smooth shadows if non-zero
Light
radius is set. It is treated as ray spread angle in case of directional light. -
Lightmaps are filtered and seams are stitched.
-
Supported per-object resolution scale. Objects with zero “Scale in Lightmap” will contribute to baked lightmaps of other objects, but will not have lightmaps for itself.
-
Baked lighting works (or should work) on any platform, but the baking itself is available on Desktop only. If you bake large scenes or use high quality settings, bake in Release. Debug is much slower.
Here is live sample that you can try (doesn’t work on mobiles)
There is no dynamic lighting in this scene, everything is pre-computed.
(link may be out-of-date, I’m not going to maintain it forever)
https://eugeneko.github.io/
Baking of this scene took only 11 seconds, so I think I have decent performance.
Note color bleeding from bright objects due to bounced indirect light.
Note changing lighting on the character (the only dynamic object in the scene). Character model is quite dark, maybe I’ll disable textures in this sample for more expressive lighting.
Code is merged into master branch of rbfx:
https://github.com/rokups/rbfx
More screenshots: