I've managed to implement screen-space reflections into my forward renderer and now I've been trying to go the step further by rendering recursive reflections (i.e. reflections of reflections of reflections).
I've been trying to do this in a single-pass, by:
- rendering the camera view of a scene to a 2d texture in the first frame, then
- feeding this texture back into the same shader pass in the next frame, performing the SSR calculations in this shader pass using this texture.
- then adding the results to the original color results -> this is then rendered into the same 2d texture as Step 1 and the feedback loop continues.
Here are my results:
Several issues are immediately noticeable:
The most noticeable one on the screenshot above is that reflections within reflections become distorted.
I suspect that this is due to the normals used in the SSR calculations, which continually use the original normals of the scene, thus the higher order reflections are incorrectly using the normals of the base geometry (eg. look at the reflections on the floor).
I believe that a solution to this may be to reflect the normals as well and store this into a new texture - which would be used in every subsequent normal calculation of the SSR algorithm.
Another big problem, which you won't be able to notice in the screenshot above, is any movement that occurs in the scene will show a lag between the original color and the reflected color. This only happens when I feed the texture of the scene back into the scene in the same render pass. If I use two passes, then this doesn't occur, but then I won't get the advantage of the free recursive reflections. I guess this is because, using a single pass, the lag is because the renderer has to wait until all the other effect calculations, such as shadows, global illumination, etc, are completed.
I've also tried putting aside the recursive attempt by using a single reflection so that I can address some of the other issues.
The main issue is how to mask what the camera cannot see - at the moment these areas are black in the reflections because there is no information available in the captured scene from screen space because they are either occluded by other objects, or are outside of the view.
For the areas that are outside of the view, even if I use fade, they are still noticeable.