# Trouble Precomputing Cubemap from Equirectangular HDR

**URL:** <https://discourse.libcinder.org/t/trouble-precomputing-cubemap-from-equirectangular-hdr/808>\
**Category:** Using Cinder\
**Created:** [July 31, 2017, 11:54am UTC](https://discourse.libcinder.org/t/trouble-precomputing-cubemap-from-equirectangular-hdr/808 "2017-07-31T11:54:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Droojohnson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/droojohnson/32/398_2.png) [@Droojohnson](https://discourse.libcinder.org/u/Droojohnson)\
**Post date:** [July 31, 2017, 11:54am UTC](https://discourse.libcinder.org/t/trouble-precomputing-cubemap-from-equirectangular-hdr/808/1 "2017-07-31T11:54:05Z")

</div>

I posted a while ago about my troubles implementing the tutorials over at [learnopengl.com](http://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](https://learnopengl.com/#!PBR/IBL/Diffuse-irradiance)  
Here’s a link to the [source code on the learnopengl.com website](https://learnopengl.com/code_viewer_gh.php?code=src/6.pbr/2.1.1.ibl_irradiance_conversion/ibl_irradiance_conversion.cpp)  
Here’s a link to his [project directory on github](https://github.com/JoeyDeVries/LearnOpenGL/tree/master/src/6.pbr/2.1.1.ibl_irradiance_conversion)

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.

---

<div class="post-metadata">

**Author:** ![notlion](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/notlion/32/11_2.png) [@notlion](https://discourse.libcinder.org/u/notlion)\
**Post date:** [July 31, 2017, 9:15pm UTC](https://discourse.libcinder.org/t/trouble-precomputing-cubemap-from-equirectangular-hdr/808/2 "2017-07-31T21:15:02Z")

</div>

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:

> **[Converting an Equirectangular Panorama to Cubic Faces](http://vinayhacks.blogspot.com/2010/11/converting-equirectangular-panorama-to.html)**
>
> I wanted to convert some equirectangular panoramas (spherical panoramas) to 6 cubic faces (see the images below for an example). After exper...

---

<div class="post-metadata">

**Author:** ![paul.houx](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/paul.houx/32/31_2.png) [@paul.houx](https://discourse.libcinder.org/u/paul.houx)\
**Post date:** [July 31, 2017, 11:00pm UTC](https://discourse.libcinder.org/t/trouble-precomputing-cubemap-from-equirectangular-hdr/808/3 "2017-07-31T23:00:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Droojohnson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/droojohnson/32/398_2.png) [@Droojohnson](https://discourse.libcinder.org/u/Droojohnson)\
**Post date:** [August 1, 2017, 2:47am UTC](https://discourse.libcinder.org/t/trouble-precomputing-cubemap-from-equirectangular-hdr/808/4 "2017-08-01T02:47:12Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![phil](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@phil](https://discourse.libcinder.org/u/phil)\
**Post date:** [August 1, 2017, 4:36am UTC](https://discourse.libcinder.org/t/trouble-precomputing-cubemap-from-equirectangular-hdr/808/5 "2017-08-01T04:36:06Z")

</div>

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](https://github.com/simongeilfus/Cinder-Cmft) that wraps cmft, and you can use it to easily do the conversion as well as generate radiance map.
