3d - How to bind data, vec3 and mat3, to shader with descriptor set in Vulkan? -
i try bind data, vec3 , mat3, shader descriptor set in vulkan. data become wrong. have use vec4 , mat4. data correct in shader. why it?
this not vulkan specific question. glsl question. optimize code (alignment etc), compiler prefer deal block of 128 bytes data. not possible deal mat3.
however, if want use array vec3 (in uniform buffer example), can write vec3 array[32];
in uniform block, must align on 128 bytes on cpu side. so, advice use on cpu side :
vec4 myvec3[32]
; , use vec3 since w coordinates never used inside shaders...
you can have more informations in : https://learnopengl.com/#!advanced-opengl/advanced-glsl https://www.khronos.org/registry/opengl/extensions/arb/arb_uniform_buffer_object.txt
Comments
Post a Comment