Skip to content

Commit

Permalink
Some shaders, and screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
laurelin committed May 4, 2019
1 parent 1a2d191 commit 6a5e1eb
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 0 deletions.
5 changes: 5 additions & 0 deletions colourful
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const one 1.0;
fun main() Unit {
outColor := Vec4(get !fragColor.X, get !fragColor.Y, get !fragColor.Z, one);
return
}
Binary file added colourful.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions function
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const one 1.0;

fun cmult(a | Vec2, b | Vec2) Vec2 {
return(Vec2(
-(*(get a.X, get b.X), *(get a.Y, get b.Y)),
+(*(get a.X, get b.Y), *(get a.Y, get b.X))
))
};

fun main() Unit {
coord | Vec2 = Vec2(get !fragColor.X, get !fragColor.Y);
l | Float = length(cmult(coord, coord));
outColor := Vec4(l, l, l, one);
return
}
Binary file added function.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions mandelbrot
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const zero 0.0;
const two 2.0;
const one 1.0;
const d 10.0;

fun cmult(a | Vec2, b | Vec2) Vec2 {
return(Vec2(
-(*(get a.X, get b.X), *(get a.Y, get b.Y)),
+(*(get a.X, get b.Y), *(get a.Y, get b.X))
))
};

fun mandelbrot(depth | Float, z | Vec2, c | Vec2) Vec2
when lt(depth, zero) is z
else mandelbrot(-(depth, one), +(cmult(z, z), c), c);

fun sign(x | Float) Float {
return(-(x, length(x)))
};

fun main() Unit {
coord | Vec2 = Vec2(get !fragColor.X, get !fragColor.Y);
l | Vec2 = mandelbrot(d, coord, coord);
color | Float = /(length(l), two);
outColor := Vec4(color, color, color, one);
return
}

7 changes: 7 additions & 0 deletions mult
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const one 1.0;

fun main() Unit {
shade | Float = *(get !fragColor.X, get !fragColor.Y);
outColor := Vec4(shade, shade, shade, one);
return
}
Binary file added mult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions recursive
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const zero 0.0;
const pointone 0.1;
const one 1.0;
const ten 10.0;

fun loop(i | Float, x | Float) Float when lt(i, pointone) is x else loop(-(i, one), +(x, pointone));

fun main() Unit {
color | Float = loop(ten, zero);
outColor := Vec4(color, color, color, one);
return
}
Binary file added recursive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions unrolled
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const zero 0.0;
const pointone 0.1;
const one 1.0;
const ten 10.0;

fun loop(i | Float, x | Float) Float when lt(i, pointone) is x else loop(-(i, one), +(x, pointone));

fun main() Unit {
var color | Float;
color := zero;
color := +(!color, pointone);
color := +(!color, pointone);
color := +(!color, pointone);
color := +(!color, pointone);
color := +(!color, pointone);
color := +(!color, pointone);
color := +(!color, pointone);
color := +(!color, pointone);
color := +(!color, pointone);
color := +(!color, pointone);
c | Float = !color;
outColor := Vec4(c, c, c, one);
return
}
Binary file added unrolled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions white
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const one 1.0;
fun main() Unit {outColor := Vec4(one, one, one, one); return}

0 comments on commit 6a5e1eb

Please sign in to comment.