We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I'm now trying to render to an integer format as attachment 1
GLFormat = GL_RG_INTEGER; GLInternalFormat = GL_RG32UI; Type = GL_UNSIGNED_INT; glTexImage2D( GL_TEXTURE_2D, 0, GLInternalFormat, Tex->Info.Width, Tex->Info.Height, 0, GLFormat, Type, NULL );
I have GL_NEAREST filtering on this texture.
And in the object's shader I have this :
layout(location = 1) out uvec2 VelocityOut; //... VelocityOut = uvec2( vec2( VelocityVertex.xy * vec2(0.5) + vec2(0.5) ) * vec2( 4294967295.0 ) );
VelocityVertex is -1..1 and I'm trying to pack it in 0..4294836225 (allegedly MAX_UINT)
The problem is that I don't get the results back to -1..1 in a following post processing shader where I have :
uniform highp usampler2D Texture1; //...
vec4 curFramePixelVelocity = vec4( texelFetch( Texture1, ivec2( OutTexcoord * Texture0Size ), 0 )) / vec4( 4294967295.0 ); curFramePixelVelocity = curFramePixelVelocity * vec4(2.0) - vec4(1.0);
The exact same shaders give the correct results on my Desktop AMD card. Using a GL_RGBA8 texture attachment that I just convert from -1..1 to 0..1 works as expected but I'm trying to increase the precision by using an integer format.
UPDATE : I think my problem is related to needing to convert to float from UINT32 inside the shader. I just tried using 65535 as the multiplier and with that it works fine. I'm curious what is the maximum value I could use in a shader since it says floats have 23 bits of precision, is 2^23 safe to use ?
UPDATE 2 : Trying to create a GL_RG32UI texture with Samples = 4 results in :
//glTexStorage2DMultisample TextureTarget=37120 Samples=4 GLInternalFormat=33340
GLDebugCallback Source=OpenGL Type=Error Severity=high ID=33350 Message=Error:glTexStorage2DMultisample::invalid number of samples
calling glGetError after glTexStorage2DMultisample returns GL_INVALID_OPERATION
I was looking at glTexStorage2DMultisample - OpenGL ES 3.1 Reference Pages and there is nothing that says integer textures should not support Samples > 1