Page 1 of 1

[2.2] Can't save PFG_R32_FLOAT texture to file

Posted: Fri Mar 22, 2019 11:06 pm
by Gdlk
Hi!

I am trying to save a texture with pixel format PFG_R32_FLOAT to file, but it crash. If I change the format to PFG_RGBA8_UNORM, it works fine. I think I am missing something, but I can't find what. The code is:

Code: Select all

        Ogre::TextureGpu* displaceTex = <a_valid_gpu_texture>

        Ogre::Image2 image;
        image.convertFromTexture( displaceTex, 0, 0 );

        Ogre::Image2 img2dView;
        img2dView.loadDynamicImage( image.getData( 0 ).atFromOffsettedOrigin( 0, 0, 0 ),
                                    image.getWidth(), image.getHeight(), image.getDepthOrSlices(),
                                    Ogre::TextureTypes::Type2D, image.getPixelFormat(), // <---- image pixel format is Ogre::PixelFormatGpu::PFG_R32_FLOAT. If here I change manually to PFG_RGBA8_UNORM the save works.
                                    false, 1u ); 
        img2dView.save( "./Captures/test.png", 0, 0  ); //<---- crash here
        
Any idea what could be?

Thanks!

Re: [2.2] Can't save PFG_R32_FLOAT texture to file

Posted: Sun Mar 24, 2019 6:07 am
by dark_sylinc
Hi!

PNG does not support R32_FLOAT formats. Do you know if 2.1 behaved differently? What is the crash' full callstack?

Unfortunately DDSCodec2::encodeToFile hasn't been ported yet to 2.2; and I don't know if there is another codec that would support such thing.

Cheers
Matias

Re: [2.2] Can't save PFG_R32_FLOAT texture to file

Posted: Mon Mar 25, 2019 12:01 am
by TaaTT4
Use this library to deal with textures: DirectXTex

Re: [2.2] Can't save PFG_R32_FLOAT texture to file

Posted: Mon Mar 25, 2019 4:03 pm
by Gdlk
dark_sylinc wrote:
Sun Mar 24, 2019 6:07 am
Hi!

PNG does not support R32_FLOAT formats. Do you know if 2.1 behaved differently? What is the crash' full callstack?

Unfortunately DDSCodec2::encodeToFile hasn't been ported yet to 2.2; and I don't know if there is another codec that would support such thing.

Cheers
Matias
I don't know if 2.1 was different. The callstack is:

Code: Select all

1   Ogre::FreeImageCodec2::copyData         TerrainEditorDev          0x7ff6773cc44a 
2   Ogre::FreeImageCodec2::encodeBitmap     TerrainEditorDev          0x7ff6773cc04b 
3   Ogre::FreeImageCodec2::encodeToFile     TerrainEditorDev          0x7ff6773ccc31 
4   Ogre::Image2::save                      TerrainEditorDev          0x7ff67702aeef 
5   TerrainEditor::updateGraphics           TerrainEditor.cpp     167 0x7ff676960a65 
... <More> 
  


I will try other formats.

Thanks!

Re: [2.2] Can't save PFG_R32_FLOAT texture to file

Posted: Mon Mar 25, 2019 4:09 pm
by Gdlk
TaaTT4 wrote:
Mon Mar 25, 2019 12:01 am
Use this library to deal with textures: DirectXTex
Thanks, I will try it

Re: [2.2] Can't save PFG_R32_FLOAT texture to file

Posted: Sun May 19, 2019 8:34 pm
by xrgo
TaaTT4 wrote:
Mon Mar 25, 2019 12:01 am
Use this library to deal with textures: DirectXTex
Thank you this also helped me =)
viewtopic.php?f=25&t=95048&p=545082#p545082