google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.35k stars 1.84k forks source link

Offscreen Rendering #7864

Closed AudreyWong closed 1 month ago

AudreyWong commented 1 month ago

I am using filament to implement OIT effect base on weighted-blended (https://learnopengl.com/Guest-Articles/2020/OIT/Weighted-Blended) This method needs to render opaque element and transparent element in two pass, and then composite them together. Specially, in transparent pass, it have to output two result texture, one records the accumulated color information, and the other records the alpha. I try to achieve it with offscreen view, create two texture which bind to attachment0 and attachment1 respectively.

        app.transparentRenderTarget = RenderTarget::Builder()
                .texture(RenderTarget::AttachmentPoint::COLOR0, app.transparentAccumTexture)
                .texture(RenderTarget::AttachmentPoint::COLOR1, app.transparentRevealTexture)
                .texture(RenderTarget::AttachmentPoint::DEPTH, app.solidDepthTexture)
                .build(*engine);

But I don't know how to get the result color after shading and write them to different attachment. I need help TAT!!!!!