Open alice-i-cecile opened 8 months ago
In order of difficulty, what would need to be done is:
Write a reflection probe baker. This is pretty simple: just load a scene, render all 6 sides of a cubemap, run the results through the glTF IBL Sampler, and save the results to .ktx2
.
Write an irradiance volume baker. This is a bit more involved than (1), but still not too hard. The easiest approach would be to, for every voxel location, render a cubemap in which each side is, say, 32x32, and then average all the colors of every side together to reduce the cubemap to 1x1. This would work, but would be slow (however, it wouldn't be that slow: it would still probably only take a few seconds).
Write a lightmap baker. This is a lot more involved. You'll want to start with some sort of GI solution, for example bevy_solari
or strolle
. For each lightmapped object, initialize a blank light map texture. Then path trace every pixel on that texture, and save the results as an image. As a followup, you'll probably want to integrate xatlas to generate the UVs and a denoiser like OpenImageDenoise.
I made a PR to replace gltf-ibl-sampler, but it didn't work well on all environment maps and I've shelved it for now due to lack of motivation https://github.com/bevyengine/bevy/pull/9414.
I've contemplated posting my environment maps to Discord and asking if anyone would be willing to convert them :)
BTW, three.js has a PMREMGenerator written in JavaScript which does something similar to what we want:
https://github.com/mrdoob/three.js/blob/master/src/extras/PMREMGenerator.js
What problem does this solve or what need does it fill?
Light maps (cube maps, irradiance volumes, reflection probes) are a class of assets used to "fake" pretty but expensive global illumination. Bevy has support for these now, but as #10057 says, we have no way to generate them ourselves:
What solution would you like?
This is tagged with
A-Editor
, as while it is possible to do this using a non-GUI solution, it makes more sense as a component of a larger scene editor.What alternative(s) have you considered?
Existing third-party light baking tools exist, and can be used with Bevy.
These are generally harder to customize / integrate, and cannot be used to dynamically generate lightmaps as part of procedurally generated environments.
Additional context
Pre-existing work: