Reputation:
I have this strange behavior in my rendering process. I'm passing an 32-bit unsigned integer as an attribute to my shader. The vertex-shader forwards this attribute as a flat uint to the fragmentshader.
In the fragment shader I do a comparison. In my case send in 1u and I compare with 1u. This doesn't generate true. Instead my value compared to
0x3F800000
generates true.
So, somehow my initial 32-bit value:
0000 0000 0000 0000 0000 0000 0000 0001
Has become:
0011 1111 1000 0000 0000 0000 0000 0000
All I'm doing is this:
Vertex:
layout(location = 3) in uint in_index
flat out uint v_index;
v_index = in_index;
Fragment:
if (v_index == 0x3F800000u){discard;}
And all fragments are discarded. I'm using core 330.
And by the way, I've used floats and shorts and they all work fine.
Upvotes: 0
Views: 304
Reputation:
@Andon M. Coleman solved it for me!
use glVertexAttribIPointer (...) instead of glVertexAttribPointer (...).
Upvotes: 1