diff --git a/thermion_dart/lib/src/utils/src/texture_projection.dart b/thermion_dart/lib/src/utils/src/texture_projection.dart index 308a155d..b5ce7595 100644 --- a/thermion_dart/lib/src/utils/src/texture_projection.dart +++ b/thermion_dart/lib/src/utils/src/texture_projection.dart @@ -42,7 +42,7 @@ class TextureProjection { await depthWriteView.setFrustumCullingEnabled(false); await depthWriteView.setPostProcessing(false); await depthWriteView.setViewport(viewport.width, viewport.height); - await depthWriteView.setBlendMode(BlendMode.opaque); + await depthWriteView.setBlendMode(BlendMode.transparent); final depthWriteColorTexture = await FilamentApp.instance! .createTexture(viewport.width, viewport.height, @@ -81,9 +81,6 @@ class TextureProjection { await projectionView.setPostProcessing(false); await projectionView.setViewport(viewport.width, viewport.height); - await FilamentApp.instance!.register(swapChain, depthWriteView); - await FilamentApp.instance!.register(swapChain, projectionView); - return TextureProjection._( sourceView: sourceView, swapChain: swapChain, @@ -104,11 +101,16 @@ class TextureProjection { } var _pixelBuffers = {}; - + Uint8List getColorBuffer() => _pixelBuffers[sourceView]!; Uint8List getDepthWritePixelBuffer() => _pixelBuffers[depthView]!; Uint8List getProjectedPixelBuffer() => _pixelBuffers[projectionView]!; Future project(ThermionAsset target) async { + final originalMi = await target.getMaterialInstanceAt(); + + await FilamentApp.instance!.register(swapChain, depthView); + await FilamentApp.instance!.register(swapChain, projectionView); + final camera = await sourceView.getCamera(); await depthView.setCamera(camera); await projectionView.setCamera(camera); @@ -121,8 +123,6 @@ class TextureProjection { await depthView.setRenderOrder(1); await projectionView.setRenderOrder(2); - var originalMi = await target.getMaterialInstanceAt(); - var pixelBuffers = await FilamentApp.instance!.capture(swapChain, beforeRender: (view) async { if (view == depthView) { @@ -141,5 +141,10 @@ class TextureProjection { for (final (view, pixelBuffer) in pixelBuffers) { _pixelBuffers[view] = pixelBuffer; } + + await FilamentApp.instance!.unregister(swapChain, depthView); + await FilamentApp.instance!.unregister(swapChain, projectionView); + + await target.setMaterialInstanceAt(originalMi); } } diff --git a/thermion_dart/test/light_tests.dart b/thermion_dart/test/light_tests.dart index 1f55ee64..1b090f49 100644 --- a/thermion_dart/test/light_tests.dart +++ b/thermion_dart/test/light_tests.dart @@ -8,7 +8,7 @@ void main() async { group("lights", () { test('add/clear point light', () async { await testHelper.withViewer((viewer) async { - await viewer.loadGlb("file://${testHelper.testDir}/assets/cube.glb"); + await viewer.loadGltf("file://${testHelper.testDir}/assets/cube.glb"); var light = await viewer.addDirectLight( DirectLight.point(intensity: 1000000, falloffRadius: 10));