[x3d-public] RenderedTexture support

Michalis Kamburelis michalis.kambi at gmail.com
Tue Jan 16 07:08:49 PST 2018


 2018-01-16 13:21 GMT+01:00 Andreas Plesch <andreasplesch at gmail.com>:
> Hi Michalis,
>
> oh, apologies, I had somehow overlooked the cubemap component
> documentation:
> https://castle-engine.sourceforge.io/x3d_implementation_cubemaptexturing.php
>
> It looks like ComposedCubeMapTextureNode does not take RenderedTexture
> as field values since RenderedTexture is not  derived from Class
> TAbstractTexture2DNode ?

It is also a consequence of our current implementation:

- ComposedCubeMapTexture is loading texture contents from normal
memory (RAM), always.
- RenderedTexture contents "live" only on GPU, they are never copied
to normal memory.

To enable using RenderedTexture as a side for ComposedCubeMapTexture
we would have to

1. grab RenderedTexture contents to normal memory (slow), only to
later load it to ComposedCubeMapTexture.
2. or copy texture contents from RenderedTexture to
ComposedCubeMapTexture side on the GPU (I'm not sure, but there's
probably some function for this).

> This is understandable since GeneratedCubeMapTexture is available.
>
> So I probably should try to implemenent GeneratedCubeMapTexture. All
> the pieces should be already there.
>
> An advantage of using ComposedCubeMap with rendered textures is that
> it is possible to only make a subset of the faces dynamic for
> increased efficiency. After all, each face needs a render of the
> scene.
>
> x3dom has a pingpong shader pass which may be helpful for recursive
> mirror effects.
>
> x3dom also generates a fbo for each rendered texture and I learned how
> to use it for the composed cubemap via gl.copyTexImage2D() which seems
> to work well. Does castle use another opengl function ?

We do not use glCopyTexImage2D. Instead, we're doing something more
efficient (as far as I know): we just use the OpenGL(ES) texture as an
attachment of FBO using glFramebufferTexture2D. In case of cubemap
texture, you can specify which side is attached.

This way, the rendered image goes straight to the (cubemap) texture,
without the need to perform any copy, even on GPU.

Regards,
Michalis



More information about the x3d-public mailing list