Hello, I’m rendering a mesh that has 4 “sub meshes”, with draw index I would do one drawcall per “submesh” with proper index offset. However I’m using mesh shaders, I’m rendering all meshlets in a single drawcall.
Each of these “submeshes” has their own textures, therefore I have a texture array and per meshlet I’m sending the proper texture(uint) (I know this is not good it adds a huge amount of memory etc…).
Problem is : I can send the texture Id from mesh shader to fragment shader. More Details at the bottom.
Please I’m open to suggestions and other aproachs.
Mesh Shader
layout(location = 0) out VertexOutput
{
vec2 uv;
uvec2 index;
} vertexOutput[];
...
vertexOutput[ti].index = uvec2(mesh_id,0.0) ;
Fragment Shader
layout (location = 0) in VertexInput {
vec2 uv;
uvec2 index;
} vertexInput;
layout( push_constant ) uniform block
{
mat4 model;
uvec2 id;
};
void main()
{
vec2 uv = vec2(vertexInput.uv.x,1.0 - vertexInput.uv.y);
color_out = texture(textures[vertexInput.index.x],uv);
}
When I send type uvec2, the input on fragment shader is always zero…
When I try send vec2 and convert the first element to uint and use it as index to access the texturearray I get this result.
Textures seems to be warping and strangly mixing inside the vector.