Sign in to follow this  

Floating point texture

This topic is 4207 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I want to load 16-bit floating point texture data into my textures. With 32-bit my call looks like this and works fine: glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, width, height, 0, GL_RGBA32F_ARB, GL_FLOAT, pData ); Now I want to load 16-bit data instead, so I changed the call to this: glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, width, height, 0, GL_RGBA16F_ARB, GL_FLOAT, pData ); Crashes. I guess because I don't supply GL_FLOAT values, but rather 16-bit ones. So I tried glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, width, height, 0, GL_RGBA16F_ARB, GL_RGBA16F_ARB, pData ); Does not work, because the spec ( http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_float.txt ) says that GL_RGBA16F_ARB is only allowed for the internal parameter. The spec doesn't give me a new GL_FLOAT16 type or whatever which I could pass in for the <type> argument. So, in conclusion, is there any way to directly load 16-bit floating point data into my textures? Or do I really have to convert the 16-bit to 32-bit floats first, then pass this to glTexImage2D just that it gets converted down to 16-bit again? It doesn't exactly allow for a reasonable texture loading speed... Or is there a way to make this work? -Matthias

Share this post


Link to post
Share on other sites
If you are trying to create a 16bit FP texture opengl is uses float to do fp16 textures... now if you want to do half floats you need another extension called ARB_HALF_FLOAT_ARB and this 16bit float is an unsigned short. The problem with Fp16 is you have to watch what format you are using as opengl doesn't support every format in fp16, good thing is fp16 allows filtering where fp32 doesn't hopefully soon though.


float *buffer = new float[size * size * 4];
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, width, height, 0, GL_RGBA, GL_FLOAT, buffer);




I am not sure what card you are on but with NVIDIA it will internally convert a RGB16 to RGBA16 so you may as well do it yourself... and use GL_RGBA_16F_ARB. HTH

Share this post


Link to post
Share on other sites
Quote:
Original post by Nitrogenycs
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, width, height, 0, GL_RGBA32F_ARB, GL_FLOAT, pData );

I don't think that's right ... have you checked for GL errors? For data format you are supposed to provide the data type and format separately. The type is GL_FLOAT which you have provided correctly, and the format must be GL_RGBA or GL_RGB etc.

GL_RGBA32F_ARB, GL_RGBA16F_ARB are internal format enumerations. If you use the code MARS_999 provided you should be fine.

Share this post


Link to post
Share on other sites
Quote:
Original post by phantom
Quote:
Original post by MARS_999
good thing is fp16 allows filtering where fp32 doesn't hopefully soon though.



Thats not an OpenGL limitation, thats a hardware one, iirc ATI's X1K series can filter fp32 textures as well as fp16.


Hmm I am not sure about that, I goofed and should have said hardware, but the x1000 series I am checking into with Humus. If I remember right its a no. I know that the he said awhile back that no card supports fp32 filtering... I will post back when I get a reply.

Share this post


Link to post
Share on other sites
No it can't. No hardware can do that right now. Wait for DX10. It's
> going to be mandatory there.
>
> -Humus

Emil got back to me, and that's the offical word on fp32 filtering...

Share this post


Link to post
Share on other sites

This topic is 4207 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this