summaryrefslogtreecommitdiff
path: root/shaders
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2024-04-22 17:32:17 +0100
committerdavidovski <david@davidovski.xyz>2024-04-22 17:32:17 +0100
commitb0a8bb642f919eaa0c36b9d861c47e0cc4a99440 (patch)
treed9e184cec7db11ad8dc7c93b9e68291bc5beceae /shaders
parenteeca23dc59e60def65dfefc28b69d6cfc85467ff (diff)
use grass
Diffstat (limited to 'shaders')
-rw-r--r--shaders/bloom.kage43
-rw-r--r--shaders/clouds.kage11
-rw-r--r--shaders/none.kage4
-rw-r--r--shaders/vcr_lite.kage33
4 files changed, 85 insertions, 6 deletions
diff --git a/shaders/bloom.kage b/shaders/bloom.kage
new file mode 100644
index 0000000..fc987b1
--- /dev/null
+++ b/shaders/bloom.kage
@@ -0,0 +1,43 @@
+//go:build ignore
+//kage:unit pixels
+
+package main
+
+const THRESHOLD = .9
+const DIRECTIONS = 30.0 // BLUR DIRECTIONS (Default 16.0 - More is better but slower)
+const QUALITY = 12.0 // BLUR QUALITY (Default 4.0 - More is better but slower)
+const SIZE = 5.0 // BLUR SIZE (Radius)
+const PI = 6.28318530718 // Pi*2
+const OPACITY = 0.21
+
+
+var Time float
+var NoiseOffset float
+
+func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
+ uv := srcPos
+
+ average := vec3(0.0)
+ radius := SIZE / 2
+
+ amount := 0.0
+ for d:=0.0; d<PI; d+=PI/DIRECTIONS{
+ for i:=1.0/QUALITY; i<=1.0; i+=1.0/QUALITY{
+ t := imageSrc0UnsafeAt(uv + vec2(cos(d),sin(d))*radius*log(i)).rgb
+
+ brightness := dot(t.rgb, vec3(0.2126, 0.7152, 0.0722))
+ if brightness > THRESHOLD {
+ average += t
+ amount += 1.0
+ }
+ }
+ }
+
+ col := imageSrc0UnsafeAt(uv).rgb
+ if amount > 0 {
+ col += (average / amount) * OPACITY
+ }
+
+ return vec4(col,1.0)
+}
+
diff --git a/shaders/clouds.kage b/shaders/clouds.kage
index 26597e5..62a0ae0 100644
--- a/shaders/clouds.kage
+++ b/shaders/clouds.kage
@@ -13,6 +13,7 @@ const cloudlight = 0.3
const cloudcover = 0.2
const cloudalpha = 8.0
const skytint = 0.5
+const colorDepth = 64
func rand(co vec2) float {
return fract(sin(dot(co.xy, vec2(12.9898,-78.233))) * 43758.5453)
@@ -59,10 +60,11 @@ func fbm(n vec2) float {
func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
m := mat2(1.6, 1.2, -1.2, 1.6)
- skycolour1 := vec3(0.45, 0.57, 0.66)
- skycolour2 := vec3(0.55, 0.77, 0.86)
+ skycolour := vec3(0.68, 0.81, 0.86)
+ //skycolour2 := vec3(0.55, 0.77, 0.86)
+
+ p := floor(srcPos.xy) / imageSrc0Size().xy;
- p := srcPos.xy / imageSrc0Size().xy;
uv := p*vec2(imageSrc0Size().x/imageSrc0Size().y,1.0);
time := Time * speed
q := fbm(uv * cloudscale * 0.5)
@@ -120,12 +122,13 @@ func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
c += c1
- skycolour := mix(skycolour2, skycolour1, p.y);
+ //skycolour := mix(skycolour2, skycolour1, 0);
cloudcolour := vec3(1.1, 1.1, 0.9) * clamp((clouddark + cloudlight*c), 0.0, 1.0);
f = cloudcover + cloudalpha*f*r;
result := mix(skycolour, clamp(skytint * skycolour + cloudcolour, 0.0, 1.0), clamp(f + c, 0.0, 1.0));
+ result = floor(result*colorDepth)/colorDepth
return vec4( result, 1.0 );
}
diff --git a/shaders/none.kage b/shaders/none.kage
index 3eccc50..941070d 100644
--- a/shaders/none.kage
+++ b/shaders/none.kage
@@ -5,8 +5,8 @@
package main
var Time float
-var Cursor vec2
+var NoiseOffset float
func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
- return imageSrc2UnsafeAt(srcPos);
+ return imageSrc0UnsafeAt(srcPos)
}
diff --git a/shaders/vcr_lite.kage b/shaders/vcr_lite.kage
new file mode 100644
index 0000000..405195c
--- /dev/null
+++ b/shaders/vcr_lite.kage
@@ -0,0 +1,33 @@
+//go:build ignore
+
+//kage:unit pixels
+
+package main
+
+var Time float
+var NoiseOffset float
+
+const noiseX = 840.0
+const noiseY = 840.0
+const speed = 0.01
+
+const colorOffsetIntensity = 0.1
+
+func rand(co vec2) float {
+ return fract(sin(dot(co.xy, vec2(12.9898,78.233))) * 43758.5453)
+}
+
+
+func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
+ time := Time * speed
+ uv := srcPos / imageSrc0Size()
+
+ uv.x = uv.x + (rand(vec2(time,srcPos.y)) - 0.5) / (noiseX);
+ uv.y = uv.y + (rand(vec2(time))-0.5) / (noiseY)
+ offsetR := vec2(0.006 * sin(time), 0.0) * colorOffsetIntensity
+ offsetG := vec2(0.0073 * (cos(time * 0.97)), 0.0) * colorOffsetIntensity
+ r := imageSrc0UnsafeAt((uv+offsetR) * imageSrc0Size()).r
+ g := imageSrc0UnsafeAt((uv+offsetG) * imageSrc0Size()).g
+ b := imageSrc0UnsafeAt(uv * imageSrc0Size()).b
+ return vec4(r, g, b, 1.0)
+}