How to upload the Vertices buffer data in the expected code:
ray-closest-hit.rchit:
struct Vertex
{
vec4 pos;
...
};
...
layout(scalar, set = 1, binding = 1) buffer Vertices { Vertex v[]; } vertices[];
...
void main(){
// objId(uint) is the Object of this instance
// ind(ivec3) is the Indices of the triangle
// Vertex of the triangle
Vertex v0 = vertices[objId].v[ind.x];
Vertex v1 = vertices[objId].v[ind.y];
Vertex v2 = vertices[objId].v[ind.z];
}
to bypass the array of storage buffer block, I store all data in Vertex v[]:
ray-closest-hit.rchit:
struct Vertex
{
vec4 pos;
...
};
...
layout(scalar, set = 1, binding = 1) buffer Vertices { Vertex v[]; } vertices;
...
void main(){
// objId(uint) is the Object of this instance
// ind(ivec3) is the Indices of the triangle
// the indexCount of the triangle is 3
// Vertex of the triangle
Vertex v0 = vertices.v[objId * indexCount + ind.x];
Vertex v1 = vertices.v[objId * indexCount + ind.y];
Vertex v2 = vertices.v[objId * indexCount + ind.z];
}
Hello!
How to upload the Vertices buffer data in the expected code: ray-closest-hit.rchit:
to bypass the array of storage buffer block, I store all data in Vertex v[]: ray-closest-hit.rchit:
Thanks very much!!!