Possible memory leak in HDR background materials

A forum for exporter development discussion.
Post Reply
2 posts • Page 1 of 1
Daniel
Posts: 13
Joined: Tue Mar 01, 2016 2:32 am

Possible memory leak in HDR background materials

Post by Daniel » Fri Jan 26, 2018 3:15 am

Hi again,

We have a standalone framework which integrates the Indigo SDK to open our own file format, build a Indigo scene and render images - this is working nice and smooth, no errors or complaints when compiling and running from Visual Studio 2017. It is essentially a static lib which contains our file parser, convenience functions and stuff and runs the Indigo .dll in the background. Using it standalone it is launched and handled from our own software.

Now we are working on receiving Indigo renderings within the Unreal Engine, using the same static library as the standalone tool. The Unreal engine / editor seems to be very picky concerning memory leaks, this is where we have a problem now:

I can render an empty scene (skylight, basic camera, no geometry) and receive the images, so the framework itself is working. As soon as I set an HDR image in the background settings node Unreal breaks on an error regarding a corrupted heap. I can continue the execution and receive the correct rendered images. There are more errors when adding geometry, but for the moment I'd like to track down this one:

Here's where I load the HDR image, it's pretty similar to the example code in the SDK:

Code: Select all

Indigo::Texture emission_texture;
emission_texture.path = environment_info.hdr_filepath.c_str();
emission_texture.exponent = pow(environment_info.contrast, CONTRAST_EXP);
emission_texture.tex_coord_generation = new Indigo::SphericalTexCoordGenerator(environment_rotation);

// ==== MATERIAL
Reference<Indigo::DiffuseMaterial> environment_hdr_material = new Indigo::DiffuseMaterial();
environment_hdr_material->name = "Environment HDR";
environment_hdr_material->albedo = new Indigo::ConstantWavelengthDependentParam(Reference<Indigo::Spectrum>(new Indigo::UniformSpectrum(0)));
environment_hdr_material->emission = new Indigo::TextureWavelengthDependentParam(emission_texture);

double temperature = environment_info.whitebalance;
double gain = 1.0;
environment_hdr_material->base_emission = new Indigo::ConstantWavelengthDependentParam(new Indigo::BlackBodySpectrum(temperature, gain));
environment_hdr_material->backface_emit = true;

background_settings_node->background_material = environment_hdr_material;

//================ Emission scale ================
double exposure = EXPOSURE_SCALE * pow(environment_info.exposure, EXPOSURE_EXP);
background_settings_node->emission_scale = new Indigo::EmissionScale(Indigo::EmissionScale::Measure::LUMINANCE, exposure, new Indigo::SceneNodeMaterial());


If I uncomment the following line it works (it's using the default skylight background then that I add as default earlier):

Code: Select all

background_settings_node->background_material = environment_hdr_material;

The engine breaks later when I initialize the Indigo renderer with the scene (InitializeWithScene(...)). the debug message refers to ntdll.dll but without further details.


Is it possible that there's a memory leak when handling HDR images in the renderer during initialization?

Daniel
Posts: 13
Joined: Tue Mar 01, 2016 2:32 am

Re: Possible memory leak in HDR background materials

Post by Daniel » Fri Jan 26, 2018 11:57 pm

Hey again,

I've been digging deeper into the other errors when I load gemoetries and materials and discovered that Unreal breaks again, always when I load a texture into the materials.

Here's where I set the texture, but again this is just basic stuff and probably not error-prone.

Code: Select all

Indigo::Texture texture;
texture.a = 0;
texture.b = 1;
texture.c = 0;
texture.exponent = 1.0;
texture.path = Indigo::String( filepath.c_str());
texture.tex_coord_generation = new Indigo::UVTexCoordGenerator();
this->phong_material_diffuse->diffuse_albedo = new Indigo::TextureWavelengthDependentParam(texture);
this->phong_material_specular->specular_reflectivity = new Indigo::TextureWavelengthDependentParam(texture);


I assume there's something about the way Indigo handles textures. Not even saying there's a bug or really something wrong, but at least something is happening that causes Unreal to throw an error / break referring to heap-problems.

Any ideas?

Post Reply
2 posts • Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest