6
\$\begingroup\$

So, given a scene like this (cubemap skybox with "real" spheres)

enter image description here

Everything looks great, except for the fact that the spheres don't reflect each other.

What's a good way to go about this? The first thing that came to mind was to render an environment map for each cube, and apply that to each cube along with the skybox. However, that will be insanely slow when updated per frame, given that the spheres are moving relative to each other and a static map won't work.

I realize this may fall under the category of ray tracing and be difficult to achieve real-time, but perhaps someone has addressed this problem in the past?

\$\endgroup\$
10
  • \$\begingroup\$ Create a copy of the sky cube, and render one the spheres to this, and then use this cubemap for the spheres when looking up their reflections? \$\endgroup\$
    – Herp
    Commented Mar 19, 2014 at 14:26
  • \$\begingroup\$ @Herp Hmm - I'm not sure how that would work when the sphere's aren't nicely in a line like that. \$\endgroup\$
    – 3Dave
    Commented Mar 19, 2014 at 14:29
  • \$\begingroup\$ I think it would look nice actually, I think you overestimate the human ability to interpret visual data. Only 10%[citation needed] of the things you see is actual data from your eyeballs, the rest is your brain filling in the void. Your mind would make it look right, the same way it can trick you with optical illusions. \$\endgroup\$
    – Herp
    Commented Mar 19, 2014 at 14:34
  • \$\begingroup\$ I suppose you are aware that they will reflect light from one another an infinite number of times (like you said ray tracing). Imagine each photon in the scene is like a ball in a pool game. Now lets "fire" it back from the camera lens until it hits a surface. It may hit the balls dozens of times (considering it has no mass and the balls remain stationary during rendering). There was something about this in article with the creators of Portal. They said they wanted two facing portals to give the illusion of reflections of reflections but they used a flat surface so that would be easier. \$\endgroup\$
    – AturSams
    Commented Mar 19, 2014 at 14:35
  • 5
    \$\begingroup\$ Are spheres just an example, or are they the actual objects you want to render? If they're the actual objects, and there's not going to be too many of them, you could just do true raytraced reflections in the fragment shader. Spheres aren't that expensive to test for intersection. \$\endgroup\$ Commented Mar 20, 2014 at 2:37

1 Answer 1

6
\$\begingroup\$

You can use recursive Enivornment mapping (using cube maps) as follows. It is slow if you try to do it fully every frame however, the approximation is to use the previous frames output so it builds up the reflections over time (which will be unnoticeable given good frame rates). So you only need to process one extra frame's worth of data on each render.

Recursive reflections of curved objects in a scene can be performed using environment mapping [253, 849, 933]. For example, imagine a red and a blue mirrored ball some distance from each other. Generate an EM for the red sphere, then generate an EM for the blue while using the red sphere’s EM during its creation. The blue sphere now includes a reflection of the red sphere, which in turn reflects the world. This recursion should in theory go on for several steps (until we cannot make out any differences), but this is expensive. A cheaper version of this computes only one environment map per frame using the environment maps from the previous frame [360]. This gives approximate recursive reflections. Figure 9.46 shows some examples using this technique.

Akenine-Mo¨ller, Tomas (2012-02-22). Real-Time Rendering, Third Edition (Page 391). A. K. Peters. Kindle Edition.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .