feat: add click to select

This commit is contained in:
2026-10-23 20:53:56 +02:00
parent f055bdcbf1
commit f7e7c56392
20 changed files with 385 additions and 20 deletions
+18
View File
@@ -13,9 +13,23 @@ layout (location = 1) in vec2 inUV;
layout (location = 2) in vec3 inNormal;
layout (location = 3) in vec4 inTangent;
layout (location = 4) flat in uint inMaterialID;
layout (location = 5) flat in uint inObjectID;
layout (location = 0) out vec4 outFragColor;
// Stable per object, the same object keeps its color between frames and runs
vec3 selectionColor(uint objectID)
{
if (objectID == 0u) {
return vec3(0.0);
}
uint hash = objectID * 2654435761u;
hash ^= hash >> 15;
hash *= 2246822519u;
hash ^= hash >> 13;
return vec3(hash & 255u, (hash >> 8) & 255u, (hash >> 16) & 255u) / 255.0;
}
vec3 calculateNormal(MaterialData material, uint samplerID)
{
vec3 n = normalize(inNormal);
@@ -127,6 +141,10 @@ void main()
fragColor = mix(fragColor, lightHeatmapColor(tileLightCount), 0.5);
}
if (pcs.sceneData.debugSelectionView != 0) {
fragColor = selectionColor(inObjectID);
}
#if 0
// TANGENT DEBUG
if (inTangent == vec4(0.0)) {