Fixing access to nonuniform elements + SBT alignment

This commit is contained in:
mklefrancois 2020-05-27 14:43:05 +02:00
parent 4f46136c08
commit ccdc90f35c
41 changed files with 388 additions and 279 deletions

View file

@ -43,8 +43,8 @@ void main()
int objId = scnDesc.i[pushC.instanceId].objId;
// Material of the object
int matIndex = matIdx[objId].i[gl_PrimitiveID];
WaveFrontMaterial mat = materials[objId].m[matIndex];
int matIndex = matIdx[nonuniformEXT(objId)].i[gl_PrimitiveID];
WaveFrontMaterial mat = materials[nonuniformEXT(objId)].m[matIndex];
vec3 N = normalize(fragNormal);
@ -85,7 +85,7 @@ void main()
{
int txtOffset = scnDesc.i[pushC.instanceId].txtOffset;
uint txtId = txtOffset + mat.textureId;
vec3 diffuseTxt = texture(textureSamplers[txtId], fragTexCoord).xyz;
vec3 diffuseTxt = texture(textureSamplers[nonuniformEXT(txtId)], fragTexCoord).xyz;
diffuse *= diffuseTxt;
}

View file

@ -45,13 +45,13 @@ void main()
uint objId = scnDesc.i[gl_InstanceID].objId;
// Indices of the triangle
ivec3 ind = ivec3(indices[objId].i[3 * gl_PrimitiveID + 0], //
indices[objId].i[3 * gl_PrimitiveID + 1], //
indices[objId].i[3 * gl_PrimitiveID + 2]); //
ivec3 ind = ivec3(indices[nonuniformEXT(objId)].i[3 * gl_PrimitiveID + 0], //
indices[nonuniformEXT(objId)].i[3 * gl_PrimitiveID + 1], //
indices[nonuniformEXT(objId)].i[3 * gl_PrimitiveID + 2]); //
// 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];
Vertex v0 = vertices[nonuniformEXT(objId)].v[ind.x];
Vertex v1 = vertices[nonuniformEXT(objId)].v[ind.y];
Vertex v2 = vertices[nonuniformEXT(objId)].v[ind.z];
const vec3 barycentrics = vec3(1.0 - attribs.x - attribs.y, attribs.x, attribs.y);
@ -101,8 +101,8 @@ void main()
#endif
// Material of the object
int matIdx = matIndex[objId].i[gl_PrimitiveID];
WaveFrontMaterial mat = materials[objId].m[matIdx];
int matIdx = matIndex[nonuniformEXT(objId)].i[gl_PrimitiveID];
WaveFrontMaterial mat = materials[nonuniformEXT(objId)].m[matIdx];
// Diffuse
@ -112,7 +112,7 @@ void main()
uint txtId = mat.textureId + scnDesc.i[gl_InstanceID].txtOffset;
vec2 texCoord =
v0.texCoord * barycentrics.x + v1.texCoord * barycentrics.y + v2.texCoord * barycentrics.z;
diffuse *= texture(textureSamplers[txtId], texCoord).xyz;
diffuse *= texture(textureSamplers[nonuniformEXT(txtId)], texCoord).xyz;
}
vec3 specular = vec3(0);