-
Notifications
You must be signed in to change notification settings - Fork 18
/
WvN.DelphiShader.FX.EscherLikeTiling.pas
87 lines (68 loc) · 1.69 KB
/
WvN.DelphiShader.FX.EscherLikeTiling.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
unit WvN.DelphiShader.FX.EscherLikeTiling;
interface
uses GR32,Types,WvN.DelphiShader.Shader;
type
TEscherLikeTiling = class(TShader)
constructor Create;override;
procedure PrepareFrame;
function mainImage(var fragCoord:vec2):TColor32;
function mainImage(var fragCoord:vec2):TColor32;
end;
var
EscherLikeTiling:TShader
;
implementation
uses SysUtils, Math;
constructor TEscherLikeTiling.Create;
begin
inherited;
FrameProc := PrepareFrame;
PixelProc := mainImage;
end;
procedure TEscherLikeTiling.PrepareFrame;
begin
end;
function TEscherLikeTiling.mainImage(var fragCoord:vec2):TColor32;
var
f = floor(U), u:vec2;
b:float;
i:int;
begin
U := U * (12/resolution.y);
O := O - (O);
f := floor(U), u := 2*fract(U)-1;
// ceil cause line on some OS
b := &mod(f.x+f.y,2), y;
for i := 0 to 3 do
u *= mat2(0,-1,1,0),
y := 2*fract(0.2*iDate.w+U.x*0.01)-1,
O := O + (smoothstep(0.55,0.45, length(u-Vec2.Create(0.5,1.5*y))));
if b>0 then
O := 1-O;
// try also without :-)
end;
{}
{ // shorter version: 212 chars
end;
function TEscherLikeTiling.mainImage(var fragCoord:vec2):TColor32;
var
f = ceil(U := vec2 f = ceil(U * (12./resolution.y), u:vec2;
begin
O := O - (O);
f := ceil(U := vec2 f := ceil(U * (12./resolution.y), u := 2.*fract(U)-1.);
#define q u := u.yx, u.x*=-1., O += step(length( u - Vec2.Create(.5, 3.*fract(.2*iDate.w+U.x*.01)-1.5) ),.5)
q;
q;
q;
q;
f.x+f.y,2.>0. ? O := 1.-O : O;
// golfed by 834144373
end;
{}
end;
initialization
EscherLikeTiling := TEscherLikeTiling.Create;
Shaders.Add('EscherLikeTiling', EscherLikeTiling);
finalization
FreeandNil(EscherLikeTiling);
end.