Skip to main content

vertex_position

Function vertex_position 

Source
pub fn vertex_position(
    col: u32,
    row: u32,
    mesh: (u32, u32),
    aspect: f32,
) -> (f32, f32, f32, f32)
Expand description

The (x, y, rad, ang) a vertex’s [per_vertex] bindings are evaluated against, for the vertex at column col, row row of a mesh grid, on a render target of aspect aspect.

x and y are the vertex’s uv in 0..=1, with y = 0 at the top — texture space, the space every sampler in this file addresses.

rad is the distance from the mesh centre and ang the angle there, both in the aspect-corrected space of the render target (ADR-0037): rad reaches 1.0 at the middle of the top and bottom edges on any display, and further than that at the sides of a wide one. So a program written as zoom = 1 + rad * 0.2 makes a circular figure on a 16:9 monitor and the same circular figure on a 5:4 one, which is the property the ADR exists for and the reason this takes aspect rather than deriving one from mesh.

ang is in 0..tau, measured counter-clockwise from the +x axis in screen terms (y is flipped on the way in, so a positive angle turns the way an author looking at the screen expects).