Trouble Precomputing Cubemap from Equirectangular HDR

I posted a while ago about my troubles implementing the tutorials over at learnopengl.com using cinder, and I’ve powered through a lot of them since. I’m stuck on one lesson in particular though.

https://learnopengl.com/#!PBR/IBL/Diffuse-irradiance
Here’s a link to the source code on the learnopengl.com website
Here’s a link to his project directory on github

I can render the skybox into the scene on a unit-sized geom::Cube() but everything after that point fails using both the code provided, and after my attempts to use Cinder’s various OpenGL ref classes. Has anyone done something similar to this? I found a cinder project that recalculates a cubemap every frame to allow for dynamic reflections, but that project didn’t convert an Equirectangular HDR texture into a cubemap at runtime, and the skybox in that project was also just a regular texture instead of an HDR. I don’t know if that makes much of a difference, but it seems important?

As of right now, I can build the application without errors, but the only thing that is being drawn to the screen is the dim teal color that is being used gl::clear(); every frame. Nothing else gets drawn, that I can see. I’ve tried to save out the contents of the captureFBO FboCubeMap but I can’t figure out how to get writeImage() to accept that FboCubeMap as an input… I’m very stuck.

If no one has tackled this lesson, I’d appreciate any pointers, and I’ll try to clean up my code later today if I have the chance (lots of experimentation in hopes of fixing my implementation has resulted in giant chunks of commented-out code and hacky workarounds that make it pretty unreadable) and throw it onto github if anyone feels like taking a look.

Hmm. Are you just looking to do the conversion as a preprocess? If so, I’ve used Hugin for that before and it works quite well:

Instead of a cube, you could try using a sphere. That way you don’t need to convert the HDR texture.

I’m trying to avoid using an already-built application, even if it’s just a command line interface, so I can learn the concepts in the tutorial, but if it continues to evade me I’m glad I have the option, @notlion!

@paul.houx I’ll give that a try tomorrow. I’m a little concerned that I won’t be able to perform any of the convolution I need to without some of OpenGL’s cubemap-specific features, like seam removal and whatnot, but I’ll tackle that issue when I come to it. Thanks for the suggestion!

Hi @Droojohnson,

What’s shown in the tutorial seems to be the most straightforward way of converting equirectangular images into cubemaps, however it could be tricky to implement in Cinder. @Simon has written a nice block Cinder-Cmft that wraps cmft, and you can use it to easily do the conversion as well as generate radiance map.

1 Like