Advertisement

uint RBGA as vertex attribute

Started by September 25, 2019 05:35 PM
3 comments, last by bzt 5 years, 4 months ago

hello

I try to use uint as vertex attribute. like


layout(location = 0) in vec3 a_Vertex;

layout(location = 1) in uint a_Color;


 

layout(location = 0) out vec4  color;


 

void main() 

{

  vec4 col =  unpackUnorm4x8(a_Color);


 

  color = col; //cb.color;


 ***

 

sending on draw for line just 2 vertex with struct { vec3 position; uint32 color }; Drawing just line.

The strange situation is next. color is always red or gradation of red. looks like extracts only red color.

I thought it may related to data align, but my data is too small.vertex is 16 byte, 32byte is line data.

does anyone have/had similar problem? or any suggestion?

GPU is GTX 750ti. OS win 8.1, Ubuntu 18.04 lts.

thanks.

If you think that the buffer data is correct, then something is probably wrong in your VertexInputStateCreateInfo. That's where you describe how to translate the buffer data into the shader inputs (including formats and offsets)

Advertisement

So have you tried just sending a float from 0-1.0 that represents a grayscale value to verify the pipeline states are setup (kind of what satanir is suggesting).

Never messed with vulcan but if the grayscale thing works, then it could be an issue with the unpack setup unless thats pulled from a tutorial and its a uint and not a uint[4]. Seems like that is the wrong storage type if the shader unit needs to request enough memory for more than 1 uint.

NBA2K, Madden, Maneater, Killing Floor, Sims

Hi,

Don't overcomplicate your shader when there's no need.

When you call VkVertexInputAttributeDescription, specify VK_FORMAT_B8G8R8A8_UINT, and in your shader simply use vec4. The 32 bit color codes will be converted automatically and transparently into 4 floats for the shader input.

Cheers,
bzt

This topic is closed to new replies.

Advertisement