mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-23 03:17:53 +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;
|
||||
}
|
||||
|
||||
public MeshPool.PooledMesh mesh() {
|
||||
return mesh;
|
||||
}
|
||||
|
||||
public void render(TextureBuffer buffer) {
|
||||
if (mesh.isInvalid()) {
|
||||
return;
|
||||
|
|
|
@ -64,6 +64,9 @@ public class InstancedRenderStage {
|
|||
|
||||
uploadMaterialUniform(program, material);
|
||||
|
||||
program.setUInt("_flw_vertexOffset", drawCall.mesh()
|
||||
.baseVertex());
|
||||
|
||||
MaterialRenderState.setup(material);
|
||||
|
||||
Samplers.INSTANCE_BUFFER.makeActive();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -51,5 +51,5 @@ void main() {
|
|||
|
||||
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;
|
||||
#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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue