Skip to content
Thin wrapper around Cmft for use with Cinder
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Cubemap Filtering Tools for Cinder based on cmft.

See cmft repository for more information.

The block is roughly organised around two types of functions; Convenient functions to load, filter and cache environment maps as cinder::gl::TextureCubeMapRef:

// create the skybox, radiance and irradiance environment map
// this will by default cache and for
// a much faster initialization on the next run
gl::TextureCubeMapRef	mPmrem, mIem, mEm;

auto imgPath	= getAssetPath( "env.hdr" );
mEm				= cmft::createTextureCubemap( imgPath );
mPmrem			= cmft::createPmrem( imgPath, 256 );
mIem			= cmft::createIem( imgPath, 64 );

And conversion and helpers functions to interface directly between cmft::Images and cinder::Surfaces and cinder::gl::TextureCubeMaps :

// load an image with cinder and convert it to a cmft::Image
auto surface = Surface( loadImage( loadAsset( "env_cross.exr" ) ) );
auto input = cmft::surfaceToImage( surface );

// prepare the output cmft::Image
cmft::Image output;
cmft::imageCreate( output, dstFaceSize, dstFaceSize, 0xff0000ff, 1, 6, cmft::TextureFormat::RGB32F );

// apply an sh irradiance filter
cmft::imageApplyGamma( input, 2.2f );
cmft::imageIrradianceFilterSh( output, dstFaceSize, input );
cmft::imageApplyGamma( output, 1.0f / 2.2f );

// convert the cmft::Image to a gl::TextureCubeMap
gl::TextureCubeMapRef cubemap = cmft::createTextureCubemap( output );

// release cmft image memory
cmft::imageUnload( input );
cmft::imageUnload( output );

Screenshots from the demo app (material made with Substance Designer and HDR Envmaps from NoEmotionHDRs) :


Screenshots from custom environment sample :


You can’t perform that action at this time.