How to get the colorTexture of the scene

I want to use the colorTexture of the scene (not in the post-processing stage). I know that the depth map of the scene can be obtained through czm_globeDepthTexture. Then, is there a way to get the colorTexture of the scene ?

Whether it exists in a FrameBuffer, then use frameBuffer.getColorTexture to obtain it ?

This is very much not a part of the public API, so I can’t confirm the following info won’t change in the future. :slight_smile:

  1. Create a new Texture instance to store the texture info
  2. Get you can access the current framebuffer for the scene with scene._defaultView.passState.frameBuffer.
  3. Use Texture.copyFromFramebuffer to put the framebuffer content into the texture, as is done in this prototype example.

It will also be important to call the copy function at the current time— immediately following a render pass.

Out of curiosity, what are you working on?

I would like to follow up on this as I am also interested in getting some data directly from the frameBuffer. I have the following questions:

  • is czm_globeDepthTexture only available in prostProcessing stages? I use it successfully there but can not access it in a material fragment shader.
  • Instead, can I retrieve depthTexture from the framebuffer in a way similar to the one you described above?
  • Is there, anywhere in the “undocumented” API, a way to retrieve the colorTexture of the globe before anything else was drawn on top (models, billboards, etc.)

Thanks

Never mind, I just found that I could use:

scene._view.pickDepths[0]._framebuffer._framebuffer._bind()

and then depthTexture.copyFromFramebuffer();

Sorry for the disturbance.

It would be nice to get a bit more info about all these nice undocumented and hidden features :wink:

Sorry to be banging on about this but:

When using scene._view.pickDepths[0]._framebuffer._framebuffer from the default renderLoop, I get the previous frame depthBuffer when I actually want the current depthBuffer. (I tried to fetch it at preUpdate, postUpdate, preRender, etc. to the same result)

I pass the depthBuffer copied texture to a globeMaterial as a uniform but I noticed the delay between current fragment positions and the depthBuffer I copied.

Based on @Gabby_Getz previous comment, I looked into scene._defaultView.passState.frameBuffer but I believe it is already cleared (I read undefined) when accessing it from the renderloop.

Any pointer on how to best achieve this (getting current depthbuffer in globe material) ? Can this be achieve with what already exist or do I have to create my own drawCommand, etc.?

Thanks for any help.