[2.2] Can't save PFG_R32_FLOAT texture to file

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
Gdlk
Halfling
Posts: 53
Joined: Mon Dec 05, 2011 9:43 pm

[2.2] Can't save PFG_R32_FLOAT texture to file

Post by Gdlk » Fri Mar 22, 2019 11:06 pm

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!
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4148
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 269
Contact:

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

Post by dark_sylinc » 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
0 x

User avatar
TaaTT4
OGRE Contributor
OGRE Contributor
Posts: 182
Joined: Wed Apr 23, 2014 3:49 pm
x 20

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

Post by TaaTT4 » Mon Mar 25, 2019 12:01 am

Use this library to deal with textures: DirectXTex
1 x
Senior game programmer at Vae Victis
Working on Racecraft

Gdlk
Halfling
Posts: 53
Joined: Mon Dec 05, 2011 9:43 pm

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

Post by Gdlk » Mon Mar 25, 2019 4:03 pm

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!
0 x

Gdlk
Halfling
Posts: 53
Joined: Mon Dec 05, 2011 9:43 pm

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

Post by Gdlk » Mon Mar 25, 2019 4:09 pm

TaaTT4 wrote:
Mon Mar 25, 2019 12:01 am
Use this library to deal with textures: DirectXTex
Thanks, I will try it
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 1075
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 92

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

Post by xrgo » Sun May 19, 2019 8:34 pm

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
0 x

Post Reply