Texture compression

classic Classic list List threaded Threaded
40 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Texture compression

elect
Is texture compression supported in jogl?

If yes, which kind of compression? Is there any example out there?
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

gouessej
Administrator
Hi

Yes it's supported, look at how it is used in the JOGL renderers, for example in JMonkeyEngine 3 and Ardor3d.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

elect
gouessej wrote
Hi

Yes it's supported, look at how it is used in the JOGL renderers, for example in JMonkeyEngine 3 and Ardor3d.
Where, here?

http://code.google.com/p/jmonkeyengine/source/browse/#svn%2Ftrunk%2Fengine%2Fsrc%2Fjogl%2Fcom%2Fjme3%2Frenderer%2Fjogl
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

jmaasing
elect wrote
gouessej wrote
Hi

Yes it's supported, look at how it is used in the JOGL renderers, for example in JMonkeyEngine 3 and Ardor3d.
Where, here?

http://code.google.com/p/jmonkeyengine/source/browse/#svn%2Ftrunk%2Fengine%2Fsrc%2Fjogl%2Fcom%2Fjme3%2Frenderer%2Fjogl
jMonekyEngine recently moved to GitHub so for the latest source look here:
https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-jogl/src/main/java/com/jme3/renderer/jogl
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

gouessej
Administrator
Yes jmaasing is right. Look at the class TextureUtil. I fixed a bug in this class in August 2013.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

elect
In reply to this post by elect
How can I convert an image to dds format? is there any utility in jogl?
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

gouessej
Administrator
Look at com.jogamp.opengl.util.texture.spi.DDSImage.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

elect
gouessej wrote
Look at com.jogamp.opengl.util.texture.spi.DDSImage.
Thanks, you meant this one

 createFromData

public static DDSImage createFromData(int d3dFormat,
                                      int width,
                                      int height,
                                      ByteBuffer[] mipmapData)
                               throws IllegalArgumentException

    Creates a new DDSImage from data supplied by the user. The resulting DDSImage can be written to disk using the write() method.

    Parameters:
        d3dFormat - the D3DFMT_ constant describing the data; it is assumed that it is packed tightly
        width - the width in pixels of the topmost mipmap image
        height - the height in pixels of the topmost mipmap image
        mipmapData - the data for each mipmap level of the resulting DDSImage; either only one mipmap level should be specified, or they all must be
    Returns:
        DDS image object
    Throws:
        IllegalArgumentException - if the data does not match the specified arguments


Ps: how can I do if I only have an image? Because with that method I also have to submit the mimaps, which I don't have..
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

jmaasing
elect wrote
        mipmapData - the data for each mipmap level of the resulting DDSImage; either only one mipmap level should be specified, or they all must be
Ps: how can I do if I only have an image? Because with that method I also have to submit the mimaps, which I don't have..
Then you have only 1 level of mipmap.
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

elect
I see jogl has only

GL_COMPRESSED_RGB_S3TC_DXT1
GL_COMPRESSED_RGBA_S3TC_DXT1
GL_COMPRESSED_RGB_S3TC_DXT3
GL_COMPRESSED_RGB_S3TC_DXT5

but it misses the counterparts for the sRGB space:

GL_COMPRESSED_SRGB_S3TC_DXT1
GL_COMPRESSED_SRGBA_S3TC_DXT1
GL_COMPRESSED_SRGB_S3TC_DXT3
GL_COMPRESSED_SRGB_S3TC_DXT5

Why?
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

gouessej
Administrator
GL_COMPRESSED_SRGB_S3TC_DXT1 _EXT was in JOGL 1 but I don't know why it isn't in JOGL 2.

Sven, do you know why??
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

elect
Digging the web, I didnt find anything clear, but some hints

https://www.opengl.org/wiki/Image_Format

http://stackoverflow.com/questions/12358863/opengl-compressed-textures-and-extensions

seem to point out the sRGB versions are somehow connected/implicit with the EXT_texture_sRGB extension

But I still need to figure it out how
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

elect
Found!

  public static final int GL_COMPRESSED_SRGB_S3TC_DXT1_NV = 0x8C4C;
  /** Part of <code>GL_NV_sRGB_formats</code> */
  public static final int GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV = 0x8C4D;
  /** Part of <code>GL_NV_sRGB_formats</code> */
  public static final int GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV = 0x8C4E;
  /** Part of <code>GL_NV_sRGB_formats</code> */
  public static final int GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV = 0x8C4F;

in GLES2
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

elect
Is it possible to create a compressed texture with mipmaps using the jogl classes starting from a single image?
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

elect
The problem is, to create a DDSImage a need the byteBuffer[] array containing the mipmaps

I can get that from the textureData, but textureData *dont* really create the mipmaps

            textureData = TextureIO.newTextureData(gl3.getGLProfile(), file, true, TextureIO.PNG);
           
            System.out.println("textureData.getMipmap() "+textureData.getMipmap());
            System.out.println("textureData.getMipmapData().length "+textureData.getMipmapData().length);



This prints true and then crashes because textureData.getMipmapData().length is null

and if I look in the code, I reach the

    public TextureData newTextureData(GLProfile glp, File file,
                                      int internalFormat,
                                      int pixelFormat,
                                      boolean mipmap,
                                      String fileSuffix) throws IOException;

in the TextureProvider, but it has only methods in DDS/IIO/StreamBased TextureProvider, no PNG
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

elect
How can I get internalFormat, format and type from a DDS?
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

elect
I tried both with TextureIO and AWTextureIO

TextureIO.newTextureData(gl3.getGLProfile(), conn.getURL(),
                    ddsImage.getNumMipMaps() > 1, TextureIO.DDS);

but I keep getting

Unsupported DDS compression format "DX10"
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

elect
I read in the DDSImage.java:

"/** Simple class describing images and data; does not encapsulate
        image format information. User is responsible for transmitting
        that information in another way. */"

I wish the dds loader encapsulates the format as well.. which is the reason why it has not be included?
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

elect
I'm also thinking about including support for ktx textures, is someone interested?
Reply | Threaded
Open this post in threaded view
|

Re: Texture compression

gouessej
Administrator
12