-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathe1m1.hlsl
1861 lines (1532 loc) · 66.5 KB
/
e1m1.hlsl
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Windows terminal version of this old shadertoy shader
// https://www.shadertoy.com/view/lsSXzD
Texture2D shaderTexture;
SamplerState samplerState;
// Terminal settings such as the resolution of the texture
cbuffer PixelShaderSettings {
// The number of seconds since the pixel shader was enabled
float Time;
// UI Scale
float Scale;
// Resolution of the shaderTexture
float2 Resolution;
// Background color as rgba
float4 Background;
};
// some glsl -> hlsl
#define mix lerp
#define vec2 float2
#define vec3 float3
#define vec4 float4
#define fract frac
// Below code is modified from the shadertoy shader:
// E1M1 - Hangar
// by @P_Malin
// Procedural version of Doom E1M1
// The start area of Doom E1M1.
// Click and drag the mouse to move.
// Where you click relative to the center of the screen sets the view direction.
// This is the single pass version. A multi-pass playable version is here: https://www.shadertoy.com/view/lldGDr
// Also, check out Reinder's excellent Doom2 shader: https://www.shadertoy.com/view/lsB3zD
// The sectors we draw by default
#define ENABLE_NUKAGE_SECTORS
#define ENABLE_START_SECTORS
// Adding this compiles with "Unknown Error" on some machines. Uncomment if you are feeling lucky.
//#define ENABLE_SECTOR_31
// Some additional sectors, may need to comment out some of the default ones
//#define ENABLE_EXTRA_NUKAGE_SECTORS
//#define ENABLE_MISC_SECTORS
#define ENABLE_SPRITES
#define DEMO_CAMERA
#define INTRO_EFFECT
#define DRAW_SKY
#define HEAD_BOB
#define PIXELATE_IMAGE
#define QUANTIZE_FINAL_IMAGE
#define QUANTIZE_TEXTURES
#define PIXELATE_TEXTURES
//#define DISCARD_BACKGROUND
//#define DRAW_COMPASS
// Add walls to close entrances to sectors we are not rendering
#ifndef ENABLE_EXTRA_NUKAGE_SECTORS
#define CLOSE_NUKAGE_SECTOR
#endif
#ifndef ENABLE_SECTOR_31
#define CLOSE_START_SECTOR
#endif
#define FAR_CLIP 10000.0
static const vec2 vFakeResolution = vec2(320.0, 240.0);
static const float kDepthFadeScale = (1.0 / 3500.0);
static const float kExtraLight = 0.0;
// Light level adjustment to East-West and North-South walls
static const float kC = (1.0 / 16.0);
struct Ray
{
vec3 vRayOrigin;
vec3 vRayDir;
vec2 vSpriteDir;
};
vec3 SampleTexture( const in float fTexture, const in vec2 vUV );
void MapIntersect( out float fClosestT, out vec4 vHitInfo, Ray r );
float hash(float p);
vec3 GetCameraRayDir( const in vec2 vWindow, const in vec3 vCameraPos, const in vec3 vCameraTarget )
{
vec3 vForward = normalize(vCameraTarget - vCameraPos);
vec3 vRight = normalize(cross(vec3(0.0, 1.0, 0.0), vForward));
vec3 vUp = normalize(cross(vForward, vRight));
const float kFOV = 1.8;
vec3 vDir = normalize(vWindow.x * vRight + vWindow.y * vUp + vForward * kFOV);
return vDir;
}
vec3 Quantize( const in vec3 col )
{
return floor( col * 48.0 + 0.5 ) * (1.0 / 48.0);
}
float Cross2d( const in vec2 vA, const in vec2 vB )
{
//return cross( vec3(vA, 0.0), vec3(vB, 0.0) ).z;
return vA.x * vB.y - vA.y * vB.x;
//return dot(vA * vB.yx, vec2(1.0, -1.0));
}
void BeginSector( out vec4 vSectorState, const in vec2 vSectorHeights, Ray r )
{
// store the infinite floor-ceiling plane intersect depth in vSectorState.xy
vSectorState.xy = (vSectorHeights - r.vRayOrigin.y) / r.vRayDir.y;
vSectorState.zw = vec2(0.0,0.0);
}
// Intersect a sidedef that meets another sector with the same floor and ceiling height
void Null( inout vec4 vSectorState, const in int iAx, const in int iAy, const in int iBx, const in int iBy, Ray r )
{
vec2 vA = vec2(iAx, iAy);
vec2 vB = vec2(iBx, iBy);
vec2 vD = vB - vA;
vec2 vOA = vA - r.vRayOrigin.xz;
float fDenom = Cross2d( r.vRayDir.xz, vD );
float fRcpDenom = 1.0 / fDenom;
float fHitT = Cross2d( vOA, vD ) * fRcpDenom;
float fHitU = Cross2d( vOA, r.vRayDir.xz ) * fRcpDenom;
if((fHitT > 0.0) && (fHitU >= 0.0) && (fHitU < 1.0))
{
// If we crossed the sector edge further away than the floor-ceiling intersection
// then we increment the in-out test value
// This is like doing a ray-casting point in polygon test
// http://en.wikipedia.org/wiki/Point_in_polygon
// from the floor/ceiling intersection depth to far clip depth
vSectorState.zw += step(vSectorState.xy, vec2(fHitT,fHitT));
}
}
void Wall( inout float fClosestT, inout vec4 vHitInfo, inout vec4 vSectorState, const in int iAx, const in int iAy, const in int iBx, const in int iBy, const in int iLen, const in float fLightLevel, const in vec2 vSectorHeights, const in float fTexture, Ray r )
{
vec2 vA = vec2(iAx, iAy);
vec2 vB = vec2(iBx, iBy);
float fLen = float(iLen);
vec2 vD = vB - vA;
vec2 vOA = vA - r.vRayOrigin.xz;
float fDenom = Cross2d( r.vRayDir.xz, vD );
float fRcpDenom = 1.0 / fDenom;
float fHitT = Cross2d( vOA, vD ) * fRcpDenom;
float fHitU = Cross2d( vOA, r.vRayDir.xz ) * fRcpDenom;
if((fHitT > 0.0) && (fHitU >= 0.0) && (fHitU < 1.0))
{
// If we crossed the sector edge further away than the floor-ceiling intersection
// then we increment the in-out test value
// This is like doing a ray-casting point in polygon test
// http://en.wikipedia.org/wiki/Point_in_polygon
// from the floor/ceiling intersection depth to far clip depth
vSectorState.zw += step(vSectorState.xy, vec2(fHitT,fHitT));
if((fHitT < fClosestT) && (fDenom < 0.0))
{
float fHitY = r.vRayDir.y * fHitT + r.vRayOrigin.y;
if( (fHitY > vSectorHeights.x) && (fHitY < vSectorHeights.y) )
{
fClosestT = fHitT;
vHitInfo = vec4(fHitU * fLen, fHitY, fLightLevel, fTexture);
}
}
}
}
void Open( inout float fClosestT, inout vec4 vHitInfo, inout vec4 vSectorState, const in int iAx, const in int iAy, const in int iBx, const in int iBy, const in int iLen, const in float fLightLevel, const in vec2 vSectorHeights, const in int iLowerHeight, const in int iUpperHeight, const in float fLowerTexture, const in float fUpperTexture, Ray r )
{
vec2 vA = vec2(iAx, iAy);
vec2 vB = vec2(iBx, iBy);
float fLen = float(iLen);
float fUpperHeight = float(iUpperHeight);
float fLowerHeight = float(iLowerHeight);
vec2 vD = vB - vA;
vec2 vOA = vA - r.vRayOrigin.xz;
float fDenom = Cross2d( r.vRayDir.xz, vD );
float fRcpDenom = 1.0 / fDenom;
float fHitT = Cross2d( vOA, vD ) * fRcpDenom;
float fHitU = Cross2d( vOA, r.vRayDir.xz ) * fRcpDenom;
if((fHitT > 0.0) && (fHitU >= 0.0) && (fHitU < 1.0))
{
// If we crossed the sector edge further away than the floor-ceiling intersection
// then we increment the in-out test value
// This is like doing a ray-casting point in polygon test
// http://en.wikipedia.org/wiki/Point_in_polygon
// from the floor/ceiling intersection depth to far clip depth
vSectorState.zw += step(vSectorState.xy, vec2(fHitT,fHitT));
if((fHitT < fClosestT) && (fDenom < 0.0))
{
float fHitY = r.vRayDir.y * fHitT + r.vRayOrigin.y;
if( (fHitY > vSectorHeights.x) && (fHitY < vSectorHeights.y) )
{
if(fHitY < fLowerHeight)
{
fClosestT = fHitT;
vHitInfo = vec4(fHitU * fLen, fHitY - fLowerHeight, fLightLevel, fLowerTexture);
}
if(fHitY > fUpperHeight)
{
fClosestT = fHitT;
vHitInfo = vec4(fHitU * fLen, fHitY - fUpperHeight, fLightLevel, fUpperTexture);
}
}
}
}
}
void Upper( inout float fClosestT, inout vec4 vHitInfo, inout vec4 vSectorState, const in int iAx, const in int iAy, const in int iBx, const in int iBy, const in int iLen, const in float fLightLevel, const in vec2 vSectorHeights, const in int iUpperHeight, const in float fUpperTexture, Ray r )
{
vec2 vA = vec2(iAx, iAy);
vec2 vB = vec2(iBx, iBy);
float fLen = float(iLen);
float fUpperHeight = float(iUpperHeight);
vec2 vD = vB - vA;
vec2 vOA = vA - r.vRayOrigin.xz;
float fDenom = Cross2d( r.vRayDir.xz, vD );
float fRcpDenom = 1.0 / fDenom;
float fHitT = Cross2d( vOA, vD ) * fRcpDenom;
float fHitU = Cross2d( vOA, r.vRayDir.xz ) * fRcpDenom;
if((fHitT > 0.0) && (fHitU >= 0.0) && (fHitU < 1.0))
{
// If we crossed the sector edge further away than the floor-ceiling intersection
// then we increment the in-out test value
// This is like doing a ray-casting point in polygon test
// http://en.wikipedia.org/wiki/Point_in_polygon
// from the floor/ceiling intersection depth to far clip depth
vSectorState.zw += step(vSectorState.xy, vec2(fHitT,fHitT));
if((fHitT < fClosestT) && (fDenom < 0.0))
{
float fHitY = r.vRayDir.y * fHitT + r.vRayOrigin.y;
if( fHitY < vSectorHeights.y )
{
if(fHitY > fUpperHeight)
{
fClosestT = fHitT;
vHitInfo = vec4(fHitU * fLen, fHitY - fUpperHeight, fLightLevel, fUpperTexture);
}
}
}
}
}
void Lower( inout float fClosestT, inout vec4 vHitInfo, inout vec4 vSectorState, const in int iAx, const in int iAy, const in int iBx, const in int iBy, const in int iLen, const in float fLightLevel, const in vec2 vSectorHeights, const in int iLowerHeight, const in float fLowerTexture, Ray r )
{
vec2 vA = vec2(iAx, iAy);
vec2 vB = vec2(iBx, iBy);
float fLen = float(iLen);
float fLowerHeight = float(iLowerHeight);
vec2 vD = vB - vA;
vec2 vOA = vA - r.vRayOrigin.xz;
float fDenom = Cross2d( r.vRayDir.xz, vD );
float fRcpDenom = 1.0 / fDenom;
float fHitT = Cross2d( vOA, vD ) * fRcpDenom;
float fHitU = Cross2d( vOA, r.vRayDir.xz ) * fRcpDenom;
if((fHitT > 0.0) && (fHitU >= 0.0) && (fHitU < 1.0))
{
// If we crossed the sector edge further away than the floor-ceiling intersection
// then we increment the in-out test value
// This is like doing a ray-casting point in polygon test
// http://en.wikipedia.org/wiki/Point_in_polygon
// from the floor/ceiling intersection depth to far clip depth
vSectorState.zw += step(vSectorState.xy, vec2(fHitT,fHitT));
if((fHitT < fClosestT) && (fDenom < 0.0))
{
float fHitY = r.vRayDir.y * fHitT + r.vRayOrigin.y;
if( fHitY > vSectorHeights.x )
{
if(fHitY < fLowerHeight)
{
fClosestT = fHitT;
vHitInfo = vec4(fHitU * fLen, fHitY - fLowerHeight, fLightLevel, fLowerTexture);
}
}
}
}
}
void EndSector( inout float fClosestT, inout vec4 vHitInfo, in vec4 vSectorState, const in float fLightLevel, const in vec2 vFloorCeilingTextures, Ray r )
{
// Test the even-odd state of our sector floor/ceiling in-out values
vec2 vInOutTest = fract( vSectorState.zw * 0.5 ) * 2.0;
if( fClosestT > vSectorState.x )
{
if((vInOutTest.x > 0.5) && (vSectorState.x > 0.0))
{
vec3 vFloorPos = r.vRayOrigin + r.vRayDir * vSectorState.x;
if( r.vRayOrigin.y > vFloorPos.y )
{
fClosestT = vSectorState.x;
vHitInfo = vec4( vFloorPos.xz, fLightLevel, vFloorCeilingTextures.x);
}
}
}
if( fClosestT > vSectorState.y )
{
if((vInOutTest.y > 0.5) && (vSectorState.y > 0.0))
{
vec3 vCeilingPos = r.vRayOrigin + r.vRayDir * vSectorState.y;
if( r.vRayOrigin.y < vCeilingPos.y )
{
fClosestT = vSectorState.y;
vHitInfo = vec4( vCeilingPos.xz, fLightLevel, vFloorCeilingTextures.y);
}
}
}
}
#ifdef ENABLE_SPRITES
void Sprite( out float fClosestT, out vec4 vHitInfo, const in vec2 vSpriteDir, const in int iX, const in int iY, const in int iZ, vec2 vSize, float fLightLevel, float fTexture, Ray r )
{
vec3 vPos = vec3(iX, iY, iZ);
fClosestT = FAR_CLIP;
vHitInfo = vec4(0.0,0.0,0.0,0.0);
vec2 vA = vPos.xz - vSpriteDir * 0.5 * vSize.x;
vec2 vB = vPos.xz + vSpriteDir * 0.5 * vSize.x;
vec2 vD = vB - vA;
vec2 vOA = vA - r.vRayOrigin.xz;
float rcpdenom = 1.0 / Cross2d( r.vRayDir.xz, vD );
float fHitT = Cross2d( vOA, vD ) * rcpdenom;
if(fHitT > 0.0)
{
float fHitU = Cross2d( vOA, r.vRayDir.xz ) * rcpdenom;
if((fHitU >= 0.0) && (fHitU < 1.0))
{
float fHitY = r.vRayDir.y * fHitT + r.vRayOrigin.y;
if( (fHitT < fClosestT) && (fHitY > vPos.y) && (fHitY < (vPos.y + vSize.y)) )
{
fClosestT = fHitT;
vHitInfo = vec4(fHitU * vSize.x, fHitY - vPos.y, fLightLevel, fTexture);
}
}
}
}
bool MaskBarrel(vec2 vTexCoord)
{
vec2 vSize = vec2(23.0, 32.0);
vTexCoord = floor(vTexCoord);
// remove corner pixels
vec2 vWrapCoord = fract((vTexCoord + vec2(2.0, 1.0) ) / vSize) * vSize;
return ( (vWrapCoord.x >= 4.0) || (vWrapCoord.y >= 2.0) );
}
vec4 CosApprox( vec4 x )
{
x = abs(fract(x * (0.5))*2.0 - 1.0);
vec4 x2 = x*x;
return( ( x2 * 3.0) - ( 2.0 * x2*x) );
}
bool MaskCorpseSprite(vec2 vTexCoord)
{
//vTexCoord = floor(vTexCoord);
vec2 vUV = vTexCoord.xy / vec2(57.0, 22.0);
vec2 vOffset = vUV;
vOffset = vOffset * 2.0 -vec2(1.0, 0.8);
float fDist = dot(vOffset, vOffset);
fDist += dot(CosApprox(vTexCoord.xyxy * vec4(0.55, 0.41, 0.25, 0.1)), vec4(0.2 * -vOffset.yyyy));
return fDist < 0.4;
}
#define TEX_BAR1A 32.0
#define TEX_PLAYW 33.0
void BarrelSprite(inout float fClosestT, inout vec4 vHitInfo, const in vec2 vSpriteDir, const in int iX, const in int iY, const in int iZ, const in float fLightLevel, Ray r )
{
float fSpriteT;
vec4 vSpriteHitInfo;
Sprite( fSpriteT, vSpriteHitInfo, vSpriteDir, iX, iY, iZ, vec2(23.0, 32.0), fLightLevel, TEX_BAR1A, r);
if(fSpriteT < fClosestT)
{
if(MaskBarrel(vSpriteHitInfo.xy))
{
fClosestT = fSpriteT;
vHitInfo = vSpriteHitInfo;
}
}
}
void CorpseSprite(inout float fClosestT, inout vec4 vHitInfo, const in vec2 vSpriteDir, const in int iX, const in int iY, const in int iZ, const in float fLightLevel, Ray r )
{
float fSpriteT;
vec4 vSpriteHitInfo;
Sprite( fSpriteT, vSpriteHitInfo, vSpriteDir, iX, iY, iZ, vec2(57.0, 22.0), fLightLevel, TEX_PLAYW, r );
if(fSpriteT < fClosestT)
{
if(MaskCorpseSprite(vSpriteHitInfo.xy))
{
fClosestT = fSpriteT;
vHitInfo = vSpriteHitInfo;
}
}
}
#endif
vec3 DrawScene(vec3 vForwards, vec2 vUV, Ray r )
{
vec4 vHitInfo;
float fClosestT;
float fNoFog = 0.0;
MapIntersect( fClosestT, vHitInfo, r );
#ifdef ENABLE_SPRITES
vec2 vSpriteDir = -normalize(vec2(-vForwards.z, vForwards.x));
BarrelSprite(fClosestT, vHitInfo, vSpriteDir, 1088, 0, -2944, 0.565, r);
BarrelSprite(fClosestT, vHitInfo, vSpriteDir, 864, 0, -3328, 0.565, r);
BarrelSprite(fClosestT, vHitInfo, vSpriteDir, 1312, -16, -3264, 0.878, r);
CorpseSprite(fClosestT, vHitInfo, vSpriteDir, 1024, -16, -3264, 0.878, r);
#endif
vHitInfo.z = clamp(vHitInfo.z + kExtraLight, 0.0, 1.0);
// sky
#ifdef DRAW_SKY
float fDoSky = step(0.9, vHitInfo.w) * step(vHitInfo.w, 1.1);
fNoFog = max(fNoFog, fDoSky);
float fSkyU = (atan2(vForwards.x, vForwards.z) * 512.0 / radians(180.0)) + vUV.x * 320.0;
float fSkyV = vUV.y * 240.0;
vHitInfo = mix(vHitInfo, vec4(fSkyU, fSkyV, 1.0, 1.0), fDoSky);
#endif
// fade in effect
#ifdef INTRO_EFFECT
float fEffectOffset = max(Time - 1.0, 0.0) - hash(vUV.x);
vec2 vEffectUV = vUV;
vEffectUV.y += clamp(fEffectOffset, 0.0, 1.0);
float fDoEffect = step(vEffectUV.y, 1.0);
vHitInfo = mix(vHitInfo, vec4(vEffectUV * 128.0, 1.0, 3.0), fDoEffect);
fNoFog = max(fNoFog, fDoEffect);
#endif
#ifdef DISCARD_BACKGROUND
if(vHitInfo.w == 0.0) discard;
#endif
float fLightLevel = clamp( vHitInfo.z, 0.0, 1.0 );
float fDepth = dot(r.vRayDir, vForwards) * fClosestT;
float fDepthFade = fDepth * kDepthFadeScale;
float fApplyFog = 1.0 - fNoFog;
fLightLevel = clamp( fLightLevel - fDepthFade * fApplyFog, 0.0, 1.0 );
vec3 vResult = SampleTexture( vHitInfo.w, vHitInfo.xy ) * fLightLevel;
vResult = clamp(vResult * 1.2, 0.0, 1.0);
#ifdef QUANTIZE_FINAL_IMAGE
vResult = Quantize(vResult);
#endif
return vResult;
}
void DemoCamera( float time, inout vec3 vCameraPos, inout vec3 vCameraTarget )
{
vCameraPos = vec3(1050, 30, -3616);
vCameraTarget = vec3(1050, 30, -3500);
#ifdef DEMO_CAMERA
float fCamTime = time - 5.0;
if(fCamTime > 0.0) fCamTime = fmod(fCamTime, 33.0 - 5.0) + 5.0;
if(Time==10.0) fCamTime = 0.0; // hack for shadertoy preview screen
vCameraTarget = mix( vCameraTarget, vec3(1834, 30, -3264), smoothstep(5.0, 10.0, fCamTime));
vCameraPos = mix( vCameraPos, vec3(1280, 30, -3350), smoothstep(8.0, 13.0, fCamTime));
vCameraTarget = mix( vCameraTarget, vec3(1280, 30, -2976), smoothstep(11.0, 16.0, fCamTime));
vCameraPos = mix( vCameraPos, vec3(1280, 30, -2976), smoothstep(13.0, 19.0, fCamTime));
vCameraTarget = mix( vCameraTarget, vec3(768, 30, -3050), smoothstep(16.0, 20.0, fCamTime));
vCameraPos = mix( vCameraPos, vec3(832, 30, -3020), smoothstep(19.0, 23.0, fCamTime));
vCameraTarget = mix( vCameraTarget, vec3(1256, 30, -3648), smoothstep(20.0, 25.0, fCamTime));
vCameraPos = mix( vCameraPos, vec3(768, 30, -3424), smoothstep(23.0, 28.0, fCamTime));
vCameraPos = mix( vCameraPos, vec3(1050, 30, -3616), smoothstep(25.0, 30.0, fCamTime));
vCameraTarget = mix( vCameraTarget, vec3(1050, 30, -3500), smoothstep(28.0, 33.0, fCamTime));
#endif
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 vOrigUV = fragCoord.xy / Resolution.xy;
#ifdef PIXELATE_IMAGE
vec2 vUV = floor(vOrigUV * vFakeResolution + 0.5) * (1.0 / vFakeResolution);
#else
vec2 vUV = vOrigUV;
#endif
vec3 vCameraPos = vec3(0.0, 0.0, 0.0);
vec3 vCameraTarget = vec3(0.0, 0.0, 0.0);
// vec2 vMouse = (iMouse.xy / iResolution.xy);
const vec2 vStart = vec2(1050, -3616);
/*if(iMouse.z > 0.0)
{
vec2 vDir = normalize((abs(iMouse.zw) / iResolution.xy) - 0.5);
vec2 vOffset = (iMouse.xy - abs(iMouse.zw)) / iResolution.xy;
vCameraPos.y = 30.0;
vCameraPos.xz = (vDir.yx * vec2(1.0, -1.0) * vOffset.x + vDir * vOffset.y) * 5000.0;
vCameraPos.xz += vStart;
vCameraTarget.xz = vCameraPos.xz + vDir * 10.0;
vCameraTarget.y = vCameraPos.y;
}
else*/
{
DemoCamera( Time, vCameraPos, vCameraTarget );
}
#ifdef HEAD_BOB
float fBob = sin(length(vCameraPos.xz - vStart) * 0.04) * 4.0; // head bob
vCameraPos.y += fBob;
vCameraTarget.y += fBob;
#endif
vec2 vWindowCoord = (vUV * 2.0 - 1.0) * vec2(Resolution.x / Resolution.y, 1.0);
Ray r;
r.vRayOrigin = vCameraPos;
r.vRayDir = GetCameraRayDir( vWindowCoord, vCameraPos, vCameraTarget );
vec3 vForwards = normalize(vCameraTarget - vCameraPos);
vec3 vResult = DrawScene(vForwards, vUV, r);
#ifdef DRAW_COMPASS
// a hack - assume we have never clicked the mouse before if coordinate is zero
if((iMouse.x > 0.5) && (iMouse.y > 0.5))
{
if(iMouse.z <= 0.0)
{
vec2 vCompassUV = vOrigUV - 0.5;
vCompassUV.x *= iResolution.x / iResolution.y;
float fDistNS = ((abs(vCompassUV.x) * 10.0) + abs(vCompassUV.y) - 0.05);
float fDistEW = ((abs(vCompassUV.y) * 10.0) + abs(vCompassUV.x) - 0.025);
float fDistCircle = abs(0.045 - length(vCompassUV)) * 10.0;
float fDist = min(min(fDistNS, fDistEW), fDistCircle);
float fAmount = clamp(fDist * 20.0, 0.0, 1.0);
float fCol = step(fract((floor(vCompassUV.x) + floor(vCompassUV.y)) * 0.5), 0.25);
vResult = mix(vec3(fCol * 0.75 + 0.25), vResult, fAmount);
}
}
#endif
fragColor = vec4(vResult, 1.0);
}
// Generated code follows
// ----------------- 8< -------------------------- 8< -------------------------- 8< --------------
// Textures
#define TEX_X 0.0
#define TEX_F_SKY1 1.0
#define TEX_NUKAGE3 2.0
#define TEX_FLOOR7_1 3.0
#define TEX_FLAT5_5 4.0
#define TEX_FLOOR4_8 5.0
#define TEX_CEIL3_5 6.0
#define TEX_TLITE6_4 7.0
#define TEX_FLAT14 8.0
#define TEX_FLOOR7_2 9.0
#define TEX_STEP2 10.0
#define TEX_TLITE6_1 11.0
#define TEX_DOOR3 12.0
#define TEX_LITE3 13.0
#define TEX_STARTAN3 14.0
#define TEX_BROWN1 15.0
#define TEX_DOORSTOP 16.0
#define TEX_COMPUTE2 17.0
#define TEX_STEP6 18.0
#define TEX_BROWN144 19.0
#define TEX_SUPPORT2 20.0
#define TEX_STARG3 21.0
#define TEX_DOORTRAK 22.0
#define TEX_SLADWALL 23.0
#define TEX_TEKWALL4 24.0
#define TEX_SW1COMP 25.0
#define TEX_BIGDOOR2 26.0
// Sectors
void Sector0( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=1.000;
const vec2 vSH=vec2(-80.0, 216.0);
BeginSector( vSS, vSH, r );
Lower( fT, vInf, vSS, 1520, -3168, 1672, -3104, 164, fLt, vSH, -56, TEX_BROWN144, r );
Lower( fT, vInf, vSS, 1672, -3104, 1896, -3104, 224, fLt-kC, vSH, -56, TEX_BROWN144, r );
Lower( fT, vInf, vSS, 1896, -3104, 2040, -3144, 149, fLt, vSH, -56, TEX_BROWN144, r );
Lower( fT, vInf, vSS, 2040, -3144, 2128, -3272, 155, fLt, vSH, -56, TEX_BROWN144, r );
Lower( fT, vInf, vSS, 2128, -3272, 2064, -3408, 150, fLt, vSH, -56, TEX_BROWN144, r );
Lower( fT, vInf, vSS, 2064, -3408, 1784, -3448, 282, fLt, vSH, -56, TEX_BROWN144, r );
Lower( fT, vInf, vSS, 1784, -3448, 1544, -3384, 248, fLt, vSH, -56, TEX_BROWN144, r );
Lower( fT, vInf, vSS, 1544, -3384, 1520, -3168, 217, fLt, vSH, -56, TEX_BROWN144, r );
EndSector( fT, vInf, vSS, fLt, vec2(TEX_NUKAGE3, TEX_F_SKY1), r );
}
void Sector1( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=1.000;
const vec2 vSH=vec2(-56.0, 216.0);
// merge walls from ultimate doom secret
BeginSector( vSS, vSH, r );
Open( fT, vInf, vSS, 1376, -3200, 1376, -3104, 96, fLt+kC, vSH, 8, 192, TEX_STARTAN3, TEX_STARTAN3, r );
Open( fT, vInf, vSS, 1376, -3360, 1376, -3264, 96, fLt+kC, vSH, 8, 192, TEX_STARTAN3, TEX_STARTAN3, r );
Wall( fT, vInf, vSS, 1376, -3264, 1376, -3200, 64, fLt+kC, vSH, TEX_STARTAN3, r);
Wall( fT, vInf, vSS, 1376, -3104, 1376, -2944, 160, fLt+kC, vSH, TEX_STARTAN3, r);
Wall( fT, vInf, vSS, 1376, -2944, 1472, -2880, 115, fLt, vSH, TEX_STARTAN3, r);
Wall( fT, vInf, vSS, 1856, -2880, 1920, -2920, 75, fLt, vSH, TEX_STARTAN3, r);
Null( vSS, 1520, -3168, 1672, -3104, r );
Null( vSS, 1672, -3104, 1896, -3104, r );
Null( vSS, 1896, -3104, 2040, -3144, r );
Null( vSS, 2040, -3144, 2128, -3272, r );
Null( vSS, 2128, -3272, 2064, -3408, r );
Null( vSS, 2064, -3408, 1784, -3448, r );
Null( vSS, 1784, -3448, 1544, -3384, r );
Null( vSS, 1544, -3384, 1520, -3168, r );
Wall( fT, vInf, vSS, 2736, -3360, 2736, -3648, 288, fLt+kC, vSH, TEX_STARTAN3, r);
#ifdef CLOSE_NUKAGE_SECTOR
Wall( fT, vInf, vSS, 2736, -3648, 1376, -3648, 2736-1376, fLt, vSH, TEX_STARTAN3, r);
#else
Null( vSS, 2736, -3648, 2240, -3648, r );
Null( vSS, 2240, -3648, 1984, -3648, r );
Null( vSS, 1984, -3648, 1376, -3648, r );
#endif
Wall( fT, vInf, vSS, 2240, -2920, 2272, -3008, 93, fLt, vSH, TEX_STARTAN3, r);
Wall( fT, vInf, vSS, 2272, -3008, 2432, -3112, 190, fLt, vSH, TEX_STARTAN3, r);
Wall( fT, vInf, vSS, 2432, -3112, 2736, -3112, 304, fLt-kC, vSH, TEX_STARTAN3, r);
Open( fT, vInf, vSS, 2736, -3112, 2736, -3360, 248, fLt+kC, vSH, 0, 136, TEX_STARTAN3, TEX_STARTAN3, r );
// Merge walls from Ultimate Doom secret
Wall( fT, vInf, vSS, 1376, -3648, 1376, -3360, 3648-3360, fLt+kC, vSH, TEX_STARTAN3, r);
//Wall( fT, vInf, vSS, 1376, -3648, 1376, -3520, 128, fLt+kC, vSH, TEX_STARTAN3);
//Wall( fT, vInf, vSS, 1376, -3392, 1376, -3360, 32, fLt+kC, vSH, TEX_STARTAN3);
//Wall( fT, vInf, vSS, 1376, -3520, 1376, -3392, 128, fLt+kC, vSH, TEX_STARTAN3);
// Merge walls from Ultimate Doom secret
Wall( fT, vInf, vSS, 1472, -2880, 1856, -2880, 1856-1472, fLt-kC, vSH, TEX_STARTAN3, r);
//Wall( fT, vInf, vSS, 1472, -2880, 1664, -2880, 192, fLt-kC, vSH, TEX_STARTAN3);
//Wall( fT, vInf, vSS, 1664, -2880, 1856, -2880, 192, fLt-kC, vSH, TEX_STARTAN3);
// Merge walls
Wall( fT, vInf, vSS, 1920, -2920, 2240, -2920, 2240-1920, fLt-kC, vSH, TEX_STARTAN3, r);
//Wall( fT, vInf, vSS, 1920, -2920, 2176, -2920, 256, fLt-kC, vSH, TEX_STARTAN3);
//Wall( fT, vInf, vSS, 2176, -2920, 2240, -2920, 64, fLt-kC, vSH, TEX_STARTAN3);
EndSector( fT, vInf, vSS, fLt, vec2(TEX_FLOOR7_1, TEX_F_SKY1), r );
}
void Sector3( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=1.000;
const vec2 vSH=vec2(8.0, 192.0);
BeginSector( vSS, vSH, r );
Null( vSS, 1344, -3264, 1344, -3360, r );
Null( vSS, 1376, -3360, 1376, -3264, r );
Wall( fT, vInf, vSS, 1344, -3264, 1376, -3264, 32, fLt-kC, vSH, TEX_DOORSTOP, r);
Wall( fT, vInf, vSS, 1376, -3360, 1344, -3360, 32, fLt-kC, vSH, TEX_DOORSTOP, r);
EndSector( fT, vInf, vSS, fLt, vec2(TEX_FLAT5_5, TEX_FLAT5_5), r );
}
void Sector5( inout float fT, inout vec4 vInf, Ray r)
{
vec4 vSS;
const float fLt=1.000;
const vec2 vSH=vec2(8.0, 192.0);
BeginSector( vSS, vSH, r );
Null( vSS, 1344, -3104, 1344, -3200, r );
Null( vSS, 1376, -3200, 1376, -3104, r );
Wall( fT, vInf, vSS, 1376, -3200, 1344, -3200, 32, fLt-kC, vSH, TEX_DOORSTOP, r);
Wall( fT, vInf, vSS, 1344, -3104, 1376, -3104, 32, fLt-kC, vSH, TEX_DOORSTOP, r);
EndSector( fT, vInf, vSS, fLt, vec2(TEX_FLAT5_5, TEX_FLAT5_5), r );
}
void Sector11( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=1.000;
const vec2 vSH=vec2(-56.0, 24.0);
BeginSector( vSS, vSH, r );
Wall( fT, vInf, vSS, 1528, -3680, 1376, -3648, 155, fLt, vSH, TEX_BROWN144, r);
Wall( fT, vInf, vSS, 1672, -3744, 1528, -3680, 157, fLt, vSH, TEX_BROWN144, r);
Wall( fT, vInf, vSS, 1984, -3776, 1672, -3744, 313, fLt, vSH, TEX_BROWN144, r);
Null( vSS, 1984, -3648, 1376, -3648, r );
Null( vSS, 1984, -3648, 1984, -3776, r );
EndSector( fT, vInf, vSS, fLt, vec2(TEX_FLOOR7_1, TEX_F_SKY1), r );
}
void Sector12( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=1.000;
const vec2 vSH=vec2(-56.0, 64.0);
BeginSector( vSS, vSH, r );
Wall( fT, vInf, vSS, 2240, -3776, 2208, -3680, 101, fLt, vSH, TEX_BROWN1, r);
Wall( fT, vInf, vSS, 2208, -3680, 2176, -3680, 32, fLt-kC, vSH, TEX_BROWN1, r);
Wall( fT, vInf, vSS, 2016, -3680, 1984, -3776, 101, fLt, vSH, TEX_BROWN1, r);
Wall( fT, vInf, vSS, 2048, -3680, 2016, -3680, 32, fLt-kC, vSH, TEX_BROWN1, r);
Upper( fT, vInf, vSS, 2176, -3680, 2048, -3680, 128, fLt-kC, vSH, 16, TEX_BROWN1, r );
Null( vSS, 2240, -3648, 1984, -3648, r );
Null( vSS, 1984, -3648, 1984, -3776, r );
Null( vSS, 2240, -3776, 2240, -3648, r );
EndSector( fT, vInf, vSS, fLt, vec2(TEX_FLOOR7_1, TEX_F_SKY1), r );
}
void Sector24( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=0.565;
const vec2 vSH=vec2(0.0, 144.0);
BeginSector( vSS, vSH ,r);
Wall( fT, vInf, vSS, 1216, -2880, 1248, -2528, 353, fLt, vSH, TEX_STARTAN3,r);
Wall( fT, vInf, vSS, 1384, -2592, 1344, -2880, 290, fLt, vSH, TEX_STARTAN3,r);
Wall( fT, vInf, vSS, 1472, -2560, 1384, -2592, 93, fLt, vSH, TEX_STARTAN3,r);
Wall( fT, vInf, vSS, 1248, -2528, 1472, -2432, 243, fLt, vSH, TEX_STARTAN3,r);
Upper( fT, vInf, vSS, 1344, -2880, 1216, -2880, 128, fLt-kC, vSH, 72, TEX_STARTAN3 ,r);
Upper( fT, vInf, vSS, 1472, -2432, 1472, -2560, 128, fLt+kC, vSH, 88, TEX_STARTAN3 ,r);
EndSector( fT, vInf, vSS, fLt, vec2(TEX_FLOOR4_8, TEX_CEIL3_5) ,r);
}
void Sector25( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=1.000;
const vec2 vSH=vec2(0.0, 88.0);
BeginSector( vSS, vSH , r);
Null( vSS, 1472, -2432, 1472, -2560 , r);
Wall( fT, vInf, vSS, 1536, -2432, 1536, -2560, 128, fLt+kC, vSH, TEX_BIGDOOR2, r);
Wall( fT, vInf, vSS, 1536, -2560, 1472, -2560, 64, fLt-kC, vSH, TEX_STARTAN3, r);
Wall( fT, vInf, vSS, 1472, -2432, 1536, -2432, 64, fLt-kC, vSH, TEX_STARTAN3, r);
EndSector( fT, vInf, vSS, fLt, vec2(TEX_FLOOR4_8, TEX_TLITE6_4) , r);
}
void Sector27( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=0.878;
const vec2 vSH=vec2(-16.0, 200.0);
BeginSector( vSS, vSH ,r);
Wall( fT, vInf, vSS, 1216, -3392, 1216, -3360, 32, fLt+kC, vSH, TEX_BROWN1,r);
Wall( fT, vInf, vSS, 1216, -3360, 1184, -3360, 32, fLt-kC, vSH, TEX_BROWN1,r);
Wall( fT, vInf, vSS, 1184, -3104, 1216, -3104, 32, fLt-kC, vSH, TEX_BROWN1,r);
Wall( fT, vInf, vSS, 1216, -3104, 1216, -3072, 32, fLt+kC, vSH, TEX_BROWN1,r);
Open( fT, vInf, vSS, 1344, -3264, 1344, -3360, 96, fLt+kC, vSH, 8, 192, TEX_STARTAN3, TEX_STARTAN3 ,r);
Wall( fT, vInf, vSS, 1344, -3200, 1344, -3264, 64, fLt+kC, vSH, TEX_STARTAN3,r);
Open( fT, vInf, vSS, 1344, -3104, 1344, -3200, 96, fLt+kC, vSH, 8, 192, TEX_STARTAN3, TEX_STARTAN3 ,r);
Open( fT, vInf, vSS, 1344, -3360, 1216, -3392, 131, fLt, vSH, 0, 72, TEX_STEP6, TEX_STARTAN3 ,r);
Open( fT, vInf, vSS, 1216, -3072, 1344, -3104, 131, fLt, vSH, 0, 72, TEX_STEP6, TEX_STARTAN3 ,r);
Open( fT, vInf, vSS, 928, -3104, 1184, -3104, 256, fLt-kC, vSH, -8, 120, TEX_STEP6, TEX_STARTAN3 ,r);
Open( fT, vInf, vSS, 1184, -3360, 928, -3360, 256, fLt-kC, vSH, -8, 120, TEX_STEP6, TEX_STARTAN3 ,r);
Open( fT, vInf, vSS, 928, -3360, 928, -3104, 256, fLt+kC, vSH, -8, 120, TEX_STEP6, TEX_STARTAN3 ,r);
EndSector( fT, vInf, vSS, fLt, vec2(TEX_FLAT14, TEX_CEIL3_5) ,r);
}
void Sector28( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=0.753;
const vec2 vSH=vec2(-8.0, 120.0);
BeginSector( vSS, vSH , r);
Wall( fT, vInf, vSS, 928, -3392, 928, -3360, 32, fLt+kC, vSH, TEX_BROWN1, r);
Wall( fT, vInf, vSS, 928, -3360, 896, -3360, 32, fLt-kC, vSH, TEX_BROWN1, r);
Wall( fT, vInf, vSS, 1184, -3360, 1184, -3392, 32, fLt+kC, vSH, TEX_BROWN1, r);
Wall( fT, vInf, vSS, 896, -3104, 928, -3104, 32, fLt-kC, vSH, TEX_BROWN1, r);
Wall( fT, vInf, vSS, 928, -3104, 928, -3072, 32, fLt+kC, vSH, TEX_BROWN1, r);
Wall( fT, vInf, vSS, 1184, -3072, 1184, -3104, 32, fLt+kC, vSH, TEX_BROWN1, r);
Open( fT, vInf, vSS, 1184, -3392, 928, -3392, 256, fLt-kC, vSH, 0, 72, TEX_STEP6, TEX_COMPUTE2 , r);
Null( vSS, 928, -3104, 1184, -3104 , r);
Null( vSS, 1184, -3360, 928, -3360 , r);
Null( vSS, 928, -3360, 928, -3104 , r);
Open( fT, vInf, vSS, 896, -3360, 896, -3104, 256, fLt+kC, vSH, 0, 72, TEX_STEP6, TEX_COMPUTE2 , r);
Open( fT, vInf, vSS, 928, -3072, 1184, -3072, 256, fLt-kC, vSH, 0, 72, TEX_STEP6, TEX_COMPUTE2 , r);
EndSector( fT, vInf, vSS, fLt, vec2(TEX_FLAT14, TEX_CEIL3_5) , r);
}
void Sector29( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=0.565;
const vec2 vSH=vec2(0.0, 72.0);
BeginSector( vSS, vSH ,r);
Wall( fT, vInf, vSS, 1152, -3648, 1088, -3648, 64, fLt-kC, vSH, TEX_STARTAN3,r);
Wall( fT, vInf, vSS, 1024, -3648, 960, -3648, 64, fLt-kC, vSH, TEX_STARTAN3,r);
Wall( fT, vInf, vSS, 1280, -3552, 1152, -3648, 160, fLt, vSH, TEX_STARTAN3,r);
Wall( fT, vInf, vSS, 960, -3648, 832, -3552, 160, fLt, vSH, TEX_STARTAN3,r);
Wall( fT, vInf, vSS, 1344, -3552, 1280, -3552, 64, fLt-kC, vSH, TEX_STARTAN3,r);
Wall( fT, vInf, vSS, 832, -3552, 704, -3552, 128, fLt-kC, vSH, TEX_STARTAN3,r);
Wall( fT, vInf, vSS, 896, -3392, 928, -3392, 32, fLt-kC, vSH, TEX_BROWN1,r);
Wall( fT, vInf, vSS, 896, -3360, 896, -3392, 32, fLt+kC, vSH, TEX_BROWN1,r);
Wall( fT, vInf, vSS, 1184, -3392, 1216, -3392, 32, fLt-kC, vSH, TEX_BROWN1,r);
Wall( fT, vInf, vSS, 896, -3072, 896, -3104, 32, fLt+kC, vSH, TEX_BROWN1,r);
Wall( fT, vInf, vSS, 928, -3072, 896, -3072, 32, fLt-kC, vSH, TEX_BROWN1,r);
Wall( fT, vInf, vSS, 1216, -3072, 1184, -3072, 32, fLt-kC, vSH, TEX_BROWN1,r);
Wall( fT, vInf, vSS, 1344, -2880, 1344, -3104, 224, fLt+kC, vSH, TEX_STARTAN3,r);
Null( vSS, 1184, -3392, 928, -3392 ,r);
Null( vSS, 1344, -3360, 1216, -3392 ,r);
Null( vSS, 1216, -3072, 1344, -3104 ,r);
Wall( fT, vInf, vSS, 704, -2944, 832, -2944, 128, fLt-kC, vSH, TEX_STARTAN3,r);
Wall( fT, vInf, vSS, 832, -2944, 968, -2880, 150, fLt, vSH, TEX_STARTAN3,r);
Wall( fT, vInf, vSS, 968, -2880, 1216, -2880, 248, fLt-kC, vSH, TEX_STARTAN3,r);
Null( vSS, 1088, -3648, 1024, -3648 ,r);
Null( vSS, 896, -3360, 896, -3104 ,r);
Null( vSS, 928, -3072, 1184, -3072 ,r);
#ifdef CLOSE_START_SECTOR
Wall( fT, vInf, vSS, 704, -3552, 704, -2944, 3552-2944, fLt+kC, vSH, TEX_STARTAN3,r);
#else
Wall( fT, vInf, vSS, 704, -3552, 704, -3360, 192, fLt+kC, vSH, TEX_STARTAN3,r);
Wall( fT, vInf, vSS, 704, -3104, 704, -2944, 160, fLt+kC, vSH, TEX_STARTAN3,r);
Null( vSS, 704, -3104, 704, -3360,r );
#endif
Null( vSS, 1344, -2880, 1216, -2880,r );
Wall( fT, vInf, vSS, 1344, -3360, 1344, -3392, 32, fLt+kC, vSH, TEX_STARTAN3,r);
// Merge walls from Ultimate Doom secret
Wall( fT, vInf, vSS, 1344, -3392, 1344, -3552, 3552 - 3392, fLt+kC, vSH, TEX_STARTAN3,r);
//Wall( fT, vInf, vSS, 1344, -3520, 1344, -3552, 32, fLt+kC, vSH, TEX_STARTAN3);
//Wall( fT, vInf, vSS, 1344, -3392, 1344, -3520, 128, fLt+kC, vSH, TEX_STARTAN3);
EndSector( fT, vInf, vSS, fLt, vec2(TEX_FLOOR4_8, TEX_CEIL3_5),r );
}
void Sector30( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
float fLt=(hash(floor(Time * 10.0)) > 0.3) ? 0.565 : 1.0;
const vec2 vSH=vec2(0.0, 72.0);
BeginSector( vSS, vSH ,r);
Wall( fT, vInf, vSS, 1088, -3680, 1024, -3680, 64, fLt-kC, vSH, TEX_DOOR3,r);
Wall( fT, vInf, vSS, 1024, -3680, 1024, -3648, 32, fLt+kC, vSH, TEX_LITE3,r);
Wall( fT, vInf, vSS, 1088, -3648, 1088, -3680, 32, fLt+kC, vSH, TEX_LITE3,r);
Null( vSS, 1088, -3648, 1024, -3648 ,r);
EndSector( fT, vInf, vSS, fLt, vec2(TEX_FLOOR4_8, TEX_CEIL3_5) ,r);
}
void Sector31( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=0.502;
const vec2 vSH=vec2(-8.0, 120.0);
BeginSector( vSS, vSH , r);
Open( fT, vInf, vSS, 704, -3104, 704, -3360, 256, fLt+kC, vSH, 0, 72, TEX_STEP6, TEX_STARTAN3 , r);
Wall( fT, vInf, vSS, 512, -3328, 512, -3304, 24, fLt+kC, vSH, TEX_STARTAN3, r);
Wall( fT, vInf, vSS, 512, -3160, 512, -3136, 24, fLt+kC, vSH, TEX_STARTAN3, r);
Wall( fT, vInf, vSS, 512, -3136, 680, -3104, 171, fLt, vSH, TEX_STARTAN3, r);
Wall( fT, vInf, vSS, 680, -3104, 704, -3104, 24, fLt-kC, vSH, TEX_SUPPORT2, r);
Wall( fT, vInf, vSS, 704, -3360, 680, -3360, 24, fLt-kC, vSH, TEX_SUPPORT2, r);
Wall( fT, vInf, vSS, 680, -3360, 512, -3328, 171, fLt, vSH, TEX_STARTAN3, r);
Null( vSS, 496, -3160, 496, -3304 , r);
Wall( fT, vInf, vSS, 512, -3304, 496, -3304, 16, fLt-kC, vSH, TEX_DOORTRAK, r);
Wall( fT, vInf, vSS, 496, -3160, 512, -3160, 16, fLt-kC, vSH, TEX_DOORTRAK, r);
EndSector( fT, vInf, vSS, fLt, vec2(TEX_FLOOR4_8, TEX_CEIL3_5) , r);
}
void Sector32( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=0.502;
const vec2 vSH=vec2(-8.0, 224.0);
BeginSector( vSS, vSH , r);
Upper( fT, vInf, vSS, 496, -3160, 496, -3304, 144, fLt+kC, vSH, 120, TEX_STARG3 , r);
Wall( fT, vInf, vSS, 496, -3304, 496, -3328, 24, fLt+kC, vSH, TEX_STARG3, r);
Wall( fT, vInf, vSS, 496, -3328, 448, -3456, 136, fLt, vSH, TEX_STARG3, r);
Wall( fT, vInf, vSS, 448, -3456, 128, -3456, 320, fLt-kC, vSH, TEX_STARG3, r);
Wall( fT, vInf, vSS, 128, -3008, 448, -3008, 320, fLt-kC, vSH, TEX_STARG3, r);
Wall( fT, vInf, vSS, 496, -3136, 496, -3160, 24, fLt+kC, vSH, TEX_STARG3, r);
Wall( fT, vInf, vSS, 448, -3008, 496, -3136, 136, fLt, vSH, TEX_STARG3, r);
Lower( fT, vInf, vSS, 128, -3264, 160, -3264, 32, fLt-kC, vSH, 88, TEX_SLADWALL , r);
Lower( fT, vInf, vSS, 160, -3264, 192, -3264, 32, fLt-kC, vSH, 72, TEX_SLADWALL , r);
Lower( fT, vInf, vSS, 192, -3264, 224, -3264, 32, fLt-kC, vSH, 56, TEX_SLADWALL , r);
Lower( fT, vInf, vSS, 224, -3264, 256, -3264, 32, fLt-kC, vSH, 40, TEX_SLADWALL , r);
Lower( fT, vInf, vSS, 256, -3264, 288, -3264, 32, fLt-kC, vSH, 24, TEX_SLADWALL , r);
Lower( fT, vInf, vSS, 288, -3264, 320, -3264, 32, fLt-kC, vSH, 8, TEX_SLADWALL , r);
Lower( fT, vInf, vSS, 320, -3264, 320, -3200, 64, fLt+kC, vSH, 8, TEX_STEP6 , r);
Lower( fT, vInf, vSS, 320, -3200, 288, -3200, 32, fLt-kC, vSH, 8, TEX_SLADWALL , r);
Lower( fT, vInf, vSS, 288, -3200, 256, -3200, 32, fLt-kC, vSH, 24, TEX_SLADWALL , r);
Lower( fT, vInf, vSS, 256, -3200, 224, -3200, 32, fLt-kC, vSH, 40, TEX_SLADWALL , r);
Lower( fT, vInf, vSS, 224, -3200, 192, -3200, 32, fLt-kC, vSH, 56, TEX_SLADWALL , r);
Lower( fT, vInf, vSS, 192, -3200, 160, -3200, 32, fLt-kC, vSH, 72, TEX_SLADWALL , r);
Lower( fT, vInf, vSS, 160, -3200, 128, -3200, 32, fLt-kC, vSH, 88, TEX_SLADWALL , r);
Open( fT, vInf, vSS, 128, -3200, 64, -3072, 143, fLt, vSH, 104, 192, TEX_STARG3, TEX_STARG3 , r);
Wall( fT, vInf, vSS, 64, -3072, 128, -3008, 90, fLt, vSH, TEX_STARG3, r);
Wall( fT, vInf, vSS, 128, -3456, 64, -3392, 90, fLt, vSH, TEX_STARG3, r);
Open( fT, vInf, vSS, 64, -3392, 128, -3264, 143, fLt, vSH, 104, 192, TEX_STARG3, TEX_STARG3 , r);
Open( fT, vInf, vSS, 256, -3136, 320, -3136, 64, fLt-kC, vSH, 40, 184, TEX_TEKWALL4, TEX_TEKWALL4 , r);
Open( fT, vInf, vSS, 320, -3136, 320, -3072, 64, fLt+kC, vSH, 40, 184, TEX_TEKWALL4, TEX_TEKWALL4 , r);
Open( fT, vInf, vSS, 320, -3072, 256, -3072, 64, fLt-kC, vSH, 40, 184, TEX_SW1COMP, TEX_TEKWALL4 , r);
Open( fT, vInf, vSS, 256, -3072, 256, -3136, 64, fLt+kC, vSH, 40, 184, TEX_TEKWALL4, TEX_TEKWALL4 , r);
Open( fT, vInf, vSS, 256, -3392, 320, -3392, 64, fLt-kC, vSH, 40, 184, TEX_TEKWALL4, TEX_TEKWALL4 , r);
Open( fT, vInf, vSS, 320, -3392, 320, -3328, 64, fLt+kC, vSH, 40, 184, TEX_TEKWALL4, TEX_TEKWALL4 , r);
Open( fT, vInf, vSS, 320, -3328, 256, -3328, 64, fLt-kC, vSH, 40, 184, TEX_TEKWALL4, TEX_TEKWALL4 , r);
Open( fT, vInf, vSS, 256, -3328, 256, -3392, 64, fLt+kC, vSH, 40, 184, TEX_TEKWALL4, TEX_TEKWALL4 , r);
EndSector( fT, vInf, vSS, fLt, vec2(TEX_FLOOR4_8, TEX_FLOOR7_2) , r);
}
void Sector35( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=1.000;
const vec2 vSH=vec2(40.0, 184.0);
BeginSector( vSS, vSH, r );
Null( vSS, 256, -3392, 320, -3392, r );
Null( vSS, 320, -3392, 320, -3328, r );
Null( vSS, 320, -3328, 256, -3328, r );
Null( vSS, 256, -3328, 256, -3392, r );
EndSector( fT, vInf, vSS, fLt, vec2(TEX_STEP2, TEX_TLITE6_1), r );
}
void Sector36( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=1.000;
const vec2 vSH=vec2(40.0, 184.0);
BeginSector( vSS, vSH, r );
Null( vSS, 256, -3136, 320, -3136, r );
Null( vSS, 320, -3136, 320, -3072, r );
Null( vSS, 320, -3072, 256, -3072, r );
Null( vSS, 256, -3072, 256, -3136, r );
EndSector( fT, vInf, vSS, fLt, vec2(TEX_STEP2, TEX_TLITE6_1), r );
}
void Sector63( inout float fT, inout vec4 vInf, Ray r )
{
vec4 vSS;
const float fLt=1.000;
const vec2 vSH=vec2(-56.0, 24.0);
BeginSector( vSS, vSH, r );