pub struct GridStyle {
pub spacing: f32,
pub coarse_multiple: f32,
pub line_width: f32,
pub fade_distance: f32,
pub fine_color: [f32; 4],
pub coarse_color: [f32; 4],
}Expand description
How the grid is drawn.
Every field lands in the shader’s params, fine_color and coarse_color
rows — see shaders/grid.slang for what each one does to a fragment.
Fields§
§spacing: f32The fine cell size, in world units.
coarse_multiple: f32How many fine cells make one coarse cell.
line_width: f32Line width, in pixels. Constant at any zoom, which is the whole point of taking coverage from a screen-space derivative.
fade_distance: f32The distance, in world units, at which the grid has faded to nothing.
fine_color: [f32; 4]The fine lines’ linear RGB, with their peak opacity in a.
coarse_color: [f32; 4]The coarse lines’ linear RGB, with their peak opacity in a.
Composited over the fine lines.
Implementations§
Source§impl GridStyle
impl GridStyle
Sourcepub fn for_extent(extent: f32) -> Self
pub fn for_extent(extent: f32) -> Self
A style scaled to a subject extent world units across.
Default is a metre grid fading at a hundred, which suits content
authored at human scale and nothing else: a five-centimetre model sits
inside a single cell, and a five-hundred-metre one is entirely past the
fade. A viewer opening arbitrary documents cannot assume either.
The spacing snaps to a power of ten. A cell of 0.1, 1 or 10
units is a number a person can count in and do arithmetic with, which is
the grid’s whole job; a cell of 3.7 gives the same line density and
tells the eye nothing. Blender’s adaptive grid steps by powers of ten
for the same reason. So this picks the power of ten nearest to
extent / CELLS_ACROSS rather than that value itself.
A non-finite or non-positive extent returns Default — there is no
scale to derive one from, and a log10 of zero is -inf.
Trait Implementations§
impl Copy for GridStyle
Source§impl Default for GridStyle
impl Default for GridStyle
Source§fn default() -> Self
fn default() -> Self
One-metre cells with a heavier line every ten, fading out at a hundred metres.
A metre because that is the unit the rest of the engine’s 3D content is
authored in — crcbl_greybox::primitives sizes every prototype solid in
metres — so the fine cell is the size of the smallest thing anyone
places, and the coarse cell is the ten-metre block a room is laid out
on.