mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-23 11:27:54 +01:00
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:
parent
045b065166
commit
40bd90b640
7 changed files with 20 additions and 7 deletions
|
@ -42,6 +42,10 @@ public class InstancedDraw {
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MeshPool.PooledMesh mesh() {
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
public void render(TextureBuffer buffer) {
|
public void render(TextureBuffer buffer) {
|
||||||
if (mesh.isInvalid()) {
|
if (mesh.isInvalid()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -64,6 +64,9 @@ public class InstancedRenderStage {
|
||||||
|
|
||||||
uploadMaterialUniform(program, material);
|
uploadMaterialUniform(program, material);
|
||||||
|
|
||||||
|
program.setUInt("_flw_vertexOffset", drawCall.mesh()
|
||||||
|
.baseVertex());
|
||||||
|
|
||||||
MaterialRenderState.setup(material);
|
MaterialRenderState.setup(material);
|
||||||
|
|
||||||
Samplers.INSTANCE_BUFFER.makeActive();
|
Samplers.INSTANCE_BUFFER.makeActive();
|
||||||
|
|
|
@ -14,6 +14,7 @@ public enum DebugMode implements StringRepresentable {
|
||||||
LIGHT_COLOR,
|
LIGHT_COLOR,
|
||||||
OVERLAY,
|
OVERLAY,
|
||||||
DIFFUSE,
|
DIFFUSE,
|
||||||
|
MODEL_ID,
|
||||||
;
|
;
|
||||||
|
|
||||||
public static final Codec<DebugMode> CODEC = StringRepresentable.fromEnum(DebugMode::values);
|
public static final Codec<DebugMode> CODEC = StringRepresentable.fromEnum(DebugMode::values);
|
||||||
|
|
|
@ -14,7 +14,7 @@ in vec2 _flw_crumblingTexCoord;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _FLW_DEBUG
|
#ifdef _FLW_DEBUG
|
||||||
flat in uint _flw_instanceID;
|
flat in uvec2 _flw_ids;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
out vec4 _flw_outputColor;
|
out vec4 _flw_outputColor;
|
||||||
|
@ -79,7 +79,7 @@ void _flw_main() {
|
||||||
color = vec4(flw_vertexNormal * .5 + .5, 1.);
|
color = vec4(flw_vertexNormal * .5 + .5, 1.);
|
||||||
break;
|
break;
|
||||||
case 2u:
|
case 2u:
|
||||||
color = _flw_id2Color(_flw_instanceID);
|
color = _flw_id2Color(_flw_ids.x);
|
||||||
break;
|
break;
|
||||||
case 3u:
|
case 3u:
|
||||||
color = vec4(vec2((flw_fragLight * 15.0 + 0.5) / 16.), 0., 1.);
|
color = vec4(vec2((flw_fragLight * 15.0 + 0.5) / 16.), 0., 1.);
|
||||||
|
@ -93,6 +93,9 @@ void _flw_main() {
|
||||||
case 6u:
|
case 6u:
|
||||||
color = vec4(vec3(diffuseFactor), 1.);
|
color = vec4(vec3(diffuseFactor), 1.);
|
||||||
break;
|
break;
|
||||||
|
case 7u:
|
||||||
|
color = _flw_id2Color(_flw_ids.y);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -72,10 +72,10 @@ mat3 _flw_normalMatrix;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _FLW_DEBUG
|
#ifdef _FLW_DEBUG
|
||||||
flat out uint _flw_instanceID;
|
flat out uvec2 _flw_ids;
|
||||||
#endif
|
#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_layoutVertex();
|
||||||
flw_instanceVertex(instance);
|
flw_instanceVertex(instance);
|
||||||
flw_materialVertex();
|
flw_materialVertex();
|
||||||
|
@ -96,6 +96,6 @@ void _flw_main(in FlwInstance instance, in uint stableInstanceID) {
|
||||||
gl_Position = flw_viewProjection * flw_vertexPos;
|
gl_Position = flw_viewProjection * flw_vertexPos;
|
||||||
|
|
||||||
#ifdef _FLW_DEBUG
|
#ifdef _FLW_DEBUG
|
||||||
_flw_instanceID = stableInstanceID;
|
_flw_ids = uvec2(stableInstanceID, modelID);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,5 +51,5 @@ void main() {
|
||||||
|
|
||||||
FlwInstance instance = _flw_unpackInstance(instanceIndex);
|
FlwInstance instance = _flw_unpackInstance(instanceIndex);
|
||||||
|
|
||||||
_flw_main(instance, instanceIndex);
|
_flw_main(instance, instanceIndex, draw.vertexOffset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ uniform mat4 _flw_modelMatrixUniform;
|
||||||
uniform mat3 _flw_normalMatrixUniform;
|
uniform mat3 _flw_normalMatrixUniform;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uniform uint _flw_vertexOffset;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
_flw_unpackMaterialProperties(_flw_packedMaterial.y, flw_material);
|
_flw_unpackMaterialProperties(_flw_packedMaterial.y, flw_material);
|
||||||
|
|
||||||
|
@ -20,5 +22,5 @@ void main() {
|
||||||
_flw_normalMatrix = _flw_normalMatrixUniform;
|
_flw_normalMatrix = _flw_normalMatrixUniform;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_flw_main(instance, uint(gl_InstanceID));
|
_flw_main(instance, uint(gl_InstanceID), _flw_vertexOffset);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue