The_Leo
September 29, 2016, 5:05pm
1
Hi,
Currently Jme3 does not support textures with integer formats, such as GL_RGBA32UI.
What are your thoughts on providing integer texture support.
It requires OpenGL 2.0 and GL_EXT_texture_integer.
https://www.opengl.org/registry/specs/EXT/texture_integer.txt
As I am aware:
It would require modification of com.jme3.renderer.opengl.GLImageFormats and com.jme3.texture.Image.Format classes
Ogli
September 29, 2016, 5:17pm
2
What I know about this:
In 2007 I used integer textures on both ATI and NVIDIA cards via C++ and GLSL.
It required a different GLSL syntax on those two different hardwares.
But it worked (even on my mid- to low- range computer at home).
Should be possible with current technology too.
The_Leo
September 30, 2016, 10:36am
3
So I have tried to used Integer Textures with jme3, and currently it is possible with just the following hack:
public static Image.Format RGBA_16I = Image.Format.Reserved1;
static void initFormat(Renderer r) {
GLRenderer gl = (GLRenderer)r;
Object textureUtil = read(gl, "texUtil");
GLImageFormat[][] formats = (GLImageFormat[][]) read(textureUtil, "formats");
formats[0][RGBA_16I.ordinal()] = new GLImageFormat(GL30.GL_RGBA16I, GL30.GL_RGBA_INTEGER, GL.GL_SHORT);//GL.GL_UNSIGNED_SHORT);
}
static Object read(Object o, String name) {
try {
java.lang.reflect.Field f = o.getClass().getDeclaredField(name);
f.setAccessible(true);
return f.get(o);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Once you call method initFormat, you can use the new format in your texture
matTex = new Texture2D(w, h, RGBA_16I);
In case you are writing to your integer texture:
In fragment shader:
layout(location = 0) out ivec4 FragMat;
layout requires GLSL330
Alternatively, GLSL130:
out ivec4 FragMat;
should work. If not BindFragDataLocationEXT is probably needed.
So basically, I am asking a core dev if we can expand the Image.Format enum with other texture types. I can make the patch if we agree on this.
There is a table of texture types here. Shall we include all of them or just a subset?
https://www.opengl.org/sdk/docs/man/html/glTexImage2D.xhtml
2 Likes
tukez
November 9, 2016, 4:16pm
4
What happened to this? Additional formats would be useful for me too.
The_Leo
November 12, 2016, 12:31pm
5
Well, pretty much I am waiting for someone from core team to discuss which formats, if any, or all, to add. In the meantime, you can use the ‘hack’ that I provided. :chimpanzee_amused:
nehon
November 12, 2016, 12:43pm
6
Missed that post completely sorry.
The one to ping for this usually is @Momoko_Fan .
IMO I don’t see any issue as long as the user is aware of what he’s doing, and properly checks for the extension.
Could you make a PR for this?
2 Likes
The_Leo
November 12, 2016, 12:45pm
7
Okay, thanks I’ll prepare a PR and we’ll take things from there.
Edit: link to PR:
jMonkeyEngine:master
← TehLeo:master
opened 05:58PM - 12 Nov 16 UTC
2 Likes