@@ -46,11 +46,11 @@ struct DynObjVSOutput {
4646@vertex
4747fn vs_dynamic_object_icon (model : DynObjVertexInput , instance : DynObjInstanceInput ) -> DynObjVSOutput {
4848 var out : DynObjVSOutput ;
49-
49+
5050 let world_pos = vec3 <f32 >(instance . instance_pos + model . position , 2 .0 );
5151 let pos_in_view = world_pos - camera . world_offset . xyz ;
5252 out . clip_position = camera . view_proj * vec4 <f32 >(pos_in_view , 1 .0 );
53-
53+
5454 // Pass model position to fragment shader for UV calculation
5555 // Remap from [-0.5, 0.5] to [0, 1]
5656 out . uv = model . position + 0 .5 ;
@@ -117,15 +117,15 @@ fn render_block_icon(uv: vec2<f32>, block_type_id: u32) -> vec4<f32> {
117117 face_normal = select (vec3 <f32 >(0 .0 , 0 .0 , - 1 .0 ), vec3 <f32 >(0 .0 , 0 .0 , 1 .0 ), hit_pos . z > 0 .0 ); // Set normal
118118 }
119119 face_uv . y = 1 .0 - face_uv . y ;
120-
120+
121121 // Now sample the tilemap using the determined face
122122 let atlas_lookup_idx = (block_type_id * 6u ) + hit_face_id ;
123123 let tile_index = voxel_uv_atlas [atlas_lookup_idx ];
124-
124+
125125 let tile_x = f32 (tile_index % VOXEL_TILES_PER_ROW );
126126 let tile_y = f32 (tile_index / VOXEL_TILES_PER_ROW );
127127 let uv_min_tile = vec2 <f32 >(tile_x * VOXEL_TILE_SIZE_UV , tile_y * VOXEL_TILE_SIZE_UV );
128-
128+
129129 let final_atlas_uv = uv_min_tile + face_uv * VOXEL_TILE_SIZE_UV ;
130130 var surface_color = textureSampleLevel (tilemap_texture , tilemap_sampler , final_atlas_uv , 0 .0 );
131131
@@ -156,7 +156,7 @@ fn fs_dynamic_object_icon(in: DynObjVSOutput) -> @location(0) vec4<f32> {
156156 let tile_x = f32 (tile_index % ITEMS_TILES_PER_ROW );
157157 let tile_y = f32 (tile_index / ITEMS_TILES_PER_ROW );
158158 let uv_min_tile = vec2 <f32 >(tile_x * ITEMS_TILE_SIZE_UV . x , tile_y * ITEMS_TILE_SIZE_UV . y );
159-
159+
160160 let final_atlas_uv = uv_min_tile + in . uv * ITEMS_TILE_SIZE_UV ;
161161 final_color = textureSampleLevel (items_texture , items_sampler , final_atlas_uv , 0 .0 );
162162 }
@@ -174,7 +174,7 @@ fn fs_dynamic_object_icon(in: DynObjVSOutput) -> @location(0) vec4<f32> {
174174 // You might want a more sophisticated blend mode depending on desired effect
175175 final_color = mix (final_color , outline_color , outline_color . a );
176176 }
177-
177+
178178 let gamma = 2 .2 ;
179179 let corrected_color = pow (final_color . rgb , vec3 <f32 >(1 .0 / gamma ));
180180 return vec4 <f32 >(corrected_color , final_color . a );
0 commit comments