Like a game of telephone

- Fix overlay via casting
- Saw cortex doing this in nvidium, and it seems obvious in hindsight
This commit is contained in:
Jozufozu 2024-03-08 16:06:24 -08:00
parent e7a112d773
commit cfe6f3901b
2 changed files with 5 additions and 7 deletions

View file

@ -4,7 +4,6 @@ import java.util.List;
import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.layout.FloatRepr; 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.Layout;
import com.jozufozu.flywheel.api.layout.LayoutBuilder; import com.jozufozu.flywheel.api.layout.LayoutBuilder;
import com.jozufozu.flywheel.api.vertex.VertexView; import com.jozufozu.flywheel.api.vertex.VertexView;
@ -19,7 +18,7 @@ public final class InternalVertex {
.vector("position", FloatRepr.FLOAT, 3) .vector("position", FloatRepr.FLOAT, 3)
.vector("color", FloatRepr.NORMALIZED_UNSIGNED_BYTE, 4) .vector("color", FloatRepr.NORMALIZED_UNSIGNED_BYTE, 4)
.vector("tex", FloatRepr.FLOAT, 2) .vector("tex", FloatRepr.FLOAT, 2)
.vector("overlay", IntegerRepr.SHORT, 2) .vector("overlay", FloatRepr.SHORT, 2)
.vector("light", FloatRepr.UNSIGNED_SHORT, 2) .vector("light", FloatRepr.UNSIGNED_SHORT, 2)
.vector("normal", FloatRepr.NORMALIZED_BYTE, 3) .vector("normal", FloatRepr.NORMALIZED_BYTE, 3)
.build(); .build();

View file

@ -1,7 +1,7 @@
in vec3 _flw_a_pos; in vec3 _flw_a_pos;
in vec4 _flw_a_color; in vec4 _flw_a_color;
in vec2 _flw_a_texCoord; in vec2 _flw_a_texCoord;
in ivec2 _flw_a_overlay; in vec2 _flw_a_overlay;
in vec2 _flw_a_light; in vec2 _flw_a_light;
in vec3 _flw_a_normal; in vec3 _flw_a_normal;
@ -9,10 +9,9 @@ void _flw_layoutVertex() {
flw_vertexPos = vec4(_flw_a_pos, 1.0); flw_vertexPos = vec4(_flw_a_pos, 1.0);
flw_vertexColor = _flw_a_color; flw_vertexColor = _flw_a_color;
flw_vertexTexCoord = _flw_a_texCoord; flw_vertexTexCoord = _flw_a_texCoord;
// Need to clamp the overlay texture coords to sane coordinates because integer vertex attributes explode on // Integer vertex attributes explode on some drivers for some draw calls, so get the driver
// some drivers for some draw calls. This should only effect instances that don't write to overlay, but // to cast the int to a float so we can cast it back to an int and reliably get a sane value.
// the internal vertex format is unfortunately subject to these issues. flw_vertexOverlay = ivec2(_flw_a_overlay);
flw_vertexOverlay = clamp(_flw_a_overlay, 0, 15);
flw_vertexLight = _flw_a_light / 256.0; flw_vertexLight = _flw_a_light / 256.0;
flw_vertexNormal = _flw_a_normal; flw_vertexNormal = _flw_a_normal;
} }