Documentation
¶
Overview ¶
Package shader compiles shaders written in Go's syntax into the intermediate representation of package shaderir, which its backends translate for each platform's GPU API.
It is Ebitengine's Kage compiler (github.com/hajimehoshi/ebiten, internal/shader and internal/shaderir at commit 16f18b0), under the Apache License 2.0 in LICENSE, as MyGo (github.com/egoist/mygo, v0.6.3, MIT License) forked it to compile fragment shaders as libraries. Files that came from Ebitengine keep its copyright notice and say where MyGo changed them. NSGo's bridge (bridge.go) declares only the view's size and scale: shaders read no images yet.
Index ¶
Constants ¶
const ( RectSizeUniform = "__rectSize" ScaleUniform = "__scale" ImageSizesUniform = "__imageSizes" )
The uniform variables the bridge declares, which platforms set, before the shader's own: the size of the view the shader fills in points, and the pixels a point.
const ( // InternalRegionBegin is the line that begins the internal region. InternalRegionBegin = internalRegionDirective + " begin" // InternalRegionEnd is the line that ends the internal region. InternalRegionEnd = internalRegionDirective + " end" )
const Entry = "Fragment"
Entry is the name of a shader's entry point, which returns the color of a pixel, premultiplied:
func Fragment(dst vec4, pos vec2) vec4
dst is the pixel's center in the shader's view, in its pixels from the top left corner, and pos the same point in points. It may take dst alone, or nothing.
const MaxImages = 4
MaxImages is how many images a shader reads at most: image0 to image3.
Variables ¶
This section is empty.
Functions ¶
func BridgeLanes ¶
BridgeLanes is how many lanes the bridge's uniforms of p take, before the shader's own: the view's size and scale, then each image's size in pixels.
func Compile ¶
func Compile(src []byte, vertexEntry, fragmentEntry string, textureCount int) (*shaderir.Program, error)
Compile compiles a Kage source into an intermediate representation.
A uniform variable whose name starts with __ can be declared only in the internal region, which is the lines between InternalRegionBegin and InternalRegionEnd. A source can have at most one internal region.
Types ¶
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
func (*ParseError) Error ¶
func (p *ParseError) Error() string
func (*ParseError) Positions ¶
func (p *ParseError) Positions() []token.Position
Positions returns the source positions of the errors, in the same order as ParseError.Error reports them.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package wgsl compiles the shaders TSX apps write in WGSL, as NSH's are, into package shaderir's programs, which every backend draws as it draws a Kage program (package shader).
|
Package wgsl compiles the shaders TSX apps write in WGSL, as NSH's are, into package shaderir's programs, which every backend draws as it draws a Kage program (package shader). |