-
Notifications
You must be signed in to change notification settings - Fork 18
/
WvN.DelphiShader.FX.FractalPlasma.pas
64 lines (47 loc) · 1.15 KB
/
WvN.DelphiShader.FX.FractalPlasma.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
unit WvN.DelphiShader.FX.FractalPlasma;
interface
uses GR32, Types, WvN.DelphiShader.Shader;
type
TFractalPlasma = class(TShader)
const
vec3_1: vec3 = (x: 1.2; y: 0.999; z: 0.9);
var
m: Vec2;
n: Vec3;
constructor Create; override;
procedure PrepareFrame;
function main(var gl_FragCoord: Vec2): TColor32;
end;
var
FractalPlasma: TShader;
implementation
uses SysUtils, Math;
constructor TFractalPlasma.Create;
begin
inherited;
FrameProc := PrepareFrame;
PixelProc := main;
end;
procedure TFractalPlasma.PrepareFrame;
begin
m.x := sinLarge(time)*0.5+0.5;
m.y := cosLarge(time)*0.3+0.5;
n := vec3.Create(1, 1, m.y * 0.4);
end;
function TFractalPlasma.main(var gl_FragCoord: Vec2): TColor32;
var
p: vec3;
i: int;
begin
// Originally created by Robert Schütze (http://glslsandbox.com/e#29611.0)
p := vec3.Create((gl_FragCoord.xy) / (resolution.y), m.x);
for i := 0 to 99 do
p.xzy := vec3_1 * (abs((abs(p) / dot(p, p) - n)));
Result := TColor32(p);
end;
initialization
FractalPlasma := TFractalPlasma.Create;
Shaders.Add('FractalPlasma', FractalPlasma);
finalization
FreeandNil(FractalPlasma);
end.