WebGLRenderer: Fix feedback loop in transmission pass for WebGL 2. #26177
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed #25990.
Description
#25502 introduced a feedback loop during the back-side transmission pass since the active render target is equal to the texture which is assigned to
transmissionSamplerMap
. The feedback loop produces a WebGL warning but also the result of the back-side pass is missing in the render target (so the transmissive surface looks like before #25502 was added). The warning looks like so:This issue does not pop-up when
antialias
is set totrue
which is why the issue was overlooked initially. This happens because settingantialias
totrue
means the transmissive render target is multisampled. Multisampled render targets do have more than one framebuffer so using it as the active render target and as a texture does not produce a feedback loop.Solving this issue without multisampling is difficult because you need a separate code path that copies the contents of the transmissive render target via
copyTexSubImage2D()
into a texture and then uses it as the value fortransmissionSamplerMap
. When trying to get this to work, I have realized this will noticeably increase the code complexity with unclear performance implications (since you have to callcopyTexSubImage2D()
two times insiderenderTransmissionPass()
).For simplicity reasons, I suggest to always use a multisampled render target for the transmission pass when using WebGL 2 which fixes the issue.