diff --git a/src/main/java/com/jozufozu/flywheel/backend/InternalVertex.java b/src/main/java/com/jozufozu/flywheel/backend/InternalVertex.java index 37052a5c9..74bd5cef0 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/InternalVertex.java +++ b/src/main/java/com/jozufozu/flywheel/backend/InternalVertex.java @@ -4,7 +4,6 @@ import java.util.List; import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.api.layout.FloatRepr; -import com.jozufozu.flywheel.api.layout.IntegerRepr; import com.jozufozu.flywheel.api.layout.Layout; import com.jozufozu.flywheel.api.layout.LayoutBuilder; import com.jozufozu.flywheel.api.vertex.VertexView; @@ -19,7 +18,7 @@ public final class InternalVertex { .vector("position", FloatRepr.FLOAT, 3) .vector("color", FloatRepr.NORMALIZED_UNSIGNED_BYTE, 4) .vector("tex", FloatRepr.FLOAT, 2) - .vector("overlay", IntegerRepr.SHORT, 2) + .vector("overlay", FloatRepr.SHORT, 2) .vector("light", FloatRepr.UNSIGNED_SHORT, 2) .vector("normal", FloatRepr.NORMALIZED_BYTE, 3) .build(); diff --git a/src/main/resources/assets/flywheel/flywheel/internal/vertex_input.vert b/src/main/resources/assets/flywheel/flywheel/internal/vertex_input.vert index 776f12513..d77f66665 100644 --- a/src/main/resources/assets/flywheel/flywheel/internal/vertex_input.vert +++ b/src/main/resources/assets/flywheel/flywheel/internal/vertex_input.vert @@ -1,7 +1,7 @@ in vec3 _flw_a_pos; in vec4 _flw_a_color; in vec2 _flw_a_texCoord; -in ivec2 _flw_a_overlay; +in vec2 _flw_a_overlay; in vec2 _flw_a_light; in vec3 _flw_a_normal; @@ -9,10 +9,9 @@ void _flw_layoutVertex() { flw_vertexPos = vec4(_flw_a_pos, 1.0); flw_vertexColor = _flw_a_color; flw_vertexTexCoord = _flw_a_texCoord; - // Need to clamp the overlay texture coords to sane coordinates because integer vertex attributes explode on - // some drivers for some draw calls. This should only effect instances that don't write to overlay, but - // the internal vertex format is unfortunately subject to these issues. - flw_vertexOverlay = clamp(_flw_a_overlay, 0, 15); + // Integer vertex attributes explode on some drivers for some draw calls, so get the driver + // to cast the int to a float so we can cast it back to an int and reliably get a sane value. + flw_vertexOverlay = ivec2(_flw_a_overlay); flw_vertexLight = _flw_a_light / 256.0; flw_vertexNormal = _flw_a_normal; }