Closed beeble-wonjunyoon closed 5 months ago
Enable depth write for your transparent objects otherwise they are not part of the depth buffer, and therefore are not handled by depth of field. Note that this means you won't see depth of field through transparent objects (lifting that limitation woild be very expensive and other engines have the same limitation).
Thank you for your quick response. @romainguy
Just to clarify, after I apply .depthWrite(true), the entire rectangular plane does not become blurred. So you mean that there is no way to make only those areas with alpha 0 be blurred, without affecting the rest of the rectangle?
Right, for this you could discard the fragments where alpha=0.
⚠️ Issues not using this template will be systematically closed.
Describe the bug
I'm working on compositing an RGBA image from a green screen onto an HDRI image using IBL. For this, I've created a rectangular geometry and applied various material maps derived from the image. To achieve a blurry skybox, I've enabled camera depth of field options
view->setDepthOfFieldOptions({ .cocScale = 3.0f, .enabled = true });
. However, when I useblending(MaterialBuilder::BlendingMode::FADE)
for the foreground material, it results in both the foreground and background being blurred. This doesn't happen with blending(MaterialBuilder::BlendingMode::MASKED), but I need to use the FADE mode to retain the original alpha mask instead of a binary one. How can I keep the background blurred while preventing the foreground from getting blurred when using the FADE blending mode?To Reproduce Steps to reproduce the behavior:
setDepthOfFieldOptions to true
view->setDepthOfFieldOptions({ .cocScale = 3.0f, .enabled = true });
load IBL and skybox
I adjust the blurriness of the background(skybox) by changing the aperture. To maintain consistent brightness despite these changes, I correspondingly alter the shutter speed and ISO values. However, using
blendingMode::FADE
for the material results in the foreground also appearing blurred, irrespective of the camera's focus distance. In contrast, when I useblendingMode::MASKED
, only the background becomes blurred.Expected behavior
I'm looking to ensure that my foreground material remains clear and only the skybox is blurred, despite using blendingMode::FADE, so that the alpha mask can be effectively used.
Screenshots
blendingMode::MASKED with blurred background. You can see that compositing is not clear because of binary mask.![masked_blurred_bg](https://github.com/google/filament/assets/107169111/f63b0f53-f085-462c-8034-61d46b11efdd)
blendingMode::FADE with clean background. You can observe a smoother compositing due to the alpha mask.![fade_not_blurred](https://github.com/google/filament/assets/107169111/aad0ec6b-9ba2-4c25-b9f0-8e13bca32034)
blendingMode::FADE with blurred background. You can see that the foreground is also blurred.![fade_blurred_bg](https://github.com/google/filament/assets/107169111/6c8a25f8-3a5a-4eda-96b0-50754e4aaf33)
Logs If applicable, copy full logs from your console here. Please do not use screenshots of logs, copy them as text, use gist or attach an uncompressed file.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context Add any other context about the problem here.