When rendering to 3D texture using RTM_bind_layered, I have no issue with the aux attachments. However, when trying to use the main color attachment, no valid data is stored in the texture in any layer but no errors are reported.
I’m not sure if it is a bug or a limitation though, but as far as I understand OpenGL spec this should be allowed. The only thing I could find in the code / doc is that it’s not possible to use RTM_bind_layered with target that will be copied.
The current workaround for me is to bind a dummy texture to the color attachment (as otherwise Panda3D builds a framebuffer with no color attachment 0, which is rejected by OpenGL) and shift the shader output layout.
I attached a demo code, which tries to fill the main color attachment with a solid green color and the first aux attachment with a solid blue color. Only the aux attachment is filled with blue, and when looking at the dumped files, only the aux attachment has the right content.
The last-rendered slice does, in fact, have the correct colour, but the other slices don’t.
I think what’s happening is that there is a clear color applied by default to the color bitplane. This will clear all layers every time you do a render pass. (I think this is the right behaviour as the main use of layered rendering is to render all layers at once - and besides, Panda can’t possibly know what layer your shader is going to write to.)
So, just disable the clear color, and it should work.
That was the problem I did call disable_clears() on the display region, but not on the render buffer ! And so it was “cleared” with a random value.
If I don’t call disable_clears() the texture is cleared with LVecBase4d(0.41, 0.41, 0.41, 0) unless I explicitly call set_clear_color(LColor(0, 0, 0, 0)) and I have no idea where this value comes from!