Voxel rendering mode crashes with custom save callback

Hi,

Rendering in particle mode always seems to work but whenever I change the mode to voxel rendering KSR crashes. The logger says it is retrieving particles. No issues in particle rendering mode (voxel size and voxel filter length are both set to their respective default values, 1.0 and 0.5).

This only happens when a custom render save interface is used! It doesn’t have to do anything (only overloading save_render_data() which is empty), as soon as I set it with set_render_save_callback the render() call crashes in voxel mode.
Can you confirm this?

I shall check it out and see if I can reproduce the problem.

thanks.

Any update on this? Can you confirm it and is there a fix in sight?

Thanks for any info
Navié

I am unable to reproduce the crash you are seeing.

I tried writing a custom save callback, then setting voxel mode, and it did not crash for me.

Is there a snip of code you could send me that I can compile that shows the error?

Hi,

yes here is some code (stripped down to the problematic code):

[code]class Krakatoa_C4D_SaveHookEmpty : public krakatoasr::render_save_interface
{
public:
virtual void save_render_data
( int width
, int height
, int imageCount
, const krakatoasr::output_type_t* listOfTypes
, const krakatoasr::frame_buffer_pixel_data* const* listOfImages ) { }
};
[…]

krakatoasr::light* klight = new krakatoasr::point_light;
m_renderer.add_light(klight, MatrixToKrakatoa(t_light->m));
delete (klight);

Krakatoa_Effex_ParticleStream effex_stream(groups,types,t_settings);
krakatoasr::particle_stream particleStream = krakatoasr::particle_stream::create_from_particle_stream_interface( &effex_stream );
m_renderer.add_particle_stream( particleStream );

Krakatoa_C4D_SaveHookEmpty fileSaver;
//add the file saver to the m_renderer
m_renderer.set_render_save_callback( &fileSaver );
//Render
m_renderer.render();[/code]

The custom particle stream has only 6 particles without any extra information. Position only.
Remove the light being added and the voxel mode doesn’t crash anymore. Or remove the save hook and it works. Both in there always crash (once I call render()).

Thank you for the code. I will attempt to track down the problem from here.

I will be away for the coming week at the SIGGRAPH conference, so I apologize if my response is slow. Thanks in advance for your patience. I will try to get to the bottom of this problem for you.

Hi,

is there any news on the issue?

Thanks!

I have found a bug in the voxel code. I am working on a new build with a few fixes. I’ll post it as soon as it’s ready.

So, it turns out the code I fixed didn’t have anything to do with your bug.

I noticed one problem with the code you sent:
-Point lights are not supported by the voxel renderer.

Can you ensure that you are wrapping the “render” call in a try-catch block? You need to be catching the exceptions since error reporting is done using exceptions.

To help me further debug the issue, can you try modifying your code to this, then letting me know what is outputted:
The following code removes the point light, and wraps render in a try-catch block.

class Krakatoa_C4D_SaveHookEmpty : public krakatoasr::render_save_interface
         {
         public:
            virtual void save_render_data
               ( int width
               , int height
               , int imageCount
               , const krakatoasr::output_type_t* listOfTypes
               , const krakatoasr::frame_buffer_pixel_data* const* listOfImages ) { }
         };
[...]

krakatoasr::light*   klight   = new krakatoasr::spot_light; //NOTE: I changed this.
m_renderer.add_light(klight, MatrixToKrakatoa(t_light->m));
delete (klight);

Krakatoa_Effex_ParticleStream effex_stream(groups,types,t_settings);
krakatoasr::particle_stream particleStream = krakatoasr::particle_stream::create_from_particle_stream_interface( &effex_stream );
m_renderer.add_particle_stream( particleStream );

Krakatoa_C4D_SaveHookEmpty fileSaver;
//add the file saver to the m_renderer
m_renderer.set_render_save_callback( &fileSaver );
//Render
try {
    m_renderer.render();
} catch( std::exception& e ) {
    std::cout << "THIS IS THE ERROR: " << e.what() << std::endl;
}

Hi Conrad,

thanks for your reply (I didn’t get a reply email so I only noticed now). I tried it right away and it must have been the point light indeed that is crashing.
With the try catch block the exception is caught and I get the message about krakatoa not supporting point lights in voxel mode. With a spot light it seems not to crash at all, so I guess that was the issue which is great! (though I would expect Krakatoa not to crash on me anyway).

Thanks for sheding light on this (literally…).

Ah, I’m glad we got that sorted out.

If the renderer throws an exception, it is expected that your program will catch it and report it to the user. Such as this point light issue. Please be sure to always use a try-catch when starting a Krakatoa render, since that’s how we report error messages from the renderer. Technically all the Krakatoa API calls can throw exceptions, but in practice, just the “render” call will do so. If you are getting unexplained crashes, it may be because an exception went uncaught.

Hope this sorts everything out!

thanks for the info. Yes, customers report voxel mode is working now. :slight_smile: