@@ -371,25 +371,6 @@ bool internalBoxPointWithinVolume(float3 p, internalBoxQuad q) {
371
371
return all (abs (dotAxes) < 0.5 );
372
372
}
373
373
374
- bool internalBoxPointWithinVolumeold1 (float3 p, internalBoxQuad q) {
375
- float3 relvec = q.a - p;
376
- float3 planeNormal = q.planeNormalZComp.xyz;
377
- float3 uline = q.ulineAndLength.xyz;
378
- float3 vline = q.vlineAndLength.xyz;
379
- float3 dotAxes = float3 (
380
- dot (relvec, uline),
381
- dot (relvec, vline),
382
- dot (relvec, planeNormal)
383
- );
384
- float3 compareLengths = float3 (
385
- q.ulineAndLength.w,
386
- q.vlineAndLength.w,
387
- q.planeNormalZComp.w
388
- );
389
- return (//all(dotAxes >= 0) &&
390
- all (dotAxes * compareLengths <= 1 ));
391
- }
392
-
393
374
bool internalBoxTriangleIntersectsQuad (float3 p1, float3 p2, float3 p3, internalBoxQuad q) {
394
375
float3 x1;
395
376
float2 x2;
@@ -526,26 +507,19 @@ bool boxConditionCheck(float3 origvertpos) {
526
507
}
527
508
});
528
509
BOXCLIP_FOR_EACH_QUAD (ShowVolume, {
529
- if (1 ){//q.planeNormalZComp.w < 0) {
530
- if (internalBoxPointWithinVolume (origvertpos.xyz, q)) {
531
- found = true ;
532
- }
510
+ if (internalBoxPointWithinVolume (origvertpos.xyz, q)) {
511
+ found = true ;
533
512
}
534
513
});
535
514
BOXCLIP_FOR_EACH_QUAD (HideVolume, {
536
- if (1 ){//if (q.planeNormalZComp.w < 0) {
537
- if (internalBoxPointWithinVolume (origvertpos.xyz, q)) {
538
- found = false ;
539
- }
515
+ if (internalBoxPointWithinVolume (origvertpos.xyz, q)) {
516
+ found = false ;
540
517
}
541
518
});
542
519
BOXCLIP_FOR_EACH_QUAD (ClipShow, {
543
520
if (internalBoxPointInQuad (origvertpos.xyz, q, thispos, thisuv)) {
544
521
found = true ;
545
522
}
546
- // if (internalBoxFrustumCheck(origvertpos.xyz, q, -3)) {
547
- // found = true;
548
- // }
549
523
});
550
524
BOXCLIP_FOR_EACH_QUAD (ClipHide, {
551
525
if (internalBoxPointInQuad (origvertpos.xyz, q, thispos, thisuv)) {
@@ -571,6 +545,54 @@ void boxConditionalClipWorld(float4 worldPos) {
571
545
clip (boxConditionCheck (mul (unity_WorldToObject, worldPos).xyz) ? 0 : -1 );
572
546
}
573
547
548
+ bool geometry_check (float3 v1, float3 v2, float3 v3) {
549
+ float3 thispos = 0 ;
550
+ float2 thisuv = 0 ;
551
+ bool found = true ;
552
+ BOXCLIP_FOR_EACH_QUAD (ShowVolume, {
553
+ found = false ;
554
+ });
555
+ BOXCLIP_FOR_EACH_QUAD (ShowCameraWithin, {
556
+ found = false ;
557
+ });
558
+ BOXCLIP_FOR_EACH_QUAD (ClipShow, {
559
+ found = false ;
560
+ });
561
+ BOXCLIP_FOR_EACH_QUAD (ShowCameraWithin, {
562
+ if (internalBoxPointWithinVolume (boxObjectSpaceCameraPosStereo, q)) {
563
+ found = true ;
564
+ }
565
+ });
566
+ BOXCLIP_FOR_EACH_QUAD (HideCameraWithin, {
567
+ if (internalBoxPointWithinVolume (boxObjectSpaceCameraPosStereo, q)) {
568
+ found = false ;
569
+ }
570
+ });
571
+ BOXCLIP_FOR_EACH_QUAD (ShowVolume, {
572
+ if (internalBoxPointWithinVolume (v1.xyz, q) || internalBoxPointWithinVolume (v2.xyz, q) || internalBoxPointWithinVolume (v3.xyz, q)) {
573
+ found = true ;
574
+ }
575
+ });
576
+ BOXCLIP_FOR_EACH_QUAD (HideVolume, {
577
+ if (internalBoxPointWithinVolume (v1.xyz, q) && internalBoxPointWithinVolume (v2.xyz, q) && internalBoxPointWithinVolume (v3.xyz, q)) {
578
+ found = false ;
579
+ }
580
+ });
581
+ BOXCLIP_FOR_EACH_QUAD (ClipShow, {
582
+ if (internalBoxTriangleIntersectsQuad (v1.xyz, v2.xyz, v3.xyz, q)) {
583
+ found = true ;
584
+ }
585
+ });
586
+ BOXCLIP_FOR_EACH_QUAD (ClipHide, {
587
+ if (internalBoxPointInQuad (v1.xyz, q, thispos, thisuv) &&
588
+ internalBoxPointInQuad (v2.xyz, q, thispos, thisuv) &&
589
+ internalBoxPointInQuad (v3.xyz, q, thispos, thisuv)) {
590
+ found = true ;
591
+ }
592
+ });
593
+ return found;
594
+ }
595
+
574
596
bool modified_vert_check (float3 localPos, float length) {
575
597
bool found = true ;
576
598
BOXCLIP_FOR_EACH_QUAD (ShowVolume, {
@@ -593,17 +615,13 @@ bool modified_vert_check(float3 localPos, float length) {
593
615
}
594
616
});
595
617
BOXCLIP_FOR_EACH_QUAD (ShowVolume, {
596
- if (q.planeNormalZComp.w < 0 ) {
597
- if (internalBoxPointWithinVolume (localPos, q)) {
598
- found = true ;
599
- }
618
+ if (internalBoxPointWithinVolume (localPos, q)) {
619
+ found = true ;
600
620
}
601
621
});
602
622
BOXCLIP_FOR_EACH_QUAD (HideVolume, {
603
- if (q.planeNormalZComp.w < 0 ) {
604
- if (internalBoxPointWithinVolume (localPos, q)) {
605
- found = false ;
606
- }
623
+ if (internalBoxPointWithinVolume (localPos, q)) {
624
+ found = false ;
607
625
}
608
626
});
609
627
BOXCLIP_FOR_EACH_QUAD (ClipShow, {
@@ -641,16 +659,19 @@ bool modified_vert_check(float3 localPos, float length) {
641
659
float lengthVert0 = max (distance (localPos[0 ], localPos[1 ]),distance (localPos[0 ], localPos[2 ])); \
642
660
float lengthVert1 = max (distance (localPos[0 ], localPos[1 ]),distance (localPos[1 ], localPos[2 ])); \
643
661
float lengthVert2 = max (distance (localPos[0 ], localPos[2 ]),distance (localPos[1 ], localPos[2 ])); \
644
- /* if (geometry_check(localPos[0], localPos[1], localPos[2])) { */ \
645
- if ((modified_vert_check (localPos[0 ], lengthVert0) && \
646
- modified_vert_check (localPos[1 ], lengthVert1) && \
647
- modified_vert_check (localPos[2 ], lengthVert2))) { \
662
+ if (geometry_check (localPos[0 ], localPos[1 ], localPos[2 ])) { \
648
663
tristream.Append (IN[0 ]); \
649
664
tristream.Append (IN[1 ]); \
650
665
tristream.Append (IN[2 ]); \
651
666
} \
652
667
}
653
668
669
+ /*
670
+ if ((modified_vert_check(localPos[0], lengthVert0) && \
671
+ modified_vert_check(localPos[1], lengthVert1) && \
672
+ modified_vert_check(localPos[2], lengthVert2))) {
673
+ */
674
+
654
675
#define BOXCLIP_GEOM_SHADER_WORLDPOS (V2FStruct, worldPosVar) \
655
676
BOXCLIP_GEOM_SHADER_LOCALPOS (V2FStruct, mul (unity_WorldToObject, float4 ((worldPosVar).xyz, 1 )).xyz)
656
677
0 commit comments