Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion korangar/shaders/modules/interface.slang
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public struct RectangleInstanceData {
public var texture_size: float2;
public var rectangle_type: uint;
public var texture_index: int;
public var rotation: float;
public var padding: uint;
};

public struct RectangleVertexInput {
Expand Down Expand Up @@ -258,7 +260,19 @@ public func rectangle_vertex_shader(
adjusted_size += shadow_expansion;

let clip_size = adjusted_size * 2.0;
let position = coordinate_space::screen_to_clip_space(instance.screen_position + position_offset) + vertex.xy * clip_size;

var rotated_vertex = vertex.xy * clip_size;
if (instance.rotation != 0.0) {
let center = float2(0.5, -0.5) * clip_size;
let c = cos(instance.rotation);
let s = sin(instance.rotation);
let p = rotated_vertex - center;
let rx = p.x * c - p.y * s;
let ry = p.x * s + p.y * c;
rotated_vertex = float2(rx, ry) + center;
}

let position = coordinate_space::screen_to_clip_space(instance.screen_position + position_offset) + rotated_vertex;

var output: RectangleVertexOutput;
output.position = float4(position, 0.0, 1.0);
Expand Down
2 changes: 2 additions & 0 deletions korangar/shaders/modules/postprocessing.slang
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public struct RectangleInstanceData {
public var texture_size: float2;
public var rectangle_type: uint;
public var texture_index: int;
public var rotation: float;
public var padding: uint;
}

public struct DebugUniforms {
Expand Down
12 changes: 11 additions & 1 deletion korangar/shaders/passes/postprocessing/rectangle.slang
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ func vs_main(input: PostprocessingVertexInput) -> PostprocessingVertexOutput {
let vertex = rectangle_vertex_data(input.vertex_index);

let clip_size = instance.screen_size * 2.0;
let position = screen_to_clip_space(instance.screen_position) + vertex.xy * clip_size;
var rotated_vertex = vertex.xy * clip_size;
if (instance.rotation != 0.0) {
let center = float2(0.5, -0.5) * clip_size;
let c = cos(instance.rotation);
let s = sin(instance.rotation);
let p = rotated_vertex - center;
let rx = p.x * c - p.y * s;
let ry = p.x * s + p.y * c;
rotated_vertex = float2(rx, ry) + center;
}
let position = screen_to_clip_space(instance.screen_position) + rotated_vertex;

var output: PostprocessingVertexOutput;
output.position = float4(position, 0.0, 1.0);
Expand Down
12 changes: 11 additions & 1 deletion korangar/shaders/passes/postprocessing/rectangle_bindless.slang
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ func vs_main(input: PostprocessingVertexInput) -> PostprocessingVertexOutput {
let vertex = rectangle_vertex_data(input.vertex_index);

let clip_size = instance.screen_size * 2.0;
let position = screen_to_clip_space(instance.screen_position) + vertex.xy * clip_size;
var rotated_vertex = vertex.xy * clip_size;
if (instance.rotation != 0.0) {
let center = float2(0.5, -0.5) * clip_size;
let c = cos(instance.rotation);
let s = sin(instance.rotation);
let p = rotated_vertex - center;
let rx = p.x * c - p.y * s;
let ry = p.x * s + p.y * c;
rotated_vertex = float2(rx, ry) + center;
}
let position = screen_to_clip_space(instance.screen_position) + rotated_vertex;

var output: PostprocessingVertexOutput;
output.position = float4(position, 0.0, 1.0);
Expand Down
4 changes: 4 additions & 0 deletions korangar/src/graphics/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ pub enum RectangleInstruction {
texture_size: Vector2<f32>,
linear_filtering: bool,
texture: Arc<Texture>,
rotation: f32,
},
Sdf {
screen_position: ScreenPosition,
Expand All @@ -192,6 +193,7 @@ pub enum RectangleInstruction {
texture_position: Vector2<f32>,
texture_size: Vector2<f32>,
texture: Arc<Texture>,
rotation: f32,
},
Text {
screen_position: ScreenPosition,
Expand Down Expand Up @@ -221,6 +223,7 @@ pub enum InterfaceRectangleInstruction {
corner_diameter: CornerDiameter,
texture: Arc<Texture>,
smooth: bool,
rotation: f32,
},
Sdf {
screen_position: ScreenPosition,
Expand All @@ -229,6 +232,7 @@ pub enum InterfaceRectangleInstruction {
color: Color,
corner_diameter: CornerDiameter,
texture: Arc<Texture>,
rotation: f32,
},
Text {
screen_position: ScreenPosition,
Expand Down
15 changes: 14 additions & 1 deletion korangar/src/graphics/passes/interface/rectangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ struct InstanceData {
texture_size: [f32; 2],
rectangle_type: u32,
texture_index: i32,
padding: [f32; 2],
rotation: f32,
padding: f32,
}

pub(crate) struct InterfaceRectangleDrawer {
Expand Down Expand Up @@ -293,6 +294,7 @@ impl Prepare for InterfaceRectangleDrawer {
texture_size: [1.0, 1.0],
rectangle_type: 0,
texture_index: 0,
rotation: 0.0,
padding: Default::default(),
});
}
Expand All @@ -304,6 +306,7 @@ impl Prepare for InterfaceRectangleDrawer {
corner_diameter,
texture,
smooth,
rotation,
} => {
let rectangle_type = if *smooth { 1 } else { 2 };

Expand All @@ -330,6 +333,7 @@ impl Prepare for InterfaceRectangleDrawer {
texture_size: [1.0, 1.0],
rectangle_type,
texture_index,
rotation: *rotation,
padding: Default::default(),
});
}
Expand All @@ -340,6 +344,7 @@ impl Prepare for InterfaceRectangleDrawer {
color,
corner_diameter,
texture,
rotation,
} => {
let mut texture_index = texture_views.len() as i32;
let id = texture.get_id();
Expand All @@ -364,6 +369,7 @@ impl Prepare for InterfaceRectangleDrawer {
texture_size: [1.0, 1.0],
rectangle_type: 3,
texture_index,
rotation: *rotation,
padding: Default::default(),
});
}
Expand All @@ -387,6 +393,7 @@ impl Prepare for InterfaceRectangleDrawer {
texture_size: (*texture_size).into(),
rectangle_type: 4,
texture_index: 0,
rotation: 0.0,
padding: Default::default(),
});
}
Expand Down Expand Up @@ -429,6 +436,7 @@ impl Prepare for InterfaceRectangleDrawer {
texture_size: [1.0, 1.0],
rectangle_type: 0,
texture_index: 0,
rotation: 0.0,
padding: Default::default(),
});
}
Expand All @@ -441,6 +449,7 @@ impl Prepare for InterfaceRectangleDrawer {
corner_diameter,
texture: _,
smooth,
rotation,
} => {
let rectangle_type = if *smooth { 1 } else { 2 };

Expand All @@ -456,6 +465,7 @@ impl Prepare for InterfaceRectangleDrawer {
texture_size: [1.0, 1.0],
rectangle_type,
texture_index: 0,
rotation: *rotation,
padding: Default::default(),
});
}
Expand All @@ -466,6 +476,7 @@ impl Prepare for InterfaceRectangleDrawer {
color,
corner_diameter,
texture: _,
rotation,
} => {
self.instance_data.push(InstanceData {
color: color.components_linear(),
Expand All @@ -479,6 +490,7 @@ impl Prepare for InterfaceRectangleDrawer {
texture_size: [1.0, 1.0],
rectangle_type: 3,
texture_index: 0,
rotation: *rotation,
padding: Default::default(),
});
}
Expand All @@ -502,6 +514,7 @@ impl Prepare for InterfaceRectangleDrawer {
texture_size: (*texture_size).into(),
rectangle_type: 4,
texture_index: 0,
rotation: 0.0,
padding: Default::default(),
});
}
Expand Down
15 changes: 14 additions & 1 deletion korangar/src/graphics/passes/postprocessing/rectangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ pub(crate) struct InstanceData {
texture_size: [f32; 2],
rectangle_type: u32,
texture_index: i32,
padding: [u32; 2],
rotation: f32,
padding: u32,
}

#[derive(Default, Copy, Clone)]
Expand Down Expand Up @@ -318,6 +319,7 @@ impl Prepare for PostProcessingRectangleDrawer {
texture_size: [0.0; 2],
rectangle_type: 0,
texture_index: -1,
rotation: 0.0,
padding: Default::default(),
});
}
Expand All @@ -329,6 +331,7 @@ impl Prepare for PostProcessingRectangleDrawer {
texture_size,
linear_filtering,
texture,
rotation,
} => {
let rectangle_type = if *linear_filtering { 1 } else { 2 };

Expand All @@ -351,6 +354,7 @@ impl Prepare for PostProcessingRectangleDrawer {
texture_size: (*texture_size).into(),
rectangle_type,
texture_index,
rotation: *rotation,
padding: Default::default(),
});
}
Expand All @@ -361,6 +365,7 @@ impl Prepare for PostProcessingRectangleDrawer {
texture_position,
texture_size,
texture,
rotation,
} => {
let mut texture_index = texture_views.len() as i32;
let id = texture.get_id();
Expand All @@ -381,6 +386,7 @@ impl Prepare for PostProcessingRectangleDrawer {
texture_size: (*texture_size).into(),
rectangle_type: 3,
texture_index,
rotation: *rotation,
padding: Default::default(),
});
}
Expand All @@ -399,6 +405,7 @@ impl Prepare for PostProcessingRectangleDrawer {
texture_size: (*texture_size).into(),
rectangle_type: 4,
texture_index: -1,
rotation: 0.0,
padding: Default::default(),
});
}
Expand Down Expand Up @@ -448,6 +455,7 @@ impl Prepare for PostProcessingRectangleDrawer {
texture_size: [0.0; 2],
rectangle_type: 0,
texture_index: -1,
rotation: 0.0,
padding: Default::default(),
});
}
Expand All @@ -459,6 +467,7 @@ impl Prepare for PostProcessingRectangleDrawer {
texture_size,
linear_filtering,
texture: _,
rotation,
} => {
let rectangle_type = if *linear_filtering { 1 } else { 2 };

Expand All @@ -470,6 +479,7 @@ impl Prepare for PostProcessingRectangleDrawer {
texture_size: (*texture_size).into(),
rectangle_type,
texture_index: 0,
rotation: *rotation,
padding: Default::default(),
});
}
Expand All @@ -480,6 +490,7 @@ impl Prepare for PostProcessingRectangleDrawer {
texture_position,
texture_size,
texture: _,
rotation,
} => {
self.instance_data.push(InstanceData {
color: color.components_linear(),
Expand All @@ -489,6 +500,7 @@ impl Prepare for PostProcessingRectangleDrawer {
texture_size: (*texture_size).into(),
rectangle_type: 3,
texture_index: 0,
rotation: *rotation,
padding: Default::default(),
});
}
Expand All @@ -507,6 +519,7 @@ impl Prepare for PostProcessingRectangleDrawer {
texture_size: (*texture_size).into(),
rectangle_type: 4,
texture_index: -1,
rotation: 0.0,
padding: Default::default(),
});
}
Expand Down
2 changes: 2 additions & 0 deletions korangar/src/input/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ pub enum InputEvent {
ToggleAudioSettingsWindow,
/// Open or close the friend list window. Only works while playing.
ToggleFriendListWindow,
/// Open or close the minimap window. Only works while playing.
ToggleMinimapWindow,
/// Close the most recently opened or clicked closable window.
CloseTopWindow,
/// Toggle if the user interface should be rendered or not.
Expand Down
4 changes: 4 additions & 0 deletions korangar/src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ impl InputSystem {
events.push(InputEvent::ToggleFriendListWindow);
}

if alt_down && self.get_key(KeyCode::KeyM).pressed() {
events.push(InputEvent::ToggleMinimapWindow);
}

if alt_down && self.get_key(KeyCode::KeyQ).pressed() {
events.push(InputEvent::ToggleEquipmentWindow);
}
Expand Down
Loading