-
Notifications
You must be signed in to change notification settings - Fork 18
/
WvN.DelphiShader.FX.FlagNL.pas
63 lines (47 loc) · 1.03 KB
/
WvN.DelphiShader.FX.FlagNL.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
unit WvN.DelphiShader.FX.FlagNL;
interface
uses GR32, Types, WvN.DelphiShader.Shader;
type
TFlagNL = class(TShader)
const
cRed : vec3 = (x: 1; y: 0.2; z: 0.2);
cWhite : vec3 = (x: 1; y: 1; z: 1);
cBlue : vec3 = (x: 0.2; y: 0.2; z: 1.0);
function Main(var gl_FragCoord: Vec2): TColor32;
constructor Create; override;
procedure PrepareFrame;
end;
var
FlagNL: TShader;
implementation
uses SysUtils, Math;
constructor TFlagNL.Create;
begin
inherited;
FrameProc := PrepareFrame;
PixelProc := Main;
end;
procedure TFlagNL.PrepareFrame;
begin
end;
function TFlagNL.Main;
var
p: Vec2;
c: vec3;
begin
p := (gl_FragCoord.xy / resolution.xy);
if p.y < 0.3333333333333333333333 then
c := cBlue
else
if (p.y < 0.666666666666666666666666) then
c := cWhite
else
c := cRed;
Result := TColor32(c);
end;
initialization
FlagNL := TFlagNL.Create;
Shaders.Add('FlagNL', FlagNL);
finalization
FreeandNil(FlagNL);
end.