Renaming to instanceCustomId

This commit is contained in:
mklefrancois 2020-11-30 18:05:13 +01:00
parent 60b9191069
commit b1d17dbd2a
35 changed files with 167 additions and 157 deletions

View file

@ -19,7 +19,7 @@ layout(binding = 1, set = 1, scalar) buffer MatColorBufferObject { WaveFrontMate
void main()
{
// Object of this instance
uint objId = scnDesc.i[gl_InstanceID].objId;
uint objId = scnDesc.i[gl_InstanceCustomIndexEXT].objId;
// Material of the object
int matIdx = matIndex[nonuniformEXT(objId)].i[gl_PrimitiveID];

View file

@ -42,7 +42,7 @@ layout(location = 3) callableDataEXT rayLight cLight;
void main()
{
// Object of this instance
uint objId = scnDesc.i[gl_InstanceID].objId;
uint objId = scnDesc.i[gl_InstanceCustomIndexEXT].objId;
// Indices of the triangle
ivec3 ind = ivec3(indices[nonuniformEXT(objId)].i[3 * gl_PrimitiveID + 0], //
@ -58,13 +58,13 @@ void main()
// Computing the normal at hit position
vec3 normal = v0.nrm * barycentrics.x + v1.nrm * barycentrics.y + v2.nrm * barycentrics.z;
// Transforming the normal to world space
normal = normalize(vec3(scnDesc.i[gl_InstanceID].transfoIT * vec4(normal, 0.0)));
normal = normalize(vec3(scnDesc.i[gl_InstanceCustomIndexEXT].transfoIT * vec4(normal, 0.0)));
// Computing the coordinates of the hit position
vec3 worldPos = v0.pos * barycentrics.x + v1.pos * barycentrics.y + v2.pos * barycentrics.z;
// Transforming the position to world space
worldPos = vec3(scnDesc.i[gl_InstanceID].transfo * vec4(worldPos, 1.0));
worldPos = vec3(scnDesc.i[gl_InstanceCustomIndexEXT].transfo * vec4(worldPos, 1.0));
cLight.inHitPosition = worldPos;
//#define DONT_USE_CALLABLE
@ -109,7 +109,7 @@ void main()
vec3 diffuse = computeDiffuse(mat, cLight.outLightDir, normal);
if(mat.textureId >= 0)
{
uint txtId = mat.textureId + scnDesc.i[gl_InstanceID].txtOffset;
uint txtId = mat.textureId + scnDesc.i[gl_InstanceCustomIndexEXT].txtOffset;
vec2 texCoord =
v0.texCoord * barycentrics.x + v1.texCoord * barycentrics.y + v2.texCoord * barycentrics.z;
diffuse *= texture(textureSamplers[nonuniformEXT(txtId)], texCoord).xyz;