3
\$\begingroup\$

I understand how reflections work for objects. A cubemap would be rendered around a certain point in 3D space, usually at the center of the object that the reflection is to be applied to, and that is the surrounding world it reflections.

But this leads to the question, what about large flat surfaces like floors and walls? If you're only rendering the cubemap from a single point in 3D space, reflections only work for a small area around this. If you walk down the hall and look at the same floor, the reflections would make no sense at all.

How are large, flat surfaces reflected?

\$\endgroup\$
5
\$\begingroup\$

For large flat surfaces (water, floors, etc) there is this approach:

  1. Scale everything (geometry, camera, lights, etc) upside-down across reflection plane;
  2. Clip geometry left above the reflection plane;
  3. Render to texture;
  4. Render everything as usual except the reflective plane surface;
  5. Render reflective plane with reflections texture applied to it (blending/shading/distorting it as needed).

If you don't need any shader effects, it is also viable to just render the upside-down geometry stenciled by visible reflective plane area.

Here's a diagram of how it works (from this excellent GLSL tutorial):

enter image description here

\$\endgroup\$
  • \$\begingroup\$ How does it render to texture if the viewing angle is unknown? Does this have to be done every frame? \$\endgroup\$ – Keavon Oct 6 '14 at 5:09
  • \$\begingroup\$ What do you mean? Viewing angle is known, it's the same one from camera direction just flipped upside down across the reflection plane. It needs to be done every frame, yes (or every N frames if you are okay with that, or just when something changes significantly). Also texture resolution can be smaller if you care about performance. \$\endgroup\$ – Kromster says support Monica Oct 6 '14 at 5:12
  • \$\begingroup\$ I meant that the viewing angle is not known ahead of time so it has to be rendered in real time rather than ahead of time as allowed by cubemap reflections. Note that you can remove the first sentence because I edited the question. \$\endgroup\$ – Keavon Oct 6 '14 at 5:20
  • \$\begingroup\$ Edited. As said, if you don't need fancy shader effects, you can get away with duplicate flipped geometry being generated only once at level start and stenciling where it will be seen. Honestly though, I did reflective water shader not so long ago and it did not impact the performance as much as I was afraid it would, cos upside-down scaling can be done in shader too, which is really fast. You can also drop many effects that wont be noticeable in the reflection (bump maps, etc) \$\endgroup\$ – Kromster says support Monica Oct 6 '14 at 5:25
  • 1
    \$\begingroup\$ In at least one title I've seen there was actually a super low LOD version of the geometry that could be seen in water puddles and whatever that was built upside down and the reflective surface was just an empty hole. No second rendering pass. It's definitely a dated technique, doubt if it's useful at all nowadays. \$\endgroup\$ – Patrick Hughes Oct 6 '14 at 5:31
2
\$\begingroup\$

A reflected image is placed on the mirror by first rendering the reflection image using a reflected camera on the other side of the mirror, and then combining the reflection image with the scene image.

The steps of this procedure are as follows:

Reflect the camera to the other side of the mirror surface.
Modify the scene model by removing the reflecting surface and other surfaces that block the view of the reflected camera.
Render the reflection image.
Convert the reflection image into a reflection texture map.
Apply a suitable shader to the reflecting surface; this shader uses the reflection texture to simulate the reflections. 

refer the below link for more details https://renderman.pixar.com/resources/RPS_13.5/prman_technical_rendering/AppNotes/appnote.6.html

\$\endgroup\$
1
\$\begingroup\$

I'm not much of a programmer, but since I did lots of researches around the kind of elements you find in background (as I'm having a blast at making video game backgrounds), I had to understand the behavior of the cubemap reflections.

On the basic, the cubemap reflection all work in a single way : the render processor (camera) is able to render up to a circular 180x180 degrees of a 360x360 cubemap. So, if you see the cubemap from a single point of view, you can see up to 5 of the 6 maps from which the cubemap is made of.

That said, there are 3 kinds of cubemap reflections : Predetermined cubemap reflection (mapped) // Real-time Light procedural // Real-time Procedural projection : and each have a different way of working, giving results and being managed.

The predetermined cubemap reflection is pretty much the same thing as a skybox on which a mask is applied which is calculated from the specular value of the material's map. On your example of a large flat surface, this would end up as a big view of the reflected cubemap over the part that have a high amount of specular. On a large surface without any area with low specular value, it would look like a reflection of a picture. (Not really good) This is commonly used on things like windows to simulate cloud/sky reflection in them.

Real-time light procedural is a process on which a initial cubemap is used which act as a kind of specular color, but on which an additional additive layer is added based on the projected lights around its surface. This is the actual best way of simulating heavily transparent glass and metals. There are no "real" reflection as every light reflected are calculated from a single ray projection (which is done naturally from the light in 3D scene) So, for example, if you uses a light with a mask over it, the mask won't appear on the reflecting surface. On the given example of a huge flat surface, it would look good as long as there are no lights too close to it (from the camera view). Otherwise, the light "projected" will seems too bright.

Real-time procedural reflection is actually the thing which is closer to the real mirror reflection. It's a reflection process that involve an additional render process (hidden camera) which project what its seeing onto the meshes with the material. There are 3 main problem with this system. Problem #1 is that you need 1 different material per meshes and, so, 1 generated hidden camera. Otherwise, you'll end up with the same reflection point of view on all the meshes). Problem #2 is the it's highly costy on the performance. #3 is that the reflection might be of poor quality or not include any camera filter you might be using like Anti-aliasing, blur, dynamic fog, etc. Best example of this one is for water and mirror reflections.

Those are 3 different ways of using the cubemap reflection and have different uses.

For your example of a huge hall with the reflective floor, those are the final result you'll end up with :

With the simple cubemap reflection : you'll have a view similar as if the floor was made of glass with a skybox under it. Big issue is if you have multiple room with the same floor. This would require multiple cubemap reflection materials.

With the Real-time Light procedural, you'll have a view as if the floor was made of metal, plastic or any materials that doesn't reflect much detail, yet have a high amount of light reflected. Unlike the regular specular channel, this one actually apply spot-like light effects on the meshes faces. Since there are no "reflected object" and since the light projected are procedural, you can use the material multiple time without any change nor adjustment.

For a Real-time Procedural projection, you get high fidelity result. The amount of material using this process should be reduced to a minimal. For example, the game Watchdog from Ubisoft make uses of it for things like the streets' water ( http://media1.gameinformer.com/imagefeed/featured/E32012/Ubisoft/watchdogs/WatchDogs1.jpg ) In this screenshot, you can see the reflection of the city which is created in real-time based on the point of view of the camera. While it look awesome, you might also notice that nothing else uses the same kind of reflection. Simply put, it's because it's actually a procedural (Substance Designer) layer on the material which project the pixels shown from a hidden secondary camera which is created from the collision of a raycast shot by the camera in real-time. (In other words, having that reflection is similar, in CPU and GPU, as having 2 player playing on the same screen)

Might not be what you wanted to know (or too much), but I hope this will help you understand how vaste the cubemap reflection is and how it works.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.