One and the same

- Add model id debug view
- Want to be able to visually check that instances are pointing to the
  same model
This commit is contained in:
Jozufozu 2025-01-16 10:57:11 -08:00
parent 045b065166
commit 40bd90b640
7 changed files with 20 additions and 7 deletions

View file

@ -42,6 +42,10 @@ public class InstancedDraw {
return deleted;
}
public MeshPool.PooledMesh mesh() {
return mesh;
}
public void render(TextureBuffer buffer) {
if (mesh.isInvalid()) {
return;

View file

@ -64,6 +64,9 @@ public class InstancedRenderStage {
uploadMaterialUniform(program, material);
program.setUInt("_flw_vertexOffset", drawCall.mesh()
.baseVertex());
MaterialRenderState.setup(material);
Samplers.INSTANCE_BUFFER.makeActive();

View file

@ -14,6 +14,7 @@ public enum DebugMode implements StringRepresentable {
LIGHT_COLOR,
OVERLAY,
DIFFUSE,
MODEL_ID,
;
public static final Codec<DebugMode> CODEC = StringRepresentable.fromEnum(DebugMode::values);

View file

@ -14,7 +14,7 @@ in vec2 _flw_crumblingTexCoord;
#endif
#ifdef _FLW_DEBUG
flat in uint _flw_instanceID;
flat in uvec2 _flw_ids;
#endif
out vec4 _flw_outputColor;
@ -79,7 +79,7 @@ void _flw_main() {
color = vec4(flw_vertexNormal * .5 + .5, 1.);
break;
case 2u:
color = _flw_id2Color(_flw_instanceID);
color = _flw_id2Color(_flw_ids.x);
break;
case 3u:
color = vec4(vec2((flw_fragLight * 15.0 + 0.5) / 16.), 0., 1.);
@ -93,6 +93,9 @@ void _flw_main() {
case 6u:
color = vec4(vec3(diffuseFactor), 1.);
break;
case 7u:
color = _flw_id2Color(_flw_ids.y);
break;
}
#endif

View file

@ -72,10 +72,10 @@ mat3 _flw_normalMatrix;
#endif
#ifdef _FLW_DEBUG
flat out uint _flw_instanceID;
flat out uvec2 _flw_ids;
#endif
void _flw_main(in FlwInstance instance, in uint stableInstanceID) {
void _flw_main(in FlwInstance instance, in uint stableInstanceID, in uint modelID) {
_flw_layoutVertex();
flw_instanceVertex(instance);
flw_materialVertex();
@ -96,6 +96,6 @@ void _flw_main(in FlwInstance instance, in uint stableInstanceID) {
gl_Position = flw_viewProjection * flw_vertexPos;
#ifdef _FLW_DEBUG
_flw_instanceID = stableInstanceID;
_flw_ids = uvec2(stableInstanceID, modelID);
#endif
}

View file

@ -51,5 +51,5 @@ void main() {
FlwInstance instance = _flw_unpackInstance(instanceIndex);
_flw_main(instance, instanceIndex);
_flw_main(instance, instanceIndex, draw.vertexOffset);
}

View file

@ -10,6 +10,8 @@ uniform mat4 _flw_modelMatrixUniform;
uniform mat3 _flw_normalMatrixUniform;
#endif
uniform uint _flw_vertexOffset;
void main() {
_flw_unpackMaterialProperties(_flw_packedMaterial.y, flw_material);
@ -20,5 +22,5 @@ void main() {
_flw_normalMatrix = _flw_normalMatrixUniform;
#endif
_flw_main(instance, uint(gl_InstanceID));
_flw_main(instance, uint(gl_InstanceID), _flw_vertexOffset);
}