[2.2] Can't save PFG_R32_FLOAT texture to file

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
Gdlk
Halfling
Posts: 53
Joined: Mon Dec 05, 2011 9:43 pm
x 1

[2.2] Can't save PFG_R32_FLOAT texture to file

Post 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!
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5299
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

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

Post 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
User avatar
TaaTT4
OGRE Contributor
OGRE Contributor
Posts: 267
Joined: Wed Apr 23, 2014 3:49 pm
Location: Bologna, Italy
x 75
Contact:

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

Post by TaaTT4 »

Use this library to deal with textures: DirectXTex

Senior programmer at 505 Games; former senior engine programmer at Sandbox Games
Worked on: Racecraft EsportRacecraft Coin-Op, Victory: The Age of Racing

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

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

Post 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!
Gdlk
Halfling
Posts: 53
Joined: Mon Dec 05, 2011 9:43 pm
x 1

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

Post by Gdlk »

TaaTT4 wrote: Mon Mar 25, 2019 12:01 am Use this library to deal with textures: DirectXTex
Thanks, I will try it
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

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

Post 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
Post Reply