Skip to content

Commit

Permalink
Render SDF sharp for the in-game UI
Browse files Browse the repository at this point in the history
  • Loading branch information
hasenbanck committed Dec 17, 2024
1 parent 92d3c57 commit ddda1d8
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 4 deletions.
Binary file modified korangar/archive/data/texture/marker_entity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified korangar/archive/data/texture/marker_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified korangar/archive/data/texture/marker_object.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified korangar/archive/data/texture/marker_particle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified korangar/archive/data/texture/marker_shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified korangar/archive/data/texture/marker_sound.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
case 1u: {
// SDF
let pixel = textureSample(texture, linear_sampler, input.texture_coordinates);
return vec4(pixel.rgb, saturate((pixel.a - 0.5) * 2.0 / fwidth(pixel.a))) * instance.color;
return vec4(pixel.rgb, step(0.5, pixel.a)) * instance.color;
}
case 2u: {
// Sprite (linear filtering)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
case 1u: {
// SDF
let pixel = textureSample(textures[instance.texture_index], linear_sampler, input.texture_coordinates);
return vec4(pixel.rgb, saturate((pixel.a - 0.5) * 2.0 / fwidth(pixel.a))) * instance.color;
return vec4(pixel.rgb, step(0.5, pixel.a)) * instance.color;
}
case 2u: {
// Sprite (linear filtering)
Expand Down
3 changes: 1 addition & 2 deletions korangar/src/renderer/game_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,12 @@ impl MarkerRenderer for GameInterfaceRenderer {
MarkerIdentifier::Shadow(..) => (&self.shadow_marker_texture, Color::rgb_u8(170, 170, 170)),
};

self.instructions.borrow_mut().push(RectangleInstruction::Sprite {
self.instructions.borrow_mut().push(RectangleInstruction::Sdf {
screen_position,
screen_size,
color,
texture_position: Vector2::new(0.0, 0.0),
texture_size: Vector2::new(1.0, 1.0),
linear_filtering: true,
texture: texture.clone(),
});
}
Expand Down

0 comments on commit ddda1d8

Please sign in to comment.