What texture formats to choose for integer render targets?
17 posts
• Page 2 of 2 • 1, 2
Re: What texture formats to choose for integer render target
Hi!
I have up until now used TextureStoreFormat.Luminance32F as the store format for the ID texture I use for pixel level picking in my application (see above). This has been working very well except for one thing: it breaks down when using blending.
When blending is enabled it seems to accumulate the stored values and thus produce wrong IDs. I have played around with the blend functions, but with no luck. I have also tried to use TextureStoreFormat.LuminanceAlpha32F, but the only thing I gained from this was to have the alpha value accumulated as well. To accumulate luminance values is maybe default operation when blending and luminance is combined? Assuming the error is not in my blend settings (it seems to work for the color part of it all) I suggest two possible solutions:
At this moment I am trying to set up a render texture using R32I or R32UI format, but glTexImage2D fails:
works
doesn't.
Am I missing something or is support for R32I/R32UI not implemented all the way through? Renanse, maybe JOGL fails because it has no constants for these formats and the 0x.... values cannot be used directly?
As always I assume I am doing something wrong so first of all I ask for help to point out what that is, secondly for help to improve Ardor3D so I can be able to do what i need to;)
-Martin
I have up until now used TextureStoreFormat.Luminance32F as the store format for the ID texture I use for pixel level picking in my application (see above). This has been working very well except for one thing: it breaks down when using blending.
When blending is enabled it seems to accumulate the stored values and thus produce wrong IDs. I have played around with the blend functions, but with no luck. I have also tried to use TextureStoreFormat.LuminanceAlpha32F, but the only thing I gained from this was to have the alpha value accumulated as well. To accumulate luminance values is maybe default operation when blending and luminance is combined? Assuming the error is not in my blend settings (it seems to work for the color part of it all) I suggest two possible solutions:
- Implement support for glEnableIndexed/glDisableIndexed or the newer glEnablei/glDisablei in the texture renderers so that blending can be used for the color buffer and disabled for the ID buffer.
- Try to use integer render targets for which blending operations should not be performed by OpenGL.
At this moment I am trying to set up a render texture using R32I or R32UI format, but glTexImage2D fails:
- Code: Select all
javax.media.opengl.GLException: glGetError() returned the following error codes after a call to glTexImage2D(): GL_INVALID_OPERATION
at javax.media.opengl.DebugGL.checkGLGetError(DebugGL.java:12715)
at javax.media.opengl.DebugGL.glTexImage2D(DebugGL.java:9034)
at com.ardor3d.renderer.jogl.JoglTextureRenderer.setupTexture(JoglTextureRenderer.java:102)
- Code: Select all
idTex = new Texture2D();
idTex.setTextureStoreFormat(TextureStoreFormat.Luminance32F);
works
- Code: Select all
idTex = new Texture2D();
idTex.setTextureStoreFormat(TextureStoreFormat.R32UI);
doesn't.
Am I missing something or is support for R32I/R32UI not implemented all the way through? Renanse, maybe JOGL fails because it has no constants for these formats and the 0x.... values cannot be used directly?
As always I assume I am doing something wrong so first of all I ask for help to point out what that is, secondly for help to improve Ardor3D so I can be able to do what i need to;)
-Martin
- martifa
- regular
- Posts: 67
- Joined: Thu Sep 15, 2011 5:16 am
Re: What texture formats to choose for integer render target
Hi
There is rather something wrong in your source code. JOGL 2.0 has such constants:
http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GL2GL3.html#GL_R32I
http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GL2GL3.html#GL_R32UI
and anyway they are correctly handled in JoglTextureUtil:
http://ardorlabs.trac.cvsdude.com/Ardor3Dv1/browser/trunk/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglTextureUtil.java
martifa wrote:Renanse, maybe JOGL fails because it has no constants for these formats and the 0x.... values cannot be used directly?
There is rather something wrong in your source code. JOGL 2.0 has such constants:
http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GL2GL3.html#GL_R32I
http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GL2GL3.html#GL_R32UI
and anyway they are correctly handled in JoglTextureUtil:
http://ardorlabs.trac.cvsdude.com/Ardor3Dv1/browser/trunk/ardor3d-jogl/src/main/java/com/ardor3d/scene/state/jogl/util/JoglTextureUtil.java
- gouessej
- regular
- Posts: 1186
- Joined: Fri May 01, 2009 3:26 am
- Location: France
Re: What texture formats to choose for integer render target
Well, JOGL 2.0 is not used in this case. From the JoglTextureUtil link you provided:
I other words the JOGL version that is used doesn't know about GL_R32I or GL_R32UI, which makes me wonder if it can handle 0x8235 and 0x8236. BUT, you are probably right in that I have errors in my code.
-Martin
- Code: Select all
case R32I:
return 0x8235;// GL.GL_R32I;
case R32UI:
return 0x8236;// GL.GL_R32UI;
I other words the JOGL version that is used doesn't know about GL_R32I or GL_R32UI, which makes me wonder if it can handle 0x8235 and 0x8236. BUT, you are probably right in that I have errors in my code.
-Martin
- martifa
- regular
- Posts: 67
- Joined: Thu Sep 15, 2011 5:16 am
Re: What texture formats to choose for integer render target
Just to clearify: I was asking Renanse that question because he added support for the integer formats in TextureStoreFormat and JoglTextureUtil after I started asking about theses formats. He said that he couldn't find the constants in JOGL 1.x, so he used the hard coded ones.
I am currently using gl.glDisableIndexedEXT(GL.GL_BLEND, index) to make application perform as I expect it to. I will open a ticket an supply the source code when I have made some more tests and improved the implementation a bit.
-Martin
I am currently using gl.glDisableIndexedEXT(GL.GL_BLEND, index) to make application perform as I expect it to. I will open a ticket an supply the source code when I have made some more tests and improved the implementation a bit.
-Martin
- martifa
- regular
- Posts: 67
- Joined: Thu Sep 15, 2011 5:16 am
Re: What texture formats to choose for integer render target
martifa wrote:Well, JOGL 2.0 is not used in this case. From the JoglTextureUtil link you provided:
- Code: Select all
case R32I:
return 0x8235;// GL.GL_R32I;
case R32UI:
return 0x8236;// GL.GL_R32UI;
I other words the JOGL version that is used doesn't know about GL_R32I or GL_R32UI, which makes me wonder if it can handle 0x8235 and 0x8236. BUT, you are probably right in that I have errors in my code.
-Martin
The absence of these constants in JOGL 1 does not cause an OpenGL error "invalid operation" if you pass the proper value to the OpenGL method.
- gouessej
- regular
- Posts: 1186
- Joined: Fri May 01, 2009 3:26 am
- Location: France
Re: What texture formats to choose for integer render target
OK, do you have any idea what errors in my code might cause this? By changing that one line of code I can make the call to gl.glTexImage2D in JoglTexureRenderer fail.
FOI I have submitted a ticket that suggests adding support for configuration of blending individually for render targets:
http://www.ardor3d.com/forums/viewtopic.php?f=11&t=5527
http://ardorlabs.trac.cvsdude.com/Ardor3Dv1/attachment/ticket/215/
I am currently using the implementation and for my narrow test case it seems to work.
Martin
FOI I have submitted a ticket that suggests adding support for configuration of blending individually for render targets:
http://www.ardor3d.com/forums/viewtopic.php?f=11&t=5527
http://ardorlabs.trac.cvsdude.com/Ardor3Dv1/attachment/ticket/215/
I am currently using the implementation and for my narrow test case it seems to work.
Martin
- martifa
- regular
- Posts: 67
- Joined: Thu Sep 15, 2011 5:16 am
Re: What texture formats to choose for integer render target
Look at all suggestions for GL_INVALID_OPERATION in the man:
http://www.opengl.org/sdk/docs/man/xhtml/glTexImage2D.xml
There are a lot of constraints as you can see.
I don't see any obvious mistake in your code.
http://www.opengl.org/sdk/docs/man/xhtml/glTexImage2D.xml
There are a lot of constraints as you can see.
I don't see any obvious mistake in your code.
- gouessej
- regular
- Posts: 1186
- Joined: Fri May 01, 2009 3:26 am
- Location: France
17 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 3 guests