Here I will try to provide more details on how I see True Reflections to be implemented with multipass rendering.
True Reflections can be implemented two ways:
- using PBuffers and render-to-texture, and
- using render-to-framebuffer and call glCopyTexImage2D(…) afterwards.
First, we should understand the general concept of multipass rendering that I propose to implement in Xith3D. The basic idea behind this concept is that we want to create rendering schema once and then minimize manual control over rendering.
I suggest to introduce new RenderingPass object that will contain all the information needed to set up and perform rendering for this pass:
a) Rendering Target (complete frame buffer, color buffer or specific color plane, depth buffer, texture, etc);
b) View transform associated with this pass;
c) Projection matrix;
d) Sorting mode;
e) Enabled status;
f) Other relevant information.
In the View, we will build a list of rendering passes, that will define a set of passes to perform and order of their execution.
In every Node (Shape3D or Group) we will maintain a set of RenderingPass objects where specific Node should be rendered (can be BitSet, or true Set).
To implement True reflections with TextureCubeMaps, we will have to create 7 groups of passes (6 groups for CubeMap, and 1 group for actual View rendering). Each group will contain 2 passes if we have transparent objects, and 1 pass if we don’t.
Then we will introduce new kind of ImageComponent2D, which will be acting as a target for RenderingPass, and use it to texturize objects on which we want to render reflections from other objects in the scene (target objects). We associate all objects, except target objects, with all 7 groups of passes, and associate target objects only with actual view rendering pass.
This is just approx. exmplanation, of course if should be discussed/described in more details.
Alternative solution may be in introducing alternate Canvas3D/View/etc. wich will be capable of rendering to texture and then manually control when we want to render to texture.
I don’t see any reason why we can not have both approaches implemented.
Yuri