shaders

package
v0.0.0-...-ecc5831 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 2 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DiffuseFragmentShader string
View Source
var DiffuseShader = ShaderConfig{
	VertexShader:   DiffuseVertexShader,
	FragmentShader: DiffuseFragmentShader,
	VertexFormat: VertexFormat{
		VertexAttribute("positionIn", AttrVec3, PositionXYZ),
		VertexAttribute("normalIn", AttrVec3, NormalXYZ),

		VertexAttribute("texCoordIn", AttrVec2, TexCoordXY),
	},
	UniformFormat: UniformFormat{
		Attr{"model", AttrMat4},
		Attr{"view", AttrMat4},
		Attr{"projection", AttrMat4},

		Attr{"viewPos", AttrVec3},

		Attr{"material.ambient", AttrVec3},
		Attr{"material.diffuse", AttrVec3},
		Attr{"material.specular", AttrVec3},
		Attr{"material.shininess", AttrFloat},

		Attr{"dirLight.direction", AttrVec3},
		Attr{"dirLight.ambient", AttrVec3},
		Attr{"dirLight.diffuse", AttrVec3},
		Attr{"dirLight.specular", AttrVec3},
	},
}
View Source
var DiffuseVertexShader string
View Source
var MSDFFragmentShader string
View Source
var MSDFShader = ShaderConfig{
	VertexShader:   SpriteVertexShader,
	FragmentShader: MSDFFragmentShader,
	VertexFormat: VertexFormat{
		VertexAttribute("positionIn", AttrVec3, PositionXYZ),
		VertexAttribute("colorIn", AttrVec4, ColorRGBA),
		VertexAttribute("texCoordIn", AttrVec2, TexCoordXY),
	},
	UniformFormat: UniformFormat{
		Attr{"model", AttrMat4},
		Attr{"projection", AttrMat4},
		Attr{"view", AttrMat4},
		Attr{"u_threshold", AttrFloat},
		Attr{"u_outline_width_relative", AttrFloat},
		Attr{"u_outline_blur", AttrFloat},
		Attr{"u_outline_color", AttrVec4},
	},
}
View Source
var MinimapFragmentShader string
View Source
var MinimapShader = ShaderConfig{
	VertexShader:   SpriteVertexShader,
	FragmentShader: MinimapFragmentShader,
	VertexFormat: VertexFormat{
		VertexAttribute("positionIn", AttrVec3, PositionXYZ),
		VertexAttribute("colorIn", AttrVec4, ColorRGBA),
		VertexAttribute("texCoordIn", AttrVec2, TexCoordXY),
	},
	UniformFormat: UniformFormat{
		Attr{"model", AttrMat4},
		Attr{"projection", AttrMat4},
		Attr{"view", AttrMat4},
	},
}
View Source
var PixelArtFrag string
View Source
var PixelArtShader = ShaderConfig{
	VertexShader:   PixelArtVert,
	FragmentShader: SubPixelAntiAliased,

	VertexFormat: VertexFormat{
		VertexAttribute("positionIn", AttrVec3, PositionXYZ),
		VertexAttribute("colorIn", AttrVec4, ColorRGBA),
		VertexAttribute("texCoordIn", AttrVec2, TexCoordXY),
	},
	UniformFormat: UniformFormat{
		Attr{"model", AttrMat4},
		Attr{"projection", AttrMat4},
		Attr{"view", AttrMat4},
		Attr{"texelsPerPixel", AttrFloat},
	},
}
View Source
var PixelArtShader2 = ShaderConfig{
	VertexShader:   PixelArtVert,
	FragmentShader: PixelArtFrag,
	VertexFormat: VertexFormat{
		VertexAttribute("positionIn", AttrVec3, PositionXYZ),
		VertexAttribute("colorIn", AttrVec4, ColorRGBA),
		VertexAttribute("texCoordIn", AttrVec2, TexCoordXY),
	},
	UniformFormat: UniformFormat{
		Attr{"model", AttrMat4},
		Attr{"projection", AttrMat4},
		Attr{"view", AttrMat4},
	},
}
View Source
var PixelArtVert string
View Source
var SDFFragmentShader string
View Source
var SDFShader = ShaderConfig{
	VertexShader:   SpriteVertexShader,
	FragmentShader: SDFFragmentShader,
	VertexFormat: VertexFormat{
		VertexAttribute("positionIn", AttrVec3, PositionXYZ),
		VertexAttribute("colorIn", AttrVec4, ColorRGBA),
		VertexAttribute("texCoordIn", AttrVec2, TexCoordXY),
	},
	UniformFormat: UniformFormat{
		Attr{"model", AttrMat4},
		Attr{"projection", AttrMat4},
		Attr{"view", AttrMat4},
	},
}
View Source
var SpriteFragmentShader string
View Source
var SpriteShader = ShaderConfig{
	VertexShader:   SpriteVertexShader,
	FragmentShader: SpriteFragmentShader,
	VertexFormat: VertexFormat{
		VertexAttribute("positionIn", AttrVec3, PositionXYZ),
		VertexAttribute("colorIn", AttrVec4, ColorRGBA),
		VertexAttribute("texCoordIn", AttrVec2, TexCoordXY),
	},
	UniformFormat: UniformFormat{
		Attr{"model", AttrMat4},
		Attr{"projection", AttrMat4},
		Attr{"view", AttrMat4},
	},
}
View Source
var SpriteVertexShader string
View Source
var SubPixelAntiAliased string

Functions

This section is empty.

Types

type Attr

type Attr struct {
	Name string
	Type AttrType
}

func (Attr) Size

func (a Attr) Size() int

Returns the size of the attribute type

type AttrType

type AttrType uint8

This type is used to define the underlying data type of a vertex attribute or uniform attribute

const (
	// TODO - others
	AttrInt AttrType = iota
	AttrFloat
	AttrVec2
	AttrVec3
	AttrVec4
	AttrMat2
	AttrMat23
	AttrMat24
	AttrMat3
	AttrMat32
	AttrMat34
	AttrMat4
	AttrMat42
	AttrMat43
)

type ShaderConfig

type ShaderConfig struct {
	VertexShader, FragmentShader string
	VertexFormat                 VertexFormat
	UniformFormat                UniformFormat
}

type SwizzleType

type SwizzleType uint8

This type is used to define how generic meshes map into specific shader buffers

const (
	PositionXY SwizzleType = iota
	PositionXYZ
	NormalXY
	NormalXYZ
	ColorR
	ColorRG
	ColorRGB
	ColorRGBA
	TexCoordXY
)

type UniformFormat

type UniformFormat []Attr

type VertexAttr

type VertexAttr struct {
	Attr                // The underlying Attribute
	Swizzle SwizzleType // This defines how the shader wants to map a generic object (like a mesh, to the shader buffers)
}

func VertexAttribute

func VertexAttribute(name string, Type AttrType, swizzle SwizzleType) VertexAttr

type VertexFormat

type VertexFormat []VertexAttr

TODO - right now we only support floats (for simplicity)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL