Documentation
¶
Index ¶
- func Compile(p *shaderir.Program, version GLSLVersion, projectionMatrixUniformIndex int) (vertexShader, fragmentShader string)
- func Fragment(p *shaderir.Program, name string, o Options) string
- func FragmentPrelude(version GLSLVersion) string
- func UniformLanes(p *shaderir.Program) (lanes []int, size int)
- func VertexPrelude(version GLSLVersion) string
- type GLSLVersion
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compile ¶
func Compile(p *shaderir.Program, version GLSLVersion, projectionMatrixUniformIndex int) (vertexShader, fragmentShader string)
Compile compiles p into GLSL vertex and fragment shaders.
projectionMatrixUniformIndex is the index of the projection matrix uniform variable, or -1 for no adjustment. While the projection matrix's Y scale is negative, the fragment shader's position, Y derivatives, and facing are adjusted as if the window coordinates started at the top.
func Fragment ¶
Fragment returns p's fragment entry point as a function named name of GLSL 3.30 and GLSL ES 3.00, for a renderer's fragment shader to call, after the uniforms (U0, U1, ...), the textures (sampler2D T0, T1, ...) and the functions it reaches:
vec4 name(vec4 position, ...varyings)
The position counts its y from the top of the target, as the renderer passes it.
func FragmentPrelude ¶
func FragmentPrelude(version GLSLVersion) string
func UniformLanes ¶
UniformLanes returns, for each lane of p's uniforms (in order, columns of matrices, elements of arrays: Type.DwordCount of each), its offset in bytes in the std140 uniform block of Fragment, and the block's size, a multiple of 16: a vector of 3 takes the room of 4, and an array's elements and a matrix's columns are 16 bytes apart at least.
func VertexPrelude ¶
func VertexPrelude(version GLSLVersion) string
Types ¶
type GLSLVersion ¶
type GLSLVersion int
const ( GLSLVersionDefault GLSLVersion = iota GLSLVersionES300 )
type Options ¶
type Options struct {
// FlipY is a boolean expression of the renderer's, true where GL's
// window y counts up, as the position's does not, which negates dFdy;
// "" where it never does.
FlipY string
// Block, unless empty, names a uniform block, laid out as std140
// (UniformLanes says how), whose members the uniforms are.
Block string
// FlipRows, unless empty, names a uniform ivec4 that the renderer sets,
// which gives, for each texture, the height of an image whose rows go
// up, as GL's framebuffers draw them, or 0: texel reads flip those.
FlipRows string
}
Options are how Fragment writes a program for a renderer.