filament icon indicating copy to clipboard operation
filament copied to clipboard

Have IBL as a light type rather than being bound per scene

Open samzanemesis opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe. Right now you are limited to a single IBL on your entire scene, this can work fine for simple programs like model viewers and tech demos but quickly break as you scale the complexity of your scene

Describe the solution you'd like It would be nice if there would be a new light type to assign an IBL per region rather the entire scene, this would also help to unify direct and indirect illumination types, akin to this:

https://user-images.githubusercontent.com/6563447/192097890-33e4fbb9-ed86-4c72-91dd-cefe1ab1c6de.mp4

If that fragment pixel is not lit by any indirect light, then it falls back to the IBL provided by the scene

To avoid sampler pressure, the IBL cubemap textures can be copied on the backend to a SamplerType::SAMPLER_CUBEMAP_ARRAY so it all uses a single sampler on runtime

This would not increase scene rendering complexity as these lights can be culled using clustered shading, as a bonus these can also have parallax as you have radius information of the indirect light

The API for creating such light could look something like this:

		LightManager::Builder(LightManager::Type::INDIRECT)
			.radius( filament::Aabb& radius)
			.transform( filament::math::mat4f& transform )
			.reflections( filament::Texture* cubemap )
			.falloff( float easingRadius ) // For blending edge easing with multiple IBL lights
			.build(*m_pEngine, filamentLight);

OS and backend Should be available on all OS and backends, I believe even GLES supports cubemap arrays

samzanemesis avatar Sep 24 '22 12:09 samzanemesis

That's something we would like to do. It's not that simple because we need mipmapped cubemap arrays and that's not available everywhere.

romainguy avatar Sep 24 '22 16:09 romainguy

A related question is once we add this type of lights, how many do we need in a scene realistically? Currently, we're limited to 256 total lights per scene.

pixelflinger avatar Sep 27 '22 00:09 pixelflinger

One solution would be to use octahedron mapping instead of cubemaps. Like this you can pack an entire cubemap in a regular 2D texture. The decoding is relatively fast, we've been using this on mobile games for 8+ years and it works great.

https://gitea.yiem.net/QianMo/Real-Time-Rendering-4th-Bibliography-Collection/raw/branch/main/Chapter%201-24/[0434]%20[Paper%202008]%20Octahedron%20Environment%20Maps.pdf

jeanlemotan avatar Dec 09 '22 10:12 jeanlemotan