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
Types ¶
Click to show internal directories.
Click to hide internal directories.