-
Notifications
You must be signed in to change notification settings - Fork 18
/
WvN.DelphiShader.FX.Flying.pas
69 lines (53 loc) · 1.15 KB
/
WvN.DelphiShader.FX.Flying.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
unit WvN.DelphiShader.FX.Flying;
interface
uses GR32, Types, WvN.DelphiShader.Shader;
type
TFlying = class(TShader)
public
const
k: vec3 = (x:0.4; y: - 0.2; z:0.9);
constructor Create; override;
procedure PrepareFrame;
function m(p:vec3): vec3;
function RenderPixel(var p:Vec2):TColor32;
end;
var
Flying: TShader;
implementation
uses SysUtils, Math;
constructor TFlying.Create;
begin
inherited;
FrameProc := PrepareFrame;
PixelProc := RenderPixel;
end;
procedure TFlying.PrepareFrame;
begin
end;
function TFlying.m(p:vec3): vec3;
var
i: int;
begin
p := p - (iGlobalTime);
for i := 0 to 15 do
p := reflect(abs(p) - 9, k);
Result := p * 0.5;
end;
function TFlying.RenderPixel(var p:Vec2):TColor32;
var
d, o: vec3;
i : int;
begin
exit(clRed32);
d := vec3.Create(p,1) / Resolution.xyy^;
o := d;
for i := 0 to 98 do
o := o + (d * m(o).x);
Result := TColor32(texture2D(tex[0], m(o).yz) * (0.5 + 99 * m(o - k * 0.02).x) * exp(o.y * o.z * o.z * o.z * 0.04));
end;
initialization
Flying := TFlying.Create;
Shaders.Add('Flying', Flying);
finalization
FreeandNil(Flying);
end.