OpenGL transform feedback half float output
category: code [glöplog]
I've been trying to output to half float buffers using OpenGL's transform feedback without success, and after many frustrated atempts and removing most code I've ended up with this simple shader like:
And I get a point on the screen (the camera is moving), which makes sense. However if I remove "const" I get a black screen. Shouldn't packHalf2x16 work with compile time variables instead of constants? Is it a driver bug or am I missing something?
Code:
out uint2 O0;
void main()
{
const vec4 t = vec4(1.0, 0.0, 0.0, 0.0);
O0.x = packHalf2x16(t.xy);
O0.y = packHalf2x16(t.zw);
}
And I get a point on the screen (the camera is moving), which makes sense. However if I remove "const" I get a black screen. Shouldn't packHalf2x16 work with compile time variables instead of constants? Is it a driver bug or am I missing something?
half float, wtf is that?
most likely you are not missing something, but doing something terrible wrong.
most likely you are not missing something, but doing something terrible wrong.
half float = 16bit float
...but seeing
made me laugh :D Anyone reading that with a bad screen / wrong font is in for trouble!
...but seeing
Code:
out uint2 O0;
made me laugh :D Anyone reading that with a bad screen / wrong font is in for trouble!
The OpenGL Shading Language specification says:
"Shaders should declare the version of the language they are written to."
And "packHalf2x16" was added in OpenGL4.
So your shader might needs:
#version 440
or older version but must be >= 400.
"Shaders should declare the version of the language they are written to."
And "packHalf2x16" was added in OpenGL4.
So your shader might needs:
#version 440
or older version but must be >= 400.
#extension GL_ARB_shading_language_packing : require
I forgot that line. The shader compiles so that shouldn't be an issue, right?
I forgot that line. The shader compiles so that shouldn't be an issue, right?
Anyway, I've ended up coding my very own sluggish packHalf2x16 and everything's working. Maybe I just don't know how to properly use GLSL extensions. Shouldn't it all work just by adding "#extension GL_ARB_shading_language_packing : require"?
You don't need #extension if you're on a GL4.x context.
Anyhow, that sounds like a driver bug to me. const should never be affecting any results you're getting. You may consider reporting this to your vendor.
Anyhow, that sounds like a driver bug to me. const should never be affecting any results you're getting. You may consider reporting this to your vendor.
Which vendor is it?