add loadIblFromTexture method

This commit is contained in:
Nick Fisher
2025-06-17 11:51:07 +08:00
parent 288acb019e
commit 71bae61015
2 changed files with 47 additions and 25 deletions

View File

@@ -288,8 +288,8 @@ class ThermionViewerFFI extends ThermionViewer {
///
///
@override
Future loadIbl(String lightingPath, {double intensity = 30000}) async {
await removeIbl();
Future loadIbl(String lightingPath, {double intensity = 30000, bool destroyExisting= true}) async {
await removeIbl(destroy:destroyExisting);
final completer = Completer();
_iblTextureUploadComplete =
@@ -306,8 +306,11 @@ class ThermionViewerFFI extends ThermionViewer {
final texture = await bundle.createTexture();
final harmonics = bundle.getSphericalHarmonics();
final ibl = await FFIIndirectLight.fromIrradianceHarmonics(harmonics,
reflectionsTexture: texture, intensity: intensity);
final ibl = await FFIIndirectLight.fromIrradianceHarmonics(
harmonics,
reflectionsTexture: texture,
intensity: intensity,
);
await scene.setIndirectLight(ibl);
@@ -324,6 +327,18 @@ class ThermionViewerFFI extends ThermionViewer {
await completer.future;
}
///
///
///
Future loadIblFromTexture(Texture texture, { double intensity = 30000, bool destroyExisting = true}) async {
await removeIbl(destroy: destroyExisting);
final ibl = await FFIIndirectLight.fromIrradianceTexture(texture,
reflectionsTexture: texture, intensity: intensity);
await scene.setIndirectLight(ibl);
}
///
///
///

View File

@@ -97,7 +97,14 @@ abstract class ThermionViewer {
/// Creates an indirect light by loading the reflections/irradiance from the KTX file.
/// Only one indirect light can be active at any given time; if an indirect light has already been loaded, it will be replaced.
///
Future loadIbl(String lightingPath, {double intensity = 30000});
Future loadIbl(String lightingPath,
{double intensity = 30000, bool destroyExisting = true});
///
///
///
Future loadIblFromTexture(Texture texture,
{double intensity = 30000, bool destroyExisting = true});
///
/// Rotates the IBL & skybox.