What texture formats to choose for integer render targets?

Problems building or running Ardor3D, questions about how to use features, etc.

What texture formats to choose for integer render targets?

Postby martifa » Thu Feb 23, 2012 11:28 am

Hi there!

I want to write integer IDs to an Frame Buffer Object using the JoglTextureRenderer, but I am having a hard time finding integer texture formats to use... Are there any in Ardor3D? Any other way around?

In my shader I want to do this:

Code: Select all
vec4 color;
int id;
......
gl_FragData[0] = color;
gl_FragData[1] = id;


Martin
martifa
regular
 
Posts: 67
Joined: Thu Sep 15, 2011 5:16 am

Re: What texture formats to choose for integer render target

Postby gouessej » Thu Feb 23, 2012 3:01 pm

Hi

Are you sure you can put an integer into gl_FragData[1]? I don't think so.
gouessej
regular
 
Posts: 1186
Joined: Fri May 01, 2009 3:26 am
Location: France

Re: What texture formats to choose for integer render target

Postby martifa » Fri Feb 24, 2012 2:47 am

Hi!

I am not sure about anything here, but I thought so..:) According to the EXT_framebuffer_object spec (http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt), table 3.15 and 3.16 should dictate valid formats for color render targets:

* The following base internal formats from table 3.15 are
"color-renderable": RGB, RGBA, FLOAT_R_NV, FLOAT_RG_NV,
FLOAT_RGB_NV, and FLOAT_RGBA_NV. The sized internal formats
from table 3.16 that have a color-renderable base internal
format are also color-renderable. No other formats, including
compressed internal formats, are color-renderable.


And in http://www.opengl.org/registry/specs/ARB/texture_rg.txt

(Add the following to Table 3.16: "Correspondence of sized internal
formats to base internal formats, and desired component resolutions
for each sized internal format", as modified by ARB_texture_float and
ARB_texture_integer)

Sized Internal Format - Base Internal Format - bits bits bits bits bits bits bits
--------------- --------------- ---- ---- ---- ---- ---- ---- ----
R8 RED 8
R16 RED 16
RG8 RG 8 8
RG16 RG 16 16
R16F RED f16
R32F RED f32
RG16F RG f16 f16
RG32F RG f32 f32
R8I RED i8
R8UI RED ui8
R16I RED i16
R16UI RED ui16
R32I RED i32
R32UI RED ui32
RG8I RG i8 i8
RG8UI RG ui8 ui8
RG16I RG i16 i16
RG16UI RG ui16 ui16
RG32I RG i32 i32
RG32UI RG ui32 ui32


My impression was that you could use pretty much any texture format you like, as long as the dimension of the render targets are equal and the bit size of each element also is. Meaning that when the main color buffer is 32-bits, any other buffer would also have to be. I was hoping to use the R32I for the "ID buffer" and thought that would work, but I am by no means sure, at least not anymore;)

Anyhow, R32I is a valid format for general textures, but I cannot see that it is available in Ardor3D...

Martin
martifa
regular
 
Posts: 67
Joined: Thu Sep 15, 2011 5:16 am

Re: What texture formats to choose for integer render target

Postby gouessej » Fri Feb 24, 2012 3:10 am

Maybe I can add some support of R32I into the JOGL 2.0 renderer but it would be nice if we knew whether it would be really useful for you in your case.
Last edited by gouessej on Fri Feb 24, 2012 6:06 am, edited 1 time in total.
gouessej
regular
 
Posts: 1186
Joined: Fri May 01, 2009 3:26 am
Location: France

Re: What texture formats to choose for integer render target

Postby martifa » Fri Feb 24, 2012 5:53 am

Thanks for the offer!

Currently I am trying to work around this issue by using a 32 bit float texture and GL_LUMINANCE + GL_LUMINANCE32F_ARB. It seems to work, but I am not finished and cannot be 100% sure yet.

For now I don't think it is worth doing specific work just to help me out, but in general I think Ardor3D should support such formats.

Cheers,
Martin
martifa
regular
 
Posts: 67
Joined: Thu Sep 15, 2011 5:16 am

Re: What texture formats to choose for integer render target

Postby gouessej » Fri Feb 24, 2012 6:08 am

martifa wrote:Thanks for the offer!

Currently I am trying to work around this issue by using a 32 bit float texture and GL_LUMINANCE + GL_LUMINANCE32F_ARB. It seems to work, but I am not finished and cannot be 100% sure yet.

For now I don't think it is worth doing specific work just to help me out, but in general I think Ardor3D should support such formats.

Cheers,
Martin

Ok, I understand your position. If you really need these formats, fill a bug report in the category "enhancement", I will provide a patch for the renderer based on JOGL 1 and I will update the renderer based on JOGL 2 if Renanse accepts your request.
gouessej
regular
 
Posts: 1186
Joined: Fri May 01, 2009 3:26 am
Location: France

Re: What texture formats to choose for integer render target

Postby martifa » Fri Feb 24, 2012 8:38 am

OK, sounds good!
martifa
regular
 
Posts: 67
Joined: Thu Sep 15, 2011 5:16 am

Re: What texture formats to choose for integer render target

Postby renanse » Fri Feb 24, 2012 5:58 pm

I'll look into adding support for the formats that are listed in lwjgl's ARBTextureRg (and similar from jogl as available, though it may be that those will need to be jogl2.)
Gratitude is a mark of a noble soul and a refined character.
User avatar
renanse
Site Admin
 
Posts: 2955
Joined: Tue Oct 28, 2008 6:49 pm
Location: Austin, TX

Re: What texture formats to choose for integer render target

Postby renanse » Sun Feb 26, 2012 9:42 pm

I've added support for the one and two component texture formats, including float and integer versions. One thing we don't yet support is the integer and unsigned integer versions of rgba/rgb/alpha/lum/intensity, but I'll hold off on those until we have someone who really needs them.

I also added support for querying the ContextCaps for support of float textures, integer textures and one/two component textures. In Jogl1 renderer I had to use some hardcoded OpenGL numbers because the values were not part of the api (eg: 0x8227 instead of GL_RG.) I've commented the correct constant name for reference though.

I don't have a use case or demo for this new functionality, so please give it a try and report back!
Gratitude is a mark of a noble soul and a refined character.
User avatar
renanse
Site Admin
 
Posts: 2955
Joined: Tue Oct 28, 2008 6:49 pm
Location: Austin, TX

Re: What texture formats to choose for integer render target

Postby martifa » Tue Feb 28, 2012 11:25 am

I currently have a working implementation of a GPU based picking system. This is a lot (!) faster than the multi-threaded "picking service" based on PrimitivePickResults that I first made (not mentioned here before now).

Instead of using a 32 bit integer texture as I first tried, I got it working by casting the integers to floats and adding 0.5 to get a float representation. That way casting to int by truncating will always return the original id. I also had to make changes to AbstractFBOTextureRenderer and JoglTextureRenderer to make it work. I have added tickets (#212 and #213) and posted under "Wishlist" regarding these changes:
viewtopic.php?f=11&t=5224
viewtopic.php?f=11&t=5225

Thanks for looking into this!
I will get back to you on the texture formats if I find that I actually need the Integer format after all.

Martin
martifa
regular
 
Posts: 67
Joined: Thu Sep 15, 2011 5:16 am

Next

Return to HELP!

Who is online

Users browsing this forum: No registered users and 0 guests

cron