Skip to content

Commit 76ce99e

Browse files
committed
let's goo
1 parent fd293a5 commit 76ce99e

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

sugarloaf/src/components/rich_text/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,23 @@ impl MetalRichTextBrush {
9696
let attributes = vertex_descriptor.attributes();
9797

9898
// Position (attribute 0) - vec4<f32>
99-
attributes.object_at(0).unwrap().set_format(MTLVertexFormat::Float4);
99+
attributes.object_at(0).unwrap().set_format(MTLVertexFormat::Float3);
100100
attributes.object_at(0).unwrap().set_offset(0);
101101
attributes.object_at(0).unwrap().set_buffer_index(0);
102102

103103
// Color (attribute 1) - vec4<f32>
104104
attributes.object_at(1).unwrap().set_format(MTLVertexFormat::Float4);
105-
attributes.object_at(1).unwrap().set_offset(16);
105+
attributes.object_at(1).unwrap().set_offset(12);
106106
attributes.object_at(1).unwrap().set_buffer_index(0);
107107

108108
// UV (attribute 2) - vec2<f32>
109109
attributes.object_at(2).unwrap().set_format(MTLVertexFormat::Float2);
110-
attributes.object_at(2).unwrap().set_offset(32);
110+
attributes.object_at(2).unwrap().set_offset(28);
111111
attributes.object_at(2).unwrap().set_buffer_index(0);
112112

113113
// Layers (attribute 3) - vec2<i32>
114114
attributes.object_at(3).unwrap().set_format(MTLVertexFormat::Int2);
115-
attributes.object_at(3).unwrap().set_offset(40);
115+
attributes.object_at(3).unwrap().set_offset(36);
116116
attributes.object_at(3).unwrap().set_buffer_index(0);
117117

118118
// Set up buffer layout

sugarloaf/src/components/rich_text/rich_text.metal

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct Globals {
88

99
// Vertex input structure - matches Vertex struct exactly
1010
struct VertexInput {
11-
float4 v_pos [[attribute(0)]]; // Position (first 16 bytes)
11+
float3 v_pos [[attribute(0)]]; // Position (first 12 bytes) - FIXED to float3
1212
float4 v_color [[attribute(1)]]; // Color (next 16 bytes)
1313
float2 v_uv [[attribute(2)]]; // UV coords (next 8 bytes)
1414
int2 layers [[attribute(3)]]; // Layers (next 8 bytes)
@@ -34,8 +34,7 @@ vertex VertexOutput vs_main(
3434
out.color_layer = input.layers.x;
3535
out.mask_layer = input.layers.y;
3636

37-
// Transform position - match WGSL exactly:
38-
// out.position = globals.transform * vec4<f32>(input.v_pos.xy, 0.0, 1.0);
37+
// Transform position - use float4 constructor with z=0.0, w=1.0
3938
out.position = globals.transform * float4(input.v_pos.xy, 0.0, 1.0);
4039

4140
return out;
@@ -50,23 +49,14 @@ fragment float4 fs_main(
5049
) {
5150
float4 out = input.f_color;
5251

53-
// Match WGSL logic exactly:
54-
// if input.color_layer > 0 {
55-
// out = textureSampleLevel(color_texture, font_sampler, input.f_uv, 0.0);
56-
// }
5752
if (input.color_layer > 0) {
5853
out = color_texture.sample(font_sampler, input.f_uv, level(0.0));
5954
}
6055

61-
// if input.mask_layer > 0 {
62-
// out = vec4<f32>(out.xyz, input.f_color.a * textureSampleLevel(mask_texture, font_sampler, input.f_uv, 0.0).x);
63-
// }
6456
if (input.mask_layer > 0) {
6557
float mask_alpha = mask_texture.sample(font_sampler, input.f_uv, level(0.0)).x;
6658
out = float4(out.xyz, input.f_color.a * mask_alpha);
6759
}
6860

6961
return out;
70-
}
71-
// Force all pixels to be bright green to test if shader is running at all
72-
// return float4(0.0, 1.0, 0.0, 1.0);
62+
}

0 commit comments

Comments
 (0)