all: add a compiler directive kage:unit

This change adds a new compiler directive 'kage:unit' to Kage. This
takes one of these two values: 'pixel' and 'texel'. The default value
is 'texel'.

With the pixel-unit mode, all the built-in functions treats pixels
instead of texels, and the texCoord argument of Fragment is in pixels.
This simplifies shader programs as programs no longer have the notion
of texels.

With the texel-unit mode, the behavior is the same as the current
behavior.

Closes #1431
This commit is contained in:
Hajime Hoshi
2023-04-16 18:56:14 +09:00
parent b5ca404c42
commit 49582519c1
31 changed files with 544 additions and 206 deletions

View File

@@ -14,11 +14,12 @@
//go:build ignore
//kage:unit pixel
package main
var Time float
var Cursor vec2
var ScreenSize vec2
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
// Triangle wave to go 0-->1-->0...