roberto.voxelfarm Posted September 4, 2019 Share Posted September 4, 2019 (edited) Hello, I try to load a RAW texture that I have in DTX1 format. I don't found a way to load a RAW texture. I try to load as image but log an error loading int format = ::Unigine::Image::FORMAT_DXT1; ::Unigine::ImagePtr image = ::Unigine::Image::create(); image->create2D(textureSize, textureSize, format); const ::Unigine::Ptr<::Unigine::Blob> stream = ::Unigine::Blob::create(); stream->write(textureData, textureLen); // textureData=RAW DTX1 Buffer, textureLen=size image->load(stream->getStream()); /roberto Edited September 4, 2019 by roberto.voxelfarm Link to comment
silent Posted September 4, 2019 Share Posted September 4, 2019 Hi Roberto, What exact error do you have? Could you please also send us a dds texture that you are using for testing? Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
roberto.voxelfarm Posted September 4, 2019 Author Share Posted September 4, 2019 (edited) Thank you Silent, The error is "ImageFileDDS::read_header(): wrong magic 0x0" I know that the texture not is a DDS image file, is just a RAW DXT1 buffer, and for that is the error. For sample Unity have this function that allow to load Raw texture Texture2D texture = new Texture2D(textureSize, textureSize, format, hasMipmaps, linear); texture.LoadRawTextureData(textureData); Is any possibility to load a RAW texture here like unity do?. or convert this to DDS format directly from the buffer or the streaming. best regards /roberto 6.rawTex Edited September 4, 2019 by roberto.voxelfarm Link to comment
andrey-kozlov Posted September 5, 2019 Share Posted September 5, 2019 Hello Roberto, There is no built-in serialization/deserialization of raw formats in the engine. Consider using DDS. To work with a raw format you could allocate image of certain size and format with create2D and then put data directly to allocated memory with memcpy(image.getPixels(), data, size). Also to read from blob after write it should be reset to the beginning with blob->seekSet(0). 1 Link to comment
roberto.voxelfarm Posted September 10, 2019 Author Share Posted September 10, 2019 Thank you andrey, This solution work perfect. /Roberto Link to comment
sweetluna Posted December 6, 2019 Share Posted December 6, 2019 Hi Roberto, For what purpose you need such a texture? Is it CPU only or GPU might be useful too? Image class is used for CPU representation of texture data, while Texture class is used to represent GPU side texture data. Thanks! May RenderDoc/Nsight Graphics/Intel GPA bless you Link to comment
Recommended Posts