1
\$\begingroup\$

I am trying to implement dynamic environment mapping in my OpengGL rendering engine for the purpose of showing reflections. I am following the tutorial found here. This tutorial (and many others that I have seen) focus' on static environment mapping where you already have a cubemap made from texture data.

From what I gather, to perform dynamic environment mapping you would perform the following steps:

create a single cubemap texture that we can reuse
for each mesh:
    render the scene 6 times (or once using geometry shader) to fill faces of cube map from the perspective of mesh
    sample cubemap to render reflections on mesh

or perhaps it should be:

for each mesh:
    create a cubemap texture for mesh
    render the scene 6 times (or once using geometry shader) to fill faces of cube map from the perspective of mesh

for each mesh:
    sample cubemap to render reflections on mesh (using this meshes cubemap)

My question is whether this is the right general idea? In particular do you need to render your scene to a cubemap for each mesh that you want to have dynamic reflections on? If so this would seem to be exceedingly expensive for any scene with more than a few meshes receiving dynamic reflections. The only examples/tutorials that I have seen involve only one mesh that uses dynamic environment mapping.

\$\endgroup\$
3
  • \$\begingroup\$ Neither, your game obviously won't be able to render the scene mesh count * 6 times, not even AAA games do that \$\endgroup\$
    – Bálint
    Commented Sep 21, 2017 at 6:54
  • \$\begingroup\$ @James, my approach would be to have one environment cubemap that gets used for all reflective objects. Every frame, you could gather the objects that need reflection, and probably restrict it to the ones that are close by and visible, and calculate some acceptable midway point. Render your cubemap from that location and use it on every object that required the reflections. It wouldn't be perfect, but depending on the game it might be acceptable. \$\endgroup\$ Commented Sep 21, 2017 at 7:00
  • \$\begingroup\$ @james you could also have cubemaps rendered from static locations (or static in relation to the player) that have lower resolutions the further they are. Then reflective objects can just use the closest cubemap. \$\endgroup\$ Commented Sep 21, 2017 at 7:02

0

You must log in to answer this question.

Browse other questions tagged .