Added ETC1 support to GLES2
-
Wolfmanfx
- OGRE Team Member

- Posts: 1525
- Joined: Fri Feb 03, 2006 10:37 pm
- Location: Austria - Leoben
- x 100
Added ETC1 support to GLES2
I have added ETC1 support here (PKM CODEC)
https://bitbucket.org/wolfmanfx/ogre/ch ... 57988f187e
i tested it with a pkm texture which were generated with the etc1tool. ETC1 do not support an alpha channel and mipmap generation is disabled atm.
The test device was a tegra2 so i would be happy if you guys could test it - this should also work on iOS.
best regards
https://bitbucket.org/wolfmanfx/ogre/ch ... 57988f187e
i tested it with a pkm texture which were generated with the etc1tool. ETC1 do not support an alpha channel and mipmap generation is disabled atm.
The test device was a tegra2 so i would be happy if you guys could test it - this should also work on iOS.
best regards
-
oiram
- Halfling
- Posts: 87
- Joined: Sun Dec 13, 2009 5:06 am
- x 6
Re: Added ETC1 support to GLES2
Great work!
I have added KTX support base on it, and it was tested that works fine.
https://sourceforge.net/tracker/?func=d ... tid=302997
And will you review these?
I have added KTX support base on it, and it was tested that works fine.
https://sourceforge.net/tracker/?func=d ... tid=302997
And will you review these?
-
Wolfmanfx
- OGRE Team Member

- Posts: 1525
- Joined: Fri Feb 03, 2006 10:37 pm
- Location: Austria - Leoben
- x 100
-
oiram
- Halfling
- Posts: 87
- Joined: Sun Dec 13, 2009 5:06 am
- x 6
Re: Added ETC1 support to GLES2
Waiting for your good news.
-
Wolfmanfx
- OGRE Team Member

- Posts: 1525
- Joined: Fri Feb 03, 2006 10:37 pm
- Location: Austria - Leoben
- x 100
Re: Added ETC1 support to GLES2
Just checked it and it seems so that you just load the image but not the compressed mips.
-
oiram
- Halfling
- Posts: 87
- Joined: Sun Dec 13, 2009 5:06 am
- x 6
Re: Added ETC1 support to GLES2
Yes, I just load the image.
Load the compressed mips for ETC1Codec is the next thing we must to do.
Here is sample code:
http://www.khronos.org/opengles/sdk/tools/KTX
Load the compressed mips for ETC1Codec is the next thing we must to do.
Here is sample code:
http://www.khronos.org/opengles/sdk/tools/KTX
Last edited by oiram on Tue Jul 31, 2012 4:46 am, edited 1 time in total.
-
oiram
- Halfling
- Posts: 87
- Joined: Sun Dec 13, 2009 5:06 am
- x 6
Re: Added ETC1 support to GLES2
Ah, another thing, this is your code:
@RenderSystems/GLES2/src/OgreGLES2PixelFormat.cpp
my update code:
use "GL_OES_compressed_ETC1_RGB8_texture" replace "OGRE_NO_ETC1_CODEC == 0", am I right?
@RenderSystems/GLES2/src/OgreGLES2PixelFormat.cpp
Code: Select all
#if OGRE_NO_ETC1_CODEC == 0
case PF_ETC1_RGB8:
return GL_ETC1_RGB8_OES;
#endif
...
lalalala...
Code: Select all
#if GL_OES_compressed_ETC1_RGB8_texture
case PF_ETC1_RGB8:
return GL_ETC1_RGB8_OES;
#endif
...
lalalala...
-
oiram
- Halfling
- Posts: 87
- Joined: Sun Dec 13, 2009 5:06 am
- x 6
Re: Added ETC1 support to GLES2
I've done.
Here is the KTX file structure from http://www.khronos.org/opengles/sdk/too ... ormat_spec:
I found the PVRTexLib of imgtech save incorrect KTX file that missed "UInt32 imageSize;" before every MIPMaps level compressed pixel data.
Mali GPU Texture Compression Tool is corrected.
Another issue with your original code:
@OgrePixelFormat.cpp
Because the min texture width/height of ETC is 4, that means 4x4, 2x2, 1x1 MIPMaps image size are same as 8 bytes.
Basically, 8 bytes is the minimum texture size. Smaller textures are padded up to 8 bytes.
Here is new code:
And, when I verify MIPMaps with OpenGL ES2 rendersystem, I found texture filtering must set to trilinear. If filtering set to bilinear, only MIPMap level 0 is used.
For verify this issue, I make red colour to MIPMap level 0 and make blue colour to level 1, and zoom in/out camera for observed.
D3D and OpenGL are both correct, it's an issue only with OpenGL ES2. I think maybe something wrong with it.
coded attached.
Here is the KTX file structure from http://www.khronos.org/opengles/sdk/too ... ormat_spec:
Code: Select all
Byte[12] identifier
UInt32 endianness
UInt32 glType
UInt32 glTypeSize
UInt32 glFormat
Uint32 glInternalFormat
Uint32 glBaseInternalFormat
UInt32 pixelWidth
UInt32 pixelHeight
UInt32 pixelDepth
UInt32 numberOfArrayElements
UInt32 numberOfFaces
UInt32 numberOfMipmapLevels
UInt32 bytesOfKeyValueData
for each keyValuePair that fits in bytesOfKeyValueData
UInt32 keyAndValueByteSize
Byte keyAndValue[keyAndValueByteSize]
Byte valuePadding[3 - ((keyAndValueByteSize + 3) % 4)]
end
for each mipmap_level in numberOfMipmapLevels*
UInt32 imageSize;
for each array_element in numberOfArrayElements*
for each face in numberOfFaces
for each z_slice in pixelDepth*
for each row or row_of_blocks in pixelHeight*
for each pixel or block_of_pixels in pixelWidth
Byte data[format-specific-number-of-bytes]**
end
end
end
Byte cubePadding[0-3]
end
end
Byte mipPadding[3 - ((imageSize + 3) % 4)]
end
Mali GPU Texture Compression Tool is corrected.
Another issue with your original code:
@OgrePixelFormat.cpp
Code: Select all
...
case PF_ETC1_RGB8:
return ((width * height) >> 1);
...
Basically, 8 bytes is the minimum texture size. Smaller textures are padded up to 8 bytes.
Here is new code:
Code: Select all
...
case PF_ETC1_RGB8:
return std::max(8, (int)(width * height) >> 1);
...
For verify this issue, I make red colour to MIPMap level 0 and make blue colour to level 1, and zoom in/out camera for observed.
D3D and OpenGL are both correct, it's an issue only with OpenGL ES2. I think maybe something wrong with it.
coded attached.
You do not have the required permissions to view the files attached to this post.
-
oiram
- Halfling
- Posts: 87
- Joined: Sun Dec 13, 2009 5:06 am
- x 6
Re: Added ETC1 support to GLES2
incorrect KTX file structure issue confirmed.
http://www.imgtec.com/forum/forum_posts ... -pvrtexlib
http://www.imgtec.com/forum/forum_posts ... -pvrtexlib
-
oiram
- Halfling
- Posts: 87
- Joined: Sun Dec 13, 2009 5:06 am
- x 6
Re: Added ETC1 support to GLES2
These day SourceForge is blocked to me in our country.
I'll update the patch asap when SF is fixed.
Anyone can review the code?
I'll update the patch asap when SF is fixed.
Anyone can review the code?
-
Wolfmanfx
- OGRE Team Member

- Posts: 1525
- Joined: Fri Feb 03, 2006 10:37 pm
- Location: Austria - Leoben
- x 100
Re: Added ETC1 support to GLES2
Hi,
It do not help when you send me pm's with "please review" moreover i have to test it on my site on a device (android/iOS) and verify its working and also i am just back from vacation today so do not except miracles
It do not help when you send me pm's with "please review" moreover i have to test it on my site on a device (android/iOS) and verify its working and also i am just back from vacation today so do not except miracles
