builtinshader

package
v2.8.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UniformColorMBody        = "ColorMBody"
	UniformColorMTranslation = "ColorMTranslation"
)
View Source
const AddressCount = 3
View Source
const FilterCount = 2

Variables

View Source
var ClearShaderSource = []byte(`//kage:unit pixels

package main

func Fragment() vec4 {
	return vec4(0)
}
`)
View Source
var ScreenShaderSource = []byte(`//kage:unit pixels

package main

func Fragment(dstPos vec4, srcPos vec2) vec4 {
	// Blend source colors in a square region, which size is 1/scale.
	scale := imageDstSize()/imageSrc0Size()
	pos := srcPos
	p0 := pos - 1/2.0/scale
	p1 := pos + 1/2.0/scale

	// Texels must be in the source rect, so it is not necessary to check.
	c0 := imageSrc0UnsafeAt(p0)
	c1 := imageSrc0UnsafeAt(vec2(p1.x, p0.y))
	c2 := imageSrc0UnsafeAt(vec2(p0.x, p1.y))
	c3 := imageSrc0UnsafeAt(p1)

	// p is the p1 value in one pixel assuming that the pixel's upper-left is (0, 0) and the lower-right is (1, 1).
	rate := clamp(fract(p1)*scale, 0, 1)
	return mix(mix(c0, c1, rate.x), mix(c2, c3, rate.x), rate.y)
}
`)

Functions

func AppendShaderSources added in v2.8.0

func AppendShaderSources(sources [][]byte) [][]byte

func ShaderSource added in v2.8.0

func ShaderSource(filter Filter, address Address, useColorM bool) []byte

ShaderSource returns the built-in shader source based on the given parameters.

The returned shader always uses a color matrix so far.

Types

type Address

type Address int
const (
	AddressUnsafe Address = iota
	AddressClampToZero
	AddressRepeat
)

type Filter

type Filter int
const (
	FilterNearest Filter = iota
	FilterLinear
)

Jump to

Keyboard shortcuts

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