mirror of
https://github.com/hannobraun/Fornjot
synced 2025-07-19 08:26:05 +00:00
Draw vertices as circles
This commit is contained in:
parent
01a12b5c88
commit
0b2e3ecbcf
@ -32,7 +32,11 @@ impl Geometry {
|
||||
for vertex in [a, b, c, c, b, d] {
|
||||
let index = vertices.len() as u32;
|
||||
|
||||
let vertex = VerticesVertex { position: vertex };
|
||||
let vertex = VerticesVertex {
|
||||
position: vertex,
|
||||
center: p.coords.components.map(|s| s.value() as f32),
|
||||
radius: s as f32,
|
||||
};
|
||||
|
||||
vertices.push(vertex);
|
||||
indices.push(index);
|
||||
|
@ -134,10 +134,14 @@ impl Vertex for TrianglesVertex {
|
||||
#[repr(C)]
|
||||
pub struct VerticesVertex {
|
||||
pub position: [f32; 3],
|
||||
pub center: [f32; 3],
|
||||
pub radius: f32,
|
||||
}
|
||||
|
||||
impl Vertex for VerticesVertex {
|
||||
const ATTRIBUTES: &[wgpu::VertexAttribute] = &wgpu::vertex_attr_array![
|
||||
0 => Float32x3,
|
||||
1 => Float32x3,
|
||||
2 => Float32,
|
||||
];
|
||||
}
|
||||
|
@ -8,22 +8,36 @@ var<uniform> uniforms: Uniforms;
|
||||
|
||||
struct VertexInput {
|
||||
@location(0) position: vec3<f32>,
|
||||
@location(1) center: vec3<f32>,
|
||||
@location(2) radius: f32,
|
||||
}
|
||||
|
||||
struct VertexOutput {
|
||||
@builtin(position) position: vec4<f32>,
|
||||
@location(0) point: vec3<f32>,
|
||||
@location(1) center: vec3<f32>,
|
||||
@location(2) radius: f32,
|
||||
}
|
||||
|
||||
@vertex
|
||||
fn vertex(in: VertexInput) -> VertexOutput {
|
||||
var out: VertexOutput;
|
||||
|
||||
out.position = uniforms.transform * vec4(in.position, 1.0);
|
||||
|
||||
out.point = in.position;
|
||||
out.center = in.center;
|
||||
out.radius = in.radius;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
if length(in.center - in.point) > in.radius {
|
||||
discard;
|
||||
}
|
||||
|
||||
var color = vec4(0.5, 0.5, 0.5, 1.0);
|
||||
return color;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user