Documentation
¶
Index ¶
- Constants
- Variables
- func BuildMapStrokes(dev *wgpu.Device, strokeGeoms []StrokeGeometry, strokeWidthPx float32, ...) (*render.StrokeBuffer, [MaxRank + 1]int)
- func RankForZoom(zoom float32) int
- type DrawPassSpec
- type FillGeometry
- type MapMesh
- type MapMeshConfig
- type MapPipeline
- type MapVertex
- type PassRange
- type StrokeGeometry
Constants ¶
const MaxRank = 12
MaxRank is the highest rank the data uses. The filter clamps to 0..12, so a pass keeps one cumulative count per rank in that range.
Variables ¶
var MapVertexLayout = gputypes.VertexBufferLayout{ ArrayStride: 12, StepMode: gputypes.VertexStepModeVertex, Attributes: []gputypes.VertexAttribute{ {Format: gputypes.VertexFormatSint32x2, Offset: 0, ShaderLocation: 0}, {Format: gputypes.VertexFormatUnorm8x4, Offset: 8, ShaderLocation: 1}, }, }
MapVertexLayout describes the buffer layout for MapVertex.
Functions ¶
func BuildMapStrokes ¶
func BuildMapStrokes( dev *wgpu.Device, strokeGeoms []StrokeGeometry, strokeWidthPx float32, minSegmentPx float32, ) (*render.StrokeBuffer, [MaxRank + 1]int)
BuildMapStrokes returns the segment buffer and, per rank, how many of its segments to draw at that level of detail. Segments are emitted in ascending rank, so a level of detail is a prefix.
It operates on generic StrokeGeometry rather than map-specific types.
func RankForZoom ¶
RankForZoom is the maximum rank worth drawing at a given zoom, which is the filter the map data documents: the more ground a pixel covers, the fewer minor rivers and lakes are worth drawing.
Types ¶
type DrawPassSpec ¶
type DrawPassSpec struct {
GeomIndices []int32
FillColor *render.Color
StrokeColor *render.Color
RankFilter bool
}
DrawPassSpec describes one ordered group of geometries to draw together.
type FillGeometry ¶
FillGeometry is one triangulated polygon ready for GPU upload.
type MapMesh ¶
MapMesh holds pre-built GPU geometry for the entire map.
func BuildMapMesh ¶
func BuildMapMesh( dev *wgpu.Device, fillGeoms []FillGeometry, passes []DrawPassSpec, cfg MapMeshConfig, ) *MapMesh
BuildMapMesh triangulates fills and uploads them to a single GPU vertex buffer. It operates on generic FillGeometry and DrawPassSpec rather than map-specific types.
type MapMeshConfig ¶
type MapMeshConfig struct {
StrokeWidthPx float32
MinSegmentPx float32
RefZoom float32
Scale float32
}
MapMeshConfig controls how the map mesh is built.
type MapPipeline ¶
type MapPipeline struct {
// contains filtered or unexported fields
}
MapPipeline renders pre-built map geometry through the engine's camera. Positions are int32 world-space coords; the viewProj matrix bakes in the scale divisor so the shader just multiplies.
It is an example of a pipeline built outside the engine: it lists the engine's camera layout as group 0, reads the camera at group(0) binding(0), and owns no camera buffer. render.GPU binds and updates that for it, so nothing here has to be told when the view moves.
func NewMapPipeline ¶
func NewMapPipeline(dev *wgpu.Device, format gputypes.TextureFormat, camBGL *wgpu.BindGroupLayout) *MapPipeline
NewMapPipeline creates the pipeline for pre-built map geometry. camBGL is render.GPU.CameraLayout().
func (*MapPipeline) Pipeline ¶
func (p *MapPipeline) Pipeline() *wgpu.RenderPipeline
func (*MapPipeline) Release ¶
func (p *MapPipeline) Release()
type MapVertex ¶
MapVertex is a compact 12-byte vertex for pre-built map geometry. Positions are raw int32 world-space coords (divided by Scale in the shader). Colors are quantized to uint8 (2x compression vs float32 Vertex).
type PassRange ¶
PassRange records the vertex range for one DrawOrder pass in the shared buffer, and how much of that range each level of detail needs.
Geometry within a pass is emitted in ascending rank order, so everything up to a given rank is a prefix of the range. Drawing a level of detail is then a smaller Count rather than a per-frame cull: ByRank[r] is how many vertices to draw when the maximum rank is r.