Advertisement
DEKTEN

SDF_014

Nov 30th, 2020 (edited)
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /** ************************************************ ***
  2. ***                                                  ***
  3. ***     Live Stream Of Me Working On This Code:      ***
  4. ***                                                  ***
  5. *** ************************************************ ***
  6.  
  7.                 twitch.com/kanjicoder    
  8.  
  9. *** ************************************************ ***
  10. ***                                                  ***
  11. *** EASY___SOURCE:  tinyurl.com/SDF-014              ***
  12. *** DIRECT_SOURCE:  pastebin.com/7xEKkhTB            ***
  13. ***                                                  ***
  14. *** EASY_____DEMO:  tinyurl.com/SDF-014-DEMO         ***
  15. *** DIRECT___DEMO:  shadertoy.com/view/wsGBRw        ***
  16. ***                                                  ***
  17. *** About: Voxel Rendering For Patent Drawings.      ***
  18. ***        This version is a work in progress.       ***
  19. ***                                                  ***
  20. ***        Voxel edge debugging continued.           ***
  21. ***                                                  ***
  22. *** ************************************************ **/
  23. //:MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM://
  24. /** M: Macros Section **/
  25.  
  26.     #define V_4  vec4
  27.     #define V_3  vec3
  28.     #define V_2  vec2
  29.     #define F32 float
  30.     #define I32   int
  31.     #define U32  uint
  32.  
  33. /** M: Macros Section **/
  34. //:MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM://
  35. //:DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD://
  36. /** D: Data Section **/
  37.  
  38.     //:DEBUGGING:====================================://
  39.  
  40.         V_4 THE_COLOR_OF_EMPTY_SPACE=V_4(
  41.             0.0 , 0.0 , 0.0 , 1.0
  42.         /** RED   GRE   BLU   ALP **/
  43.         );
  44.  
  45.     //:====================================:DEBUGGING://
  46.     //:CONFIGURATION:================================://
  47.  
  48.         //:CAMERA_SETTINGS:==========================://
  49.         /** **************************************** ***
  50.         PREFIX:
  51.  
  52.             OGP: OrthoGraphicProjection
  53.             P3D: Perspective_3D
  54.             T3O: TUBE360_OUT (TubeCam Looking OUTWARD)
  55.             T3I: TUBE360_INN (TubeCam Looking INWARD )
  56.  
  57.         POSTFIX: (SUFFIX ):
  58.             TOP: Top View
  59.             34D: 3/4 Tilted DOWN view.
  60.             AAZ: Around_Axis_Z (NOT:WAZ)
  61.  
  62.         NOTES:
  63.  
  64.             T3O    : commonly known as PANORAMIC 360  
  65.             TubeCam: Revolve Around Axis As Camera.
  66.                      Literally "Tube Camera"
  67.  
  68.         *** **************************************** **/
  69.  
  70.             #define OGP_TOP ( 1 ) /** Good For Debug **/
  71.             #define OGP_34D ( 2 ) /** PATENT_DRAWING **/
  72.             #define T3O_AAZ ( 3 ) /** Outward: Z-Axis**/
  73.             #define T3I_AAZ ( 4 ) /** Inward : Z-Axis**/
  74.  
  75.             /** Selected Camera Type **/
  76.             #define CAMTYPE ( OGP_34D )
  77.         //  #define CAMTYPE ( OGP_TOP )
  78.         //  #define CAMTYPE ( T3I_AAZ )
  79.  
  80.         //:==========================:CAMERA_SETTINGS://
  81.  
  82.         /** SLICE_RENDER_USING_CAMERA_PLANE **/
  83.         int CFG_SLICE_RENDER=( 0 );
  84.  
  85.     //:================================:CONFIGURATION://
  86.     //:RAYMARCHING_AND_VOXEL_CONSTANTS:==============://
  87.  
  88.         //:These defines are for ray marching when using
  89.         //:fragment coordinates as our coordinate space.
  90.         #define MAX_STE 1000   //:Max Step
  91.         #define MIN_DIS 0.02   //:Min Dist (SurfaceDist)
  92.         #define MAX_DIS (64.0*16.0 * 1.0) //:Max Dist
  93.  
  94.         //:Number of tiles on each axis:
  95.         #define TILEMAP_PRESET ( 333 )
  96.         #if( 847 == TILEMAP_PRESET ) /** 8 x 4 x 7 **/
  97.  
  98.             #define NTX  8  //: Number Of [tiles/voxels]
  99.             #define NTY  4  //: Number Of [tiles/voxels]
  100.             #define NTZ  7  //: Number Of [tiles/voxels]
  101.  
  102.         #endif
  103.         #if( 111 == TILEMAP_PRESET )
  104.  
  105.             #define NTX  1  //: Number Of [tiles/voxels]
  106.             #define NTY  1  //: Number Of [tiles/voxels]
  107.             #define NTZ  1  //: Number Of [tiles/voxels]
  108.  
  109.         #endif
  110.         #if( 222 == TILEMAP_PRESET )
  111.  
  112.             #define NTX  2  //: Number Of [tiles/voxels]
  113.             #define NTY  2  //: Number Of [tiles/voxels]
  114.             #define NTZ  2  //: Number Of [tiles/voxels]
  115.  
  116.         #endif
  117.         #if( 333 == TILEMAP_PRESET )
  118.  
  119.             #define NTX  3  //: Number Of [tiles/voxels]
  120.             #define NTY  3  //: Number Of [tiles/voxels]
  121.             #define NTZ  3  //: Number Of [tiles/voxels]
  122.  
  123.         #endif
  124.  
  125.         #define VOXEL_SIZE_PRESET ( 555 )
  126.         #if( 555 == VOXEL_SIZE_PRESET )
  127.  
  128.             //:Size_Of_A_Voxel_Tile_Measured_In_Pixels:
  129.             #define NPX  5 //: NPX : Num_Pixels_X
  130.             #define NPY  5 //: NPY : Num_Pixels_Y
  131.             #define NPZ  5 //: NPZ : Num_Pixels_Z
  132.  
  133.         #endif
  134.         #if( 567 == VOXEL_SIZE_PRESET )
  135.  
  136.             //:Size_Of_A_Voxel_Tile_Measured_In_Pixels:
  137.             #define NPX  5 //: NPX : Num_Pixels_X
  138.             #define NPY  6 //: NPY : Num_Pixels_Y
  139.             #define NPZ  7 //: NPZ : Num_Pixels_Z
  140.  
  141.         #endif
  142.         #if( 579 == VOXEL_SIZE_PRESET )
  143.  
  144.             //:Size_Of_A_Voxel_Tile_Measured_In_Pixels:
  145.             #define NPX  5 //: NPX : Num_Pixels_X
  146.             #define NPY  7 //: NPY : Num_Pixels_Y
  147.             #define NPZ  9 //: NPZ : Num_Pixels_Z
  148.  
  149.         #endif
  150.         #if( 51015 == VOXEL_SIZE_PRESET )
  151.  
  152.             //:Size_Of_A_Voxel_Tile_Measured_In_Pixels:
  153.             #define NPX   5 //: NPX : Num_Pixels_X
  154.             #define NPY  10 //: NPY : Num_Pixels_Y
  155.             #define NPZ  15 //: NPZ : Num_Pixels_Z
  156.  
  157.         #endif
  158.  
  159.         //:Total__number_of__Pixels__in_entire_voxel_map
  160.         #define TPX  ( NTX * NPX ) //: Total_Pixels_X
  161.         #define TPY  ( NTY * NPY ) //: Total_Pixels_Y
  162.         #define TPZ  ( NTZ * NPZ ) //: Total_Pixels_Z
  163.  
  164.     //: - ://
  165.         #define _  U32( 0 )                                        
  166.         #define X  U32( 1 )  
  167.         #define R  U32( 0xFF0000ff ) //: PRIMARY
  168.         #define r  U32( 0x880000ff ) //: PRIMARY
  169.         #define G  U32( 0x00FF00ff ) //: PRIMARY
  170.         #define g  U32( 0x008800ff ) //: PRIMARY
  171.         #define B  U32( 0x0000FFff ) //: PRIMARY
  172.         #define b  U32( 0x000088ff ) //: PRIMARY
  173.     //: - ://              
  174.         #define C  U32( 0x00FFFFff ) //: SECONDARY
  175.         #define c  U32( 0x008888ff ) //: SECONDARY
  176.         #define M  U32( 0xFF00FFff ) //: SECONDARY
  177.         #define m  U32( 0x880088ff ) //: SECONDARY
  178.         #define Y  U32( 0xFFFF00ff ) //: SECONDARY
  179.         #define y  U32( 0x888800ff ) //: SECONDARY
  180.     //: - ://      
  181.         #define L  U32( 0x88FF00ff ) //: TERTIARY
  182.         #define l  U32( 0x448800ff ) //: TERTIARY
  183.         #define O  U32( 0xFF8800ff ) //: TERTIARY
  184.         #define o  U32( 0x884400ff ) //: TERTIARY
  185.     //: - ://    
  186.         #define K  U32( 0x212121ff ) //: BLACK | GRAY
  187.         #define k  U32( 0x323232ff ) //: BLACK | GRAY
  188.     //: - ://
  189.  
  190.         #if( 1 == NTX && 1 == NTY && 1 == NTZ )
  191.  
  192.             U32  
  193.             VAT[ NTX * NTY * NTZ ]= U32[ 1 * 1 * 1 ](  
  194.  
  195.                 C /** <<<< JUST ONE TILE(VOXEL) **/
  196.  
  197.             );
  198.  
  199.         #endif
  200.         #if( 2 == NTX && 2 == NTY && 2 == NTZ )
  201.  
  202.             U32  
  203.             VAT[ NTX * NTY * NTZ ]= U32[ 2 * 2 * 2 ](  
  204.  
  205.                 C,M,
  206.                 Y,_,
  207.  
  208.                 c,m,
  209.                 y,_ //:<---NO_COMMA_LAST
  210.  
  211.             );
  212.  
  213.         #endif
  214.         #if( 3 == NTX && 3 == NTY && 3 == NTZ )/**333**/
  215.  
  216.             U32  
  217.             VAT[ NTX * NTY * NTZ ]= U32[ 3 * 3 * 3 ](  
  218.  
  219.                 /** Something about the bounding   **/
  220.                 /** calculations is definitely off **/
  221.  
  222.                 _,_,R,  //: <<< PROBLEM HERE
  223.                 _,_,_,  
  224.                 _,_,G,  //: <<< LOOKS GOOD
  225.                          
  226.                 _,_,_,  
  227.                 _,_,_,  
  228.                 _,_,_,  
  229.                          
  230.                 _,_,_,  
  231.                 _,_,_,  
  232.                 _,_,_    
  233.  
  234.             );
  235.  
  236.         #endif
  237.         #if( 8 == NTX && 4 == NTY && 7 == NTZ )
  238.  
  239.             U32  
  240.             VAT[ NTX * NTY * NTZ ]= U32[ 8 * 4 * 7 ](  
  241.  
  242.             /** TODO: Eventually use an integer      **/
  243.             /**       texture for this tilemap data. **/
  244.                
  245.             /** #STRATA_OF_2D_TILEMAPS#        * * * **/
  246.             /** #BACK_SLASH_COMMENT_FUCKERY#   * * * **/
  247.            
  248.             //: 1 2 3 4 5 6 7 8  
  249.                 _,_,_,_,_,_,_,_, //: 1 ---+
  250.                 _,_,_,_,_,_,_,_, //: 2    |__ Z == 0
  251.                 _,_,_,_,_,_,_,_, //: 3    |
  252.                 _,_,_,_,_,_,_,_, //: 4 ---+    
  253.             //: 1 2 3 4 5 6 7 8        
  254.                 _,_,_,_,_,_,_,_, //: 1 ---+
  255.                 _,_,_,_,_,_,_,_, //: 2    |__ Z == 1
  256.                 _,_,_,_,_,_,_,_, //: 3    |
  257.                 _,_,_,_,_,_,_,_, //: 4 ---+          
  258.             //: 1 2 3 4 5 6 7 8        
  259.                 _,_,_,_,_,R,_,_, //: 1 ---+
  260.                 _,_,_,_,Y,_,_,_, //: 2    |__ Z == 2
  261.                 _,_,_,M,_,_,_,_, //: 3    |
  262.                 _,_,C,_,_,_,_,_, //: 4 ---+    
  263.             //: 1 2 3 4 5 6 7 8      
  264.                 _,_,_,_,_,_,_,_, //: 1 ---+
  265.                 _,_,_,_,_,_,_,_, //: 2    |__ Z == 3
  266.                 _,_,_,_,_,_,_,_, //: 3    |
  267.                 _,_,_,_,_,_,_,_, //: 4 ---+    
  268.             //: 1 2 3 4 5 6 7 8
  269.                 _,_,_,_,_,_,_,_, //: 1 ---+
  270.                 _,_,_,_,_,_,_,_, //: 2    |__ Z == 4
  271.                 _,_,_,_,_,_,_,_, //: 3    |
  272.                 _,_,_,_,_,_,_,_, //: 4 ---+    
  273.             //: 1 2 3 4 5 6 7 8
  274.                 _,_,_,_,_,_,_,_, //: 1 ---+
  275.                 _,_,_,_,_,_,_,_, //: 2    |__ Z == 5
  276.                 _,_,_,_,_,_,_,_, //: 3    |
  277.                 _,_,_,_,_,_,_,_, //: 4 ---+    
  278.             //: 1 2 3 4 5 6 7 8
  279.                 _,_,_,_,_,_,_,_,
  280.                 _,_,_,_,_,_,_,_,
  281.                 _,_,_,_,_,_,_,_,
  282.                 _,_,_,_,_,_,_,_ //:<<< NO_COMMA_ON_LAST
  283.  
  284.             );  
  285.  
  286.  
  287.         #endif /** [ 8 x 4 x 7 ] **/
  288.                                              
  289.     //: - ://      
  290.         #undef  _              
  291.         #undef  X  
  292.         #undef  R  
  293.         #undef  r  
  294.         #undef  G  
  295.         #undef  g  
  296.         #undef  B  
  297.         #undef  b  
  298.     //: -undef      
  299.         #undef  C  
  300.         #undef  c  
  301.         #undef  M  
  302.         #undef  m  
  303.         #undef  Y  
  304.         #undef  y  
  305.     //: -undef      
  306.         #undef  L  
  307.         #undef  l  
  308.         #undef  O  
  309.         #undef  o  
  310.     //: -undef      
  311.         #undef  K  
  312.         #undef  k  
  313.     //: - ://
  314.  
  315.     //:==============:RAYMARCHING_AND_VOXEL_CONSTANTS://
  316.     //:STRUCTS:======================================://
  317.  
  318.         //:RWC_AND_RWN:------------------------------://
  319.  
  320.             struct  RWC_AND_RWN{
  321.                 V_3 rwC        ;
  322.                 V_3         rwN;
  323.             };
  324.        
  325.         //:------------------------------:RWC_AND_RWN://
  326.         //:VOX_000:----------------------------------://
  327.  
  328.             /** VOC: VOxel_Current(information) **/
  329.             struct VOC{  
  330.                 U32 has    ;  //  voxel:exists?    : 1 :  
  331.                 U32 val    ;  //  voxel:tile_value : 2 :  
  332.                               //                   :---:  
  333.                 I32 til_d3d;  //  voxel:1d_index   : 3 :  
  334.                 I32 t_x    ;  //  voxel:tile_x     : 4 :  
  335.                 I32 t_y    ;  //  voxel:tile_y     : 5 :  
  336.                 I32 t_z    ;  //  voxel:tile_z     : 6 :  
  337.                               //
  338.                 I32 pix_d3d;  //  voxel:pixel_d    : 7 :
  339.                 I32     p_x;  //  voxel:pixel_x    : 8 :
  340.                 I32     p_y;  //  voxel:pixel_y    : 9 :
  341.                 I32     p_z;  //  voxel:pixel_z    :10 :
  342.             };                                
  343.  
  344.             /** VOD: VOxel_Distance(information) **/
  345.             struct VOD{  
  346.                 F32     dis_nex; //:Distance_To_Next
  347.                 F32     dis_sur; //:Distance_To_Surface
  348.                                  //:Within_Current_Voxel
  349.             };
  350.  
  351.             struct VOE{
  352.                 F32  msg_err;
  353.             };
  354.  
  355.             struct VOX_000{ /** var: vox_000 **/
  356.                        
  357.                 VOC     voc; //:Voxel_Current_Info
  358.                 VOD     vod; //:Voxel_Distance_Info
  359.                 VOE     voe; //:Voxel_Error____Info
  360.            
  361.             };
  362.  
  363.         //:----------------------------------:VOX_000://
  364.         //:VOX_MAR:----------------------------------://
  365.        
  366.             struct VOX_MAR{ //:SEE[ #VOX_MAR_ABOUT# ]
  367.  
  368.                 uint exit;
  369.  
  370.             };
  371.  
  372.         //:----------------------------------:VOX_MAR://
  373.  
  374.     //:======================================:STRUCTS://
  375.  
  376. /** D: Data Section **/
  377. //:DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD://
  378. //:IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII://
  379. /** I: Inifnite Degree Functions. Always At Top.     **/
  380.  
  381.     //:NO_HALT_USE_ERROR_PIXEL:======================://
  382.     //:PIX_ERR:======================================://
  383.  
  384.         #define ERR_001  1  /** msg_err #1 (0x101010)**/
  385.                             /** msg_err #1 (0x010101)**/
  386.  
  387.         #define ERR_002  2  /** msg_err #2 (0x202020)**/
  388.                             /** msg_err #2 (0x020202)**/
  389.  
  390.         #define ERR_003  3  /** msg_err #3 (0x303030)**/
  391.                             /** msg_err #3 (0x030303)**/
  392.  
  393.         V_4     PIX_ERR(
  394.             int msg_err /** EX: MSG_ERR_001 **/
  395.         ,   V_4 pix_err /** Previous Pixel Error **/
  396.         ,   int   o_k
  397.         )
  398.         {
  399.             /** Muddy Pastel Yellow For When You     **/
  400.             /** forget to set the pix_err_out value. **/
  401.             V_4 pix_err_out=V_4(0.5,0.5,0.2,1);
  402.  
  403.             float flux=( mod(iTime,1.0) );
  404.  
  405.             //:COLOR_PICKER_DEBUG_HEX:---------------://
  406.        
  407.             /** Make it easy to find source of error **/
  408.             /** in code by using color picker on     **/
  409.             /** shader output and then doing a       **/
  410.             /** CTRL+F with that hex code to find    **/
  411.             /** the offending source code.           **/
  412.  
  413.                 F32 _ =F32( 0.0    );
  414.                 F32 MAX =F32( 255.0  ); // MaxIntensity
  415.                 F32  A  =F32( 1.0    ); // Alpha_Max
  416.  
  417.                 //:ERROR_CODE_STROBE_COLORS:---------://
  418.  
  419.                 F32 _01_ =( F32(0x01) / MAX );
  420.                 F32 _10_ =( F32(0x10) / MAX );
  421.                 //
  422.                 F32 _02_ =( F32(0x02) / MAX );
  423.                 F32 _20_ =( F32(0x20) / MAX );
  424.                 //
  425.                 F32 _03_ =( F32(0x03) / MAX );
  426.                 F32 _30_ =( F32(0x30) / MAX );
  427.                 //
  428.                 F32 _04_ =( F32(0x04) / MAX );
  429.                 F32 _40_ =( F32(0x40) / MAX );
  430.                 //
  431.                 F32 _05_ =( F32(0x05) / MAX );
  432.                 F32 _50_ =( F32(0x50) / MAX );
  433.                 //
  434.                 F32 _06_ =( F32(0x06) / MAX );
  435.                 F32 _60_ =( F32(0x60) / MAX );
  436.                 //
  437.                 F32 _07_ =( F32(0x07) / MAX );
  438.                 F32 _70_ =( F32(0x70) / MAX );
  439.                 //
  440.                 F32 _08_ =( F32(0x08) / MAX );
  441.                 F32 _80_ =( F32(0x80) / MAX );
  442.                 //
  443.                 F32 _09_ =( F32(0x09) / MAX );
  444.                 F32 _90_ =( F32(0x90) / MAX );
  445.  
  446.                 V_4 _0x010101_ = V_4(_01_,_01_,_01_, A);
  447.                 V_4 _0x101010_ = V_4(_10_,_10_,_10_, A);
  448.  
  449.                 V_4 _0x020202_ = V_4(_02_,_02_,_02_, A);
  450.                 V_4 _0x202020_ = V_4(_20_,_20_,_20_, A);
  451.  
  452.                 V_4 _0x030303_ = V_4(_03_,_03_,_03_, A);
  453.                 V_4 _0x303030_ = V_4(_30_,_30_,_30_, A);
  454.  
  455.                 V_4 _0x040404_ = V_4(_04_,_04_,_04_, A);
  456.                 V_4 _0x404040_ = V_4(_40_,_40_,_40_, A);
  457.  
  458.                 V_4 _0x050505_ = V_4(_05_,_05_,_05_, A);
  459.                 V_4 _0x505050_ = V_4(_50_,_50_,_50_, A);
  460.  
  461.                 V_4 _0x060606_ = V_4(_06_,_06_,_06_, A);
  462.                 V_4 _0x606060_ = V_4(_60_,_60_,_60_, A);
  463.  
  464.                 V_4 _0x070707_ = V_4(_07_,_07_,_07_, A);
  465.                 V_4 _0x707070_ = V_4(_70_,_70_,_70_, A);
  466.  
  467.                 V_4 _0x080808_ = V_4(_08_,_08_,_08_, A);
  468.                 V_4 _0x808080_ = V_4(_80_,_80_,_80_, A);
  469.  
  470.                 V_4 _0x090909_ = V_4(_09_,_09_,_09_, A);
  471.                 V_4 _0x909090_ = V_4(_90_,_90_,_90_, A);
  472.  
  473.                 //:---------:ERROR_CODE_STROBE_COLORS://
  474.                 //:ERROR_ZERO_COLORS:----------------://
  475.                 #define F float
  476.                 #define V vec4
  477.                 /** If you forget to set error code, **/
  478.                 /** you will see flashing red and    **/
  479.                 /** blue. ( _0xFF0666_ & _0x6660FF_ )**/
  480.                  
  481.                 F   _FF_=( F32(0xFF) / MAX );
  482.                 //  _06_=( F32(0x06) / MAX );
  483.                 //  _60_=( F32(0x60) / MAX );
  484.                 F   _66_=( F32(0x66) / MAX );
  485.                 V   _0xFF0666_ =V_4(_FF_,_06_,_66_,A);
  486.                 V   _0x6660FF_ =V_4(_66_,_60_,_FF_,A);
  487.  
  488.                 #undef F
  489.                 #undef V
  490.                 //:----------------:ERROR_ZERO_COLORS://
  491.                 //:BAD_OK_ERROR_COLOR:---------------://
  492.                 #define F float
  493.                 #define V vec4
  494.                 /** You will see this if you init    **/
  495.                 /** o_k to a value other than 1 in   **/
  496.                 /** your source code.                **/
  497.                 /** Strobes between orange and lime. **/
  498.                 /** ( _0xFF7700_ & _0x77FF00_ )      **/
  499.                  
  500.                 //  _FF_=( F32(0xFF) / MAX );
  501.                 F   _77_=( F32(0x77) / MAX );
  502.                 F   _00_=( F32(0x00) / MAX );
  503.                 V   _0xFF7700_ =V_4(_FF_,_77_,_00_,A);
  504.                 V   _0x77FF00_ =V_4(_77_,_FF_,_00_,A);
  505.  
  506.                 #undef F
  507.                 #undef V
  508.                 //:---------------:BAD_OK_ERROR_COLOR://
  509.  
  510.             //:---------------:COLOR_PICKER_DEBUG_HEX://
  511.  
  512.             if( o_k <= 0 ){
  513.                 pix_err_out = pix_err;
  514.             }else
  515.             if( 1 == o_k ){
  516.  
  517.                 /** table of error "messages" #0 **/
  518.                 V_4 tab_err_000[10]=V_4[10](        
  519.                                                
  520.                     // 0: Invalid Error Code    
  521.                     _0xFF0666_  // RED_FLASH
  522.                          
  523.                     // Odd Frame Error Colors:
  524.                 ,   _0x010101_  //  ERR_001 : ODD_FRAME
  525.                 ,   _0x020202_  //  ERR_002 : ODD_FRAME
  526.                 ,   _0x030303_  //  ERR_003 : ODD_FRAME
  527.                 ,   _0x040404_  //  ERR_004 : ODD_FRAME
  528.                 ,   _0x050505_  //  ERR_005 : ODD_FRAME
  529.                 ,   _0x060606_  //  ERR_006 : ODD_FRAME
  530.                 ,   _0x070707_  //  ERR_007 : ODD_FRAME
  531.                 ,   _0x080808_  //  ERR_008 : ODD_FRAME
  532.                 ,   _0x090909_  //  ERR_009 : ODD_FRAME
  533.                 );;        
  534.                 /** table of error "messages" #1 **/
  535.                 V_4 tab_err_001[10]=V_4[10](        
  536.                                                
  537.                     // 0: Invalid Error Code    
  538.                     _0x6660FF_ // BLUE_FLASH    
  539.                          
  540.                     // Even Frame Error Colors:
  541.                 ,   _0x101010_  //  ERR_001 : EVE_FRAME
  542.                 ,   _0x202020_  //  ERR_002 : EVE_FRAME
  543.                 ,   _0x303030_  //  ERR_003 : EVE_FRAME
  544.                 ,   _0x404040_  //  ERR_004 : EVE_FRAME
  545.                 ,   _0x505050_  //  ERR_005 : EVE_FRAME
  546.                 ,   _0x606060_  //  ERR_006 : EVE_FRAME
  547.                 ,   _0x707070_  //  ERR_007 : EVE_FRAME
  548.                 ,   _0x808080_  //  ERR_008 : EVE_FRAME
  549.                 ,   _0x909090_  //  ERR_009 : EVE_FRAME
  550.                 );;                      
  551.  
  552.                 if( mod(iTime*16.0,2.0) < 1.0 ){
  553.                     pix_err_out =( tab_err_000
  554.                                  [ msg_err ] );;
  555.                 }else{
  556.                     pix_err_out =( tab_err_001
  557.                                  [ msg_err ] );;
  558.                 };;
  559.  
  560.             }else{
  561.                 /** Orange strobe for an o_k value   **/
  562.                 /** that is NOT expected. (o_k >= 2) **/
  563.  
  564.                 if( mod(iTime*2.0,2.0) < 1.0 ){
  565.                     pix_err_out = _0xFF7700_; // ORANGE
  566.                 }else{
  567.                     pix_err_out = _0x77FF00_; // LIME
  568.                 };;
  569.  
  570.             };;
  571.                
  572.             return( pix_err_out );
  573.         }
  574.  
  575.     //:======================================:PIX_ERR://
  576.     //:======================:NO_HALT_USE_ERROR_PIXEL://
  577.     //:MAX_OF_3:=====================================://
  578.  
  579.         F32
  580.         max_003( F32 a , F32 b , F32 c )
  581.         {
  582.             return( max( max(a,b) , c ) );
  583.         }
  584.  
  585.     //:=====================================:MAX_OF_3://
  586.  
  587. /** I: Inifnite Degree Functions. Always At Top.     **/
  588. //:IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII://
  589. //:22222222222222222222222222222222222222222222222222://
  590.  
  591.     //:INTERPOLATION_3D:=============================://
  592.     //:sfd_i3d:======================================://
  593.  
  594.         V_3 sdf_i3d(
  595.         /**/V_3 _1_
  596.         ,   V_3 _2_
  597.         ,   F32 f_p
  598.         ){
  599.             return( _1_ + ( ( _2_ - _1_ )*f_p ) );
  600.         }
  601.  
  602.     //:=============================:INTERPOLATION_3D://
  603.     //:======================================:sfd_i3d://
  604.     //:FIRST_VOXEL_QUERY_NEEDED:=====================://
  605.     //:@WHATVOX@
  606.     // ############################# //
  607.     #define T_X ( vox_000.voc.t_x     )
  608.     #define T_Y ( vox_000.voc.t_y     )
  609.     #define T_Z ( vox_000.voc.t_z     )
  610.     // ############################# //
  611.     #define P_X ( vox_000.voc.p_x     )
  612.     #define P_Y ( vox_000.voc.p_y     )
  613.     #define P_Z ( vox_000.voc.p_z     )
  614.     #define P_I ( vox_000.voc.pix_d3d )
  615.     // ############################# //
  616.  
  617.         /** rwN used to find distance to NEXT voxel. **/
  618.             VOX_000
  619.         GET_vox_000_USE_xyz_rwN(
  620.                         V_3 xyz
  621.                     ,   V_3     rwN
  622.         )
  623.         {
  624.             VOX_000 vox_000;
  625.  
  626.             /** f: floor(xyz) values: **/
  627.             F32 f_x = floor( xyz.x );
  628.             F32 f_y = floor( xyz.y );
  629.             F32 f_z = floor( xyz.z );
  630.  
  631.             //:CURRENT_VOXEL_CELL:-------------------://
  632.  
  633.             vox_000.voc.val = U32( 0 );
  634.             T_X = ( int(floor( xyz.x / float( NPX ))));
  635.             T_Y = ( int(floor( xyz.y / float( NPY ))));
  636.             T_Z = ( int(floor( xyz.z / float( NPZ ))));
  637.  
  638.             //:-------------------:CURRENT_VOXEL_CELL://
  639.             //:GET_VOXEL_CELL_VALUE:-----------------://
  640.  
  641.             /** Voxel Volume Is Hard Coded To have   **/
  642.             /** voxel__tile[0,0,0] stuck at world    **/
  643.             /** world_coord[0,0,0]                   **/
  644.             if( T_X >= 0 && T_X < NTX
  645.             &&  T_Y >= 0 && T_Y < NTY
  646.             &&  T_Z >= 0 && T_Z < NTZ
  647.             ){
  648.  
  649.                 //: Index2D -and- Index3D
  650.                 int D2D = T_X + ( NTX    *    T_Y );
  651.                 int D3D = D2D + ( NTX * NTY * T_Z );
  652.  
  653.                 vox_000.voc.til_d3d=(      D3D   );
  654.                 vox_000.voc.val    =( VAT[ D3D ] );
  655.  
  656.                 /** NOTE: Voxel value 0 will NOT get **/
  657.                 /**       special treatment. It could**/
  658.                 /**       contain geometry if we     **/
  659.                 /**       really wanted it to.       **/
  660.                 vox_000.voc.has= U32(  1  );
  661.                
  662.             }else{
  663.                 /** Using a "has" flag so we         **/
  664.                 /** can keep more logic UNSIGNED.    **/
  665.                 /** (No need for negative value to ) **/
  666.                 /** (be used for invalid dex or val) **/
  667.                 vox_000.voc.til_d3d= int(  0  );
  668.                 vox_000.voc.val    = U32(  0  );
  669.                 vox_000.voc.has    = U32(  0  );
  670.             };;
  671.             //:-----------------:GET_VOXEL_CELL_VALUE://
  672.             //:DIST_TO_NEXT_VOXEL:-------------------://    
  673.             /** ************************************ ***
  674.                                 x_bound
  675.                                 |||
  676.                                 |||
  677.                                 |||
  678.             ====+-----+---[i]----+====== y_bound ====
  679.                 |     |   /      ||
  680.                 |     |  /       ||
  681.                 |     | /        ||
  682.                 |     |/         ||
  683.                 +- - -P----------+|
  684.                 |     .          ||
  685.                 |     .          ||
  686.                 +-----+----------+|
  687.                                 |||
  688.                                 |||
  689.                                 |||
  690.                                 |||
  691.             *** ************************************ **/
  692.             #define P xyz /** Point  **/
  693.             #define N rwN /** Normal **/
  694.  
  695.                 //:SIGNS_OF_RAY_VECTOR:--------------://
  696.                 /** We need to know if the ray is    **/
  697.                 /** moving forwards to HIGHER tile   **/
  698.                 /** values or BACKWARDS to LOWER     **/
  699.                 /** tile values.                     **/
  700.  
  701.                 /**  SEE[ #CONSISTENT_VOXEL_COORDS# **/
  702.                 F32  b_x  /** x_bound       **/     ;  
  703.                 F32  b_y  /** y_bound       **/     ;  
  704.                 F32  b_z  /** z_bound       **/     ;  
  705.                           /**               **/     ;
  706.                 F32  x_0  /** x_bound : MIN **/     ;  
  707.                 F32  y_0  /** y_bound : MIN **/     ;  
  708.                 F32  z_0  /** z_bound : MIN **/     ;  
  709.                           /**               **/     ;
  710.                 F32  x_1  /** x_bound : MAX **/     ;  
  711.                 F32  y_1  /** y_bound : MAX **/     ;  
  712.                 F32  z_1  /** z_bound : MAX **/     ;  
  713.                                                     ;
  714.                 x_1 =F32( ( T_X +  1 ) * NPX )      ;
  715.                 y_1 =F32( ( T_Y +  1 ) * NPY )      ;
  716.                 z_1 =F32( ( T_Z +  1 ) * NPZ )      ;
  717.                                                     ;
  718.                 x_0 =F32( ( T_X -  0 ) * NPX )- 0.0001 ; //:<---WTF ?
  719.                 y_0 =F32( ( T_Y -  0 ) * NPY )- 0.0001 ; //:<---WTF ?
  720.                 z_0 =F32( ( T_Z -  0 ) * NPZ )- 0.0001 ; //:<---WTF ?
  721.                                                     ;
  722.                 b_x = N.x >= 0.0 ? x_1 : x_0        ;
  723.                 b_y = N.y >= 0.0 ? y_1 : y_0        ;
  724.                 b_z = N.z >= 0.0 ? z_1 : z_0        ;
  725.  
  726.                 //:--------------:SIGNS_OF_RAY_VECTOR://
  727.                 /** ******************************** ***
  728.                 SEE[ #NEXT_VOXEL_BOUNDING_VOLUME# ]    
  729.                 The intersection point to next voxel    
  730.                 (By using plane intersections) should  
  731.                 not be further than ONE PIXEL away      
  732.                 from the current voxel we are inside.  
  733.            
  734.                 +----------------+----------------+
  735.                 | +- - -  - - -+ | +- - -  - - -+ |
  736.                 | |            | | |            | |
  737.                 |                |                |
  738.                 | |            | | |            | |
  739.                 |                |                |
  740.                 | |            | | |            | |
  741.                 | +- - -  - - -+ | +- - -  - - -+ |
  742.                 +----------------+----------------+
  743.                 | +- - -  - - -+ | +- - -  - - -+ |
  744.                 | |            | | |            | |
  745.                 |                |                |
  746.                 | |     CV     | | |            | |
  747.                 |   (CurVoxel)   |                |
  748.                 | |            | | |            | |
  749.                 | +- - -  - - -+ | +- - -  - - -+ |
  750.                 +----------------+----------------+
  751.  
  752.                 *** ******************************** **/
  753.                 /** ******************************** ***
  754.                 ___ == DONT CARE ABOUT
  755.                 P   + (N   * S   )==[ b_x, ___ , ___ ]
  756.                 P.x + (N.x * S.x )==  b_x
  757.                       (N.x * S.x )==  b_x - P.x
  758.                              S.x  == (b_x - P.x) / N.x
  759.                 *** ******************************** **/
  760.                 //:FIRST_PIXEL_OF_NEXT_VOXEL:--------://
  761.                 #define N_X ( 0.0 != N.x )
  762.                 #define N_Y ( 0.0 != N.y )
  763.                 #define N_Z ( 0.0 != N.z )
  764.  
  765.                 //:Scalar for point normal form.
  766.              //:F32 MAX_F32=intBitsToFloat(0x7f7fFFFF);
  767.              //:F32 MAX_F32=F32( 2147483647 );
  768.                 F32 MAX_F32=F32( 1000 * 1000 );
  769.                 V_3 S = V_3(MAX_F32,MAX_F32,MAX_F32);
  770.                 //:V_3 S = V_3( 0,0,0 );
  771.  
  772.                 /**  [f_x,f_y,f_z] or [ P.x,P.y,P.z ]**/
  773.                 if( N_X ){ S.x = ( b_x - P.x ) / N.x; }; //:<<<<<<<<<<< THIS EQUATION MINUS BY floored or by P ?
  774.                 if( N_Y ){ S.y = ( b_y - P.y ) / N.y; };
  775.                 if( N_Z ){ S.z = ( b_z - P.z ) / N.z; };
  776.    
  777.                 /** #TRAP_VALUE_MUST_BE_NEG_666# **/
  778.                 #define _666_ ( 0.0 - 666.0  )
  779.                 F32 shortest_scalar_distance=( _666_ );
  780.                 V_3 first_pixel_of_next_voxel;
  781.                 #undef  _666_
  782.  
  783.                 if( N_X && S.x <= S.y && S.x <= S.z ){
  784.                     shortest_scalar_distance=(  S.x );
  785.                 }else
  786.                 if( N_Y && S.y <= S.x && S.y <= S.z ){
  787.                     shortest_scalar_distance=(  S.y );
  788.                 }else
  789.                 if( N_Z && S.z <= S.x && S.z <= S.y ){
  790.                     shortest_scalar_distance=(  S.z );
  791.                 };;
  792.  
  793.                 /** Not using this anywhere, BUT KEEP**/
  794.                 /** for now. Now is not the time     **/
  795.                 /** to optimize.                     **/
  796.                 first_pixel_of_next_voxel=(
  797.                 //: P + ( N * [ S.x | S.y | S.z ] )
  798.                     P + ( N * shortest_scalar_distance )
  799.                 );;
  800.  
  801.                 vox_000.vod.dis_nex=(
  802.                         shortest_scalar_distance );;
  803.  
  804.                 //:vox_000.vod.dis_nex=( 8.0 );
  805.  
  806.                 #undef  N_X  
  807.                 #undef  N_Y  
  808.                 #undef  N_Z  
  809.                 //:--------:FIRST_PIXEL_OF_NEXT_VOXEL://
  810.  
  811.            
  812.             #undef  P /** Point  **/
  813.             #undef  N /** Normal **/
  814.             //:-------------------:DIST_TO_NEXT_VOXEL://
  815.             //:GET_VOXEL_PIXEL:----------------------://
  816.             if( vox_000.voc.has >= U32(1) ){ //:-----://
  817.  
  818.                 /** If you are inside a voxel, than  **/
  819.                 /** you by definition MUST be at a   **/
  820.                 /** certain pixel within that voxel. **/
  821.  
  822.                 P_X = I32( f_x ) - (T_X * NPX);
  823.                 P_Y = I32( f_y ) - (T_Y * NPY);
  824.                 P_Z = I32( f_z ) - (T_Z * NPZ);
  825.  
  826.  
  827.                 /** ******************************** ***
  828.  
  829.                 This is why we should FLOOR xyz
  830.                 values when figuring out what
  831.                 Tile(voxel) or Pixel(VoxelSubCell)
  832.                 we are inside of.
  833.  
  834.                 |<- 0 ->|<- 1 ->| <-- DISCREET_MODEL
  835.                 +---+---+---+---+
  836.                 |   .   |   .   |
  837.                 + - + - + - + - +
  838.                 |   .   |   .   |
  839.                 +---+---+---+---+
  840.                 ^       ^
  841.                 |       |
  842.                 0       1 <---------- FRACTIONAL_MODEL
  843.  
  844.                 *** ******************************** **/
  845.                
  846.                 //: Index2D -and- Index3D
  847.                 int D2D = P_X + ( NPX    *    P_Y );
  848.                 int D3D = D2D + ( NPX * NPY * P_Z );
  849.  
  850.                 P_I = ( D3D /** inDEX_3D **/ );
  851.  
  852.             };; //:------------------:GET_VOXEL_PIXEL://
  853.          
  854.             return( vox_000 );
  855.  
  856.         } // <<<<<<<<<<<<<{ GET_vox_000_USE_xyz_rwN } //
  857.  
  858.     // ---------------------------------------------- //
  859.     #undef  T_X   // ( vox_000.voc.t_x ) // --------- //
  860.     #undef  T_Y   // ( vox_000.voc.t_y ) // --------- //
  861.     #undef  T_Z   // ( vox_000.voc.t_z ) // --------- //
  862.     // ---------------------------------------------- //
  863.     #undef  P_X   // ( vox_000.voc.p_x     ) // ----- //
  864.     #undef  P_Y   // ( vox_000.voc.p_y     ) // ----- //
  865.     #undef  P_Z   // ( vox_000.voc.p_z     ) // ----- //
  866.     #undef  P_I   // ( vox_000.voc.pix_d3d ) // ----- //
  867.     //:=====================:FIRST_VOXEL_QUERY_NEEDED://
  868.     //:MARCH_INTO_VOXEL:=============================://
  869.     VOX_MAR sdf_MarchIntoVoxel(
  870.         VOX_000 vox_000
  871.     ,   V_3     xyz
  872.     ,   V_3     rwN
  873.     )
  874.     {
  875.  
  876.         VOX_MAR vox_mar;
  877.         vox_mar.exit=U32( 1 );
  878.  
  879.  
  880.         return( vox_mar );
  881.     }
  882.     //:=============================:MARCH_INTO_VOXEL://
  883.     #define  F    float
  884.     #define  U    uint
  885.     #define _FF_  uint( 0xFF )
  886.  
  887.         V_4 u32_CTO_c4d(
  888.             U32 u32
  889.         ){
  890.             V_4
  891.             c4d = V_4( /** c4d:Color_4_Dimensional **/
  892.                 F( ( u32 >> U(24) ) & _FF_ ) / 255.0
  893.             ,   F( ( u32 >> U(16) ) & _FF_ ) / 255.0
  894.             ,   F( ( u32 >> U( 8) ) & _FF_ ) / 255.0
  895.             ,   F( ( u32 >> U( 0) ) & _FF_ ) / 255.0
  896.             );;
  897.             return( c4d );
  898.         }
  899.  
  900.     #undef  F  
  901.     #undef  U  
  902.     #undef _FF_
  903.     //:INTEGER_MODULO:===============================://
  904.  
  905.     #ifndef I32
  906.     #define I32 int
  907.     #endif
  908.  
  909.     #ifndef F32
  910.     #define F32 float
  911.     #endif
  912.  
  913.         /** PRIVATE: Called only by I32_MOD **/
  914.         I32 i32_mod_neg( I32 neg_a , I32 pos_d ){
  915.  
  916.             /** ************************************ ***
  917.             Function Calculates:
  918.            
  919.             FIXED: (d-1)-[ mod(abs(a)+1 , d) ]
  920.  
  921.             GOAL: Negatives keep exact same tiling
  922.                   pattern as the positives.
  923.  
  924.             IN : -6 -5 -4 -3 -2 -1  0 +1 +2 +3 +4 +5 +6
  925.             OUT:  2  3  0  1  2  3  0  1  2  3  0  1  2
  926.  
  927.             0123 -> 0123 -> 0123 -> 0123 -> 0123 -> ect
  928.  
  929.            
  930.  
  931.             *** ************************************ **/
  932.  
  933.             I32 pos_a = ( 0 - neg_a ) + 1;
  934.            
  935.             F32 A = F32( pos_a );
  936.             F32 D = F32( pos_d );
  937.            
  938.             //: GLSL_MODULUS_WITH_INTEGERS_FORMULA
  939.             //: WARD:Wholepart,All,Remainder,Divisor
  940.             int W = int(  trunc( A / (          D  )) );
  941.             int R = int(         A - ( F32(W) * D  )  );
  942.            
  943.             return( (pos_d-1) - R );
  944.         }
  945.  
  946.         I32
  947.         I32_MOD(
  948.         /**/I32 a /** ALL     : CAN BE NEGATIVE **/
  949.         ,   I32 d /** DIVISOR : ALWAYS POSITIVE **/
  950.         ){
  951.  
  952.             /** ************************************ ***
  953.  
  954.             Allow for I32_MOD to be used for wrapping
  955.             even when the input to wrap[ a ] goes
  956.             negative. d should always be positive.
  957.  
  958.             EX: mod( x , 2 ) , where x == -1
  959.             | -1 | 0 [ 1 ] 2 |
  960.             |  1 | 0 [ 1 ] 0 | 1 | 0 |
  961.             d + 1 == 2 + (-1) == 1
  962.             *** ************************************ **/
  963.  
  964.             int R;
  965.  
  966.             if( a < 0 ){
  967.  
  968.                 //:This is CLOSE but then new problem
  969.                 //:of lots of green checkers is showing
  970.                 //:up. No clue...
  971.                 R = i32_mod_neg( a , d );
  972.  
  973.             }else{
  974.  
  975.                 F32 A = F32( a );
  976.                 F32 D = F32( d );
  977.                             //:<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<FIX_THE_OVERFLOW_BELOW
  978.                 //: GLSL_MODULUS_WITH_INTEGERS_FORMULA
  979.                 //: WARD:Wholepart,All,Remainder,Divisor
  980.                 int W = int(  trunc( A / (          D  )) );
  981.                     R = int(         A - ( F32(W) * D  )  );
  982.  
  983.             };;
  984.  
  985.             return( R );
  986.         }
  987.     //:===============================:INTEGER_MODULO://
  988.     //:MAX_OF_3_NAMED_BY_USE_CASE:===================://
  989.     #define F float
  990.     #define M max
  991.  
  992.         F32
  993.         GET_npm_USE_npx_npy_npz(
  994.             I32     npx         /** I32 so we don't  **/
  995.         ,   I32         npy     /** need to CAST when**/
  996.         ,   I32             npz /** calling this.    **/
  997.         ){                      /** ACTUALLY U32 vals**/
  998.  
  999.             //: npm: Number_of_Pixels_Max(x,y,z)
  1000.             F32 npm = M( M( F(NPX),F(NPY) ),F(NPZ) );
  1001.             return( npm );
  1002.         }
  1003.  
  1004.     #undef  F
  1005.     #undef  M
  1006.     //:===================:MAX_OF_3_NAMED_BY_USE_CASE://
  1007.     //:VOXEL_TO_DEBUG_COLOR:=========================://
  1008.     /** @VOXBUGCOLOR@ **/
  1009.     #define P_X ((( vox_000.voc.p_x )))
  1010.     #define P_Y ((( vox_000.voc.p_y )))
  1011.     #define P_Z ((( vox_000.voc.p_z )))
  1012.     #define ALP ( 1.0 )
  1013.  
  1014.         V_4 vox_000_CTO_c4d(
  1015.  
  1016.             VOX_000 vox_000
  1017.         )
  1018.         {
  1019.             V_4 c4d; /** [output/return/result] **/
  1020.  
  1021.             /** base color **/
  1022.             V_4 b_c=( u32_CTO_c4d( vox_000.voc.val ));
  1023.  
  1024.             #define F float
  1025.             F d_x = min( F(P_X) , F( NPX - P_X - 1 ));
  1026.             F d_y = min( F(P_Y) , F( NPY - P_Y - 1 ));
  1027.             F d_z = min( F(P_Z) , F( NPZ - P_Z - 1 ));
  1028.             #undef  F
  1029.  
  1030.             F32 m2d ; /** m2d: Minimum 2D **/
  1031.            
  1032.             if( d_x <= d_y && d_x <= d_z ){
  1033.             /** d_x == X_PLANE == [ y , z ] **/
  1034.  
  1035.                 m2d = min( d_y , d_z );
  1036.                 //: c4d =V_4( 1,0,0,  ALP );
  1037.             }else
  1038.             if( d_y <= d_x && d_y <= d_z ){
  1039.             /** d_y == Y_PLANE == [ x , z ] **/
  1040.  
  1041.                 m2d = min( d_x , d_z );
  1042.                 //: c4d =V_4( 0,1,0,  ALP );
  1043.  
  1044.             }else
  1045.             if( d_z <= d_x && d_z <= d_y ){
  1046.             /** d_z == Z_PLANE == [ x , y ] **/
  1047.  
  1048.                 m2d = min( d_x , d_y );
  1049.                 //: c4d =V_4( 0,0,1,  ALP );
  1050.  
  1051.             }else{
  1052.                 /** This should never execute **/
  1053.             };;
  1054.  
  1055.             #define F float
  1056.             F32 n_p = max_003( F(NPX),F(NPY),F(NPZ) );
  1057.             F32 per =( m2d*2.0 ) / n_p ;
  1058.             #undef  F
  1059.  
  1060.             if( per > 0.0 ){
  1061.  
  1062.                 c4d =V_4(
  1063.                     b_c.x * per
  1064.                 ,   b_c.y * per
  1065.                 ,   b_c.z * per
  1066.                 ,   b_c.w * 1.0
  1067.                 );;
  1068.             }else{
  1069.             #define X d_x
  1070.             #define Y d_y
  1071.             #define Z d_z
  1072.  
  1073.                 /** #VOXEL_EDGE_COLOR#          **/
  1074.                 /** #NO_ELSE_FOR_EDGE_COLORING# **/
  1075.  
  1076.                 F32 R=( 0.0 );
  1077.                 F32 G=( 0.0 );
  1078.                 F32 B=( 0.0 );
  1079.                
  1080.                 if( X <= Y && X <= Z ){  /** X_PLANE **/
  1081.  
  1082.                     R =( 1.0 );
  1083.  
  1084.                 };; /** NO ELSE! **/
  1085.                 if( Y <= X && Y <= Z ){  /** Y_PLANE **/
  1086.  
  1087.                     G =( 1.0 );
  1088.  
  1089.                 };; /** NO ELSE! **/
  1090.                 if( Z <= X && Z <= Y ){  /** Z_PLANE **/
  1091.  
  1092.                     B =( 1.0 );
  1093.  
  1094.                 };; /** NO ELSE! **/
  1095.  
  1096.                 c4d =V_4( R,G,B, ALP );
  1097.  
  1098.             #undef  X  
  1099.             #undef  Y  
  1100.             #undef  Z  
  1101.             };;
  1102.  
  1103.             return( c4d );
  1104.         }
  1105.  
  1106.     #undef  P_X  
  1107.     #undef  P_Y  
  1108.     #undef  P_Z  
  1109.     #undef  ALP  
  1110.     //:=========================:VOXEL_TO_DEBUG_COLOR://
  1111.  
  1112. //:22222222222222222222222222222222222222222222222222://
  1113. //:11111111111111111111111111111111111111111111111111://
  1114.  
  1115.     //:FRAGCOORD_TO_FRAGPERCENT:=====================://
  1116.     //:f_c_CTO_f_p:==================================://
  1117.  
  1118.         V_2 f_c_CTO_f_p( V_2 f_c ){
  1119.         V_2         f_p;
  1120.             f_p = f_c / ( iResolution.xy - 1.0 );
  1121.             return(  f_p );
  1122.         }
  1123.  
  1124.     //:==================================:f_c_CTO_f_p://
  1125.     //:=====================:FRAGCOORD_TO_FRAGPERCENT://
  1126.     //:FRAGPER_TO_CAMERA_RAY:========================://
  1127.     //:f_p_CTO_rwC_AND_rwN_CAMTYPE_OGP_TOP:==========://
  1128.  
  1129.                 RWC_AND_RWN
  1130.         f_p_CTO_rwC_AND_rwN_CAMTYPE_OGP_TOP(
  1131.             V_2 f_p /** 2 dimensional percentage **/
  1132.         )
  1133.         {
  1134.             F32 bug = ( F32(NPZ) * 4.0 ); //:DEBUG_ONLY
  1135.             F32 spd     =( 0.5 /**SPEED FACTOR **/ );
  1136.             F32 pos_cos =( cos(iTime*spd)+1.0 ) / 2.0;
  1137.             F32 neg_cos =( cos(iTime*spd)-1.0 ) / 2.0;
  1138.             bug=bug*pos_cos;
  1139.             //:bug = ( (-16.1) * bug );
  1140.             //:bug = ( -1036.8 );
  1141.             //:bug=( -32.2   );
  1142.  
  1143.             /** ************************************ ***
  1144.             TODO: Fix bug...
  1145.                 bug=( -   0.2 ); <<<<< OK
  1146.                 bug=( -  16.2 ); <<<<< OK
  1147.                 bug=( -  32.2 ); <<<<< ERR
  1148.                 bug=( -  48.2 ); <<<<< OK
  1149.                 bug=( -  64.2 ); <<<<< ERR
  1150.                 bug=( -  80.2 ); <<<<< OK
  1151.                 bug=( -  96.2 ); <<<<< ERR
  1152.                 bug=( - 112.2 ); <<<<< OK
  1153.                 bug=( - 128.2 ); <<<<< ERR
  1154.                 bug=( -1036.8 );
  1155.  
  1156.             *** ************************************ **/
  1157.          
  1158.             V_3 rwC; //:ray_word__COORDINATE
  1159.             V_3 rwN; //:ray_world_NORMAL____
  1160.  
  1161.             //:#FIND_POINT_ON_SCREEN_PLANE#
  1162.             F32 H = F32( 0 - 9 );; //:Cam Height Pos
  1163.             F32 X = iResolution.x - 1.0;
  1164.             F32 Y = iResolution.y - 1.0;
  1165.             /** ************************************ ***
  1166.                             A_B
  1167.                         A----|------B
  1168.                         |    |      |
  1169.                         |   rwC     |
  1170.                         |    |      |
  1171.                         C----|------D
  1172.                             C_D
  1173.                                
  1174.             *** ************************************ **/
  1175.  
  1176.             F32  _ =F32( 0.0 /**ALWAYS_ZERO **/ );
  1177.             F32 XOS=F32( 0 );
  1178.             F32 YOS=F32( 0 );
  1179.             F32 ZOS=F32( 0 );
  1180.  
  1181.             V_3 _A_ = V_3( _+XOS,_+YOS,  bug+H+ZOS );  
  1182.             V_3 _B_ = V_3( X+XOS,_+YOS,  bug+H+ZOS );  
  1183.                                      
  1184.             V_3 _C_ = V_3( _+XOS,Y+YOS,  bug+H+ZOS );  
  1185.             V_3 _D_ = V_3( X+XOS,Y+YOS,  bug+H+ZOS );  
  1186.                                      
  1187.  
  1188.             V_3 A_B = sdf_i3d( _A_ , _B_ , f_p.x );
  1189.             V_3 C_D = sdf_i3d( _C_ , _D_ , f_p.x );
  1190.                 rwC = sdf_i3d( A_B , C_D , f_p.y );
  1191.  
  1192.                 //:#POSITIVE_Z_DIVES_INTO_SCREEN#://
  1193.                 rwN = normalize( V_3( 0 , 0 , 1 ) );
  1194.  
  1195.                     RWC_AND_RWN
  1196.                     rwC_AND_rwN;
  1197.                     rwC_AND_rwN.rwC = rwC;
  1198.                     rwC_AND_rwN.rwN = rwN;
  1199.             return( rwC_AND_rwN );
  1200.         }
  1201.  
  1202.     //:==========:f_p_CTO_rwC_AND_rwN_CAMTYPE_OGP_TOP://
  1203.     //:f_p_CTO_rwC_AND_rwN_CAMTYPE_OGP_34D:==========://
  1204.     #define _0_  (0.0)
  1205.     #define  _   (0.0)
  1206.  
  1207.                 RWC_AND_RWN
  1208.         f_p_CTO_rwC_AND_rwN_CAMTYPE_OGP_34D(
  1209.             V_2 f_p /** 2 dimensional percentage **/
  1210.         )
  1211.         {
  1212.             RWC_AND_RWN  /** OUTPUT_OBJECT **/
  1213.             rwC_AND_rwN; /** OUTPUT_OBJECT **/
  1214.  
  1215.             V_3 rwC; //:ray_word__COORDINATE
  1216.             V_3 rwN; //:ray_world_NORMAL____
  1217.  
  1218.             //:#FIND_POINT_ON_SCREEN_PLANE#
  1219.             /** ************************************ ***
  1220.             Could possibly use these as slice planes.
  1221.             But for now using these to navigate our
  1222.             voxel map bounds.
  1223.  
  1224.             [ A ]Is_Directly_Above[ E ]On_Z_Axis
  1225.             [ B ]Is_Directly_Above[ F ]On_Z_Axis
  1226.             [ C ]Is_Directly_Above[ G ]On_Z_Axis
  1227.             [ D ]Is_Directly_Above[ H ]On_Z_Axis
  1228.            
  1229.                         (In World/Frag Coords)
  1230.                             [0,0,0]
  1231.                                 \
  1232.                 A_B              \
  1233.             A----|------B  A -->  +=======+  <-- B
  1234.             |    |      |        /.       .\
  1235.             | rwC_001   |       / .       . \
  1236.             |    |      |      /  .       .  \
  1237.             C----|------D  C->+===============+<-D
  1238.                 C_D           [   ._....._.   ]
  1239.                               [  /         \  ]
  1240.                               [ .           . ]
  1241.                               [/             \]
  1242.                               +===============+<-H
  1243.  
  1244.                               +===============+  
  1245.                               [\             /]
  1246.                               [ .           . ]
  1247.                               [  \_......._/  ]
  1248.                 E_F           [   .       .   ]
  1249.             E----|------F  G->+===============+<-H
  1250.             |    |      |      \  .       .  /
  1251.             | rwC_002   |       \ .       . /
  1252.             |    |      |        \.       ./
  1253.             G----|------H  E -->  +=======+  <-- F
  1254.                 G_H          
  1255.                            
  1256.             *** ************************************ **/
  1257.  
  1258.             //:Dimensions Of Voxel Volume:
  1259.             //:As maximum indexes.
  1260.             F32 M_X =( F32(TPX) - 1.0 );
  1261.             F32 M_Y =( F32(TPY) - 1.0 );
  1262.             F32 M_Z =( F32(TPZ) - 1.0 );
  1263.  
  1264.             //:TOP LAYER OF PIXELS OF VOXEL VOLUME:
  1265.             //:(INCLUSIVE MATH. We are inside the)
  1266.             //:(first layer of pixels of the first)
  1267.             //:(layer of voxels)
  1268.             V_3 _A_ = V_3( _-_ , _-_ , _-_ );
  1269.             V_3 _B_ = V_3( M_X , _-_ , _-_ );      
  1270.             V_3 _C_ = V_3( _-_ , M_Y , _-_ );
  1271.             V_3 _D_ = V_3( M_X , M_Y , _-_ );
  1272.  
  1273.             //:BOTTOM LAYER OF PIXELS OF VOXEL VOLUME
  1274.             //:(Incluseive Math. We are inside the )
  1275.             //:(last layer of pixels of the last   )
  1276.             //:(layer of voxels.                   )
  1277.             V_3 _E_ = V_3( _-_ , _-_ , M_Z );
  1278.             V_3 _F_ = V_3( M_X , _-_ , M_Z );      
  1279.             V_3 _G_ = V_3( _-_ , M_Y , M_Z );
  1280.             V_3 _H_ = V_3( M_X , M_Y , M_Z );
  1281.  
  1282.             /** ************************************ ***
  1283.             Take our plane and pretend it is
  1284.             the top of a cube that we want to
  1285.             get plane in an isometric position to.
  1286.             Where the new plane tangents corner _D_
  1287.            
  1288.            
  1289.                    A------_B_            vec_D_B
  1290.                   /|       \\                  \
  1291.                  / |       |\\                  \
  1292.                 /  |       | \\      vec_D_C <---D
  1293.               _C_============_D_                 ^
  1294.                |   |_ _ _ _|  ||                 |
  1295.                |  /E       F\ ||            vec_H_D
  1296.                | /           \||
  1297.                |/             ||     Corner_Vector:
  1298.                G-------------_H_  
  1299.             *** *** * * * * * * **** * * * * * * *** **/
  1300.  
  1301.             /** Edge Vectors **/
  1302.  
  1303.             V_3 vec_C_D = normalize( _D_ - _C_ );
  1304.             V_3 vec_D_C = normalize( _C_ - _D_ );
  1305.             V_3 vec_D_B = normalize( _B_ - _D_ );
  1306.             V_3 vec_H_D = normalize( _D_ - _H_ );
  1307.             V_3 vec_D_H = normalize( _H_ - _D_ );
  1308.  
  1309.             /** *** * * * * * * **** * * * * * * *** ***
  1310.             Use Corner_Vector to calculate a 3/4        
  1311.             perspective plane that tangents _D_.
  1312.             *** ************************************ **/
  1313.             /** ************************************ ***
  1314.    
  1315.             X axis vector is pretty easy because the
  1316.             camera X axis does not move in the Z
  1317.             direction.
  1318.                     ^         /
  1319.                     |       /    ^
  1320.             A-------B     /      |    a_x Is Average
  1321.             |       |   /        |  
  1322.             |       | /     vec_D_B
  1323.             C-------D-->    vec_C_D ----->
  1324.                   /
  1325.                 /
  1326.               /<-- goal is THIS line for X-axis.(a_x)
  1327.             /
  1328.             *** *** * * * * * * **** * * * * * * *** **/
  1329.             #define _X_ vec_C_D
  1330.             #define _Y_ vec_D_B
  1331.             V_3 a_x =normalize(
  1332.  
  1333.                 /** 45 degree line on XY plane **/
  1334.                 ( _X_ + _Y_ ) / 2.0  
  1335.  
  1336.             );;
  1337.             #undef  _X_
  1338.             #undef  _Y_
  1339.             /** *** * * * * * * **** * * * * * * *** ***
  1340.            
  1341.             Y axis vector is a bit tricky because it
  1342.             moves on all axis(es). XYZ.
  1343.  
  1344.             +--B  If we average vec_D_C & vec_D_B
  1345.             |\ |  To get a 45 degree on the XY plane,
  1346.             | \|  we can then tilt that vector up
  1347.             C--D  by 45 degrees by averaging it
  1348.                |  with vec_H_D
  1349.                |
  1350.                H
  1351.  
  1352.             *** ************************************ **/
  1353.  
  1354.             //: a_y: Axis_Y
  1355.             #define _X_ vec_D_C
  1356.             #define _Y_ vec_D_B
  1357.             #define _Z_ vec_H_D
  1358.             V_3 a_y =normalize(
  1359.  
  1360.                 (
  1361.                     normalize( (_X_ + _Y_)/2.0 )
  1362.                     +        (     _Z_         )
  1363.                 ) /2.0
  1364.             );;
  1365.             #undef  _X_
  1366.             #undef  _Y_
  1367.             #undef  _Z_
  1368.  
  1369.            
  1370.             /** Looking into the voxel volume from   **/
  1371.             /** a 3/4 isometric direction.           **/
  1372.             V_3 a_z = normalize(
  1373.                 ( vec_D_C + vec_D_B + vec_D_H ) / 3.0
  1374.             );;
  1375.  
  1376.             /** ************************************ ***
  1377.  
  1378.             We can now use point-normal form to
  1379.             build our camera polygon. We will start
  1380.             from point _D_ and walk HALFWAY the
  1381.             WIDTH in both directions on our altered
  1382.             x-axis vector( a_x ) and HALFWAY the
  1383.             HEIGHT in both directions on our altered
  1384.             y-axis vector( a_y ).
  1385.  
  1386.             HEIGHT: The height of our camera plane.
  1387.              WIDTH: The width  of our camera plane.
  1388.  
  1389.                       P_X                   +---+
  1390.                 +------+------+             |   |
  1391.                 |      |      |         +---+---+
  1392.             N_Y +---- _D_ ----+ P_Y     |_D_|
  1393.                 |      |      |     +---+---+
  1394.                 +------+------+     |   |#DIA_CAMCENTER#
  1395.                       N_X           +---+
  1396.  
  1397.                 #CAMCENTER#:
  1398.                 In order for the camera to be 100%
  1399.                 centered, it may be necessary to
  1400.                 squash or stretch the camera by 1
  1401.                 pixel IF the camera is NOT an odd
  1402.                 number of pixels on that axis.
  1403.                 SEE_DIAGRAM[ #DIA_CAMCENTER# ]
  1404.  
  1405.                     +0 +1 +2 +2.5       +0 +1 +2 +3  
  1406.                     [D]   [+]           ||     [+]    
  1407.                 [ ][ ][ ][ ][ ]   [ ][ ][ ][ ][ ][ ]  
  1408.                 |<---- 5 ---->|   |<------ 6 ----->|  
  1409.  
  1410.             *** ************************************ **/
  1411.  
  1412.             #define ZOOMED_IN_CAMERA_2020_11_26 ( 1 )
  1413.             float H_W ; //:H_W:Halfway_Width
  1414.             float H_H ; //:H_H:Halfway_Height
  1415.             if( ZOOMED_IN_CAMERA_2020_11_26 >= 1 ){
  1416.  
  1417.                 F32 npm = GET_npm_USE_npx_npy_npz(
  1418.                                       NPX,NPY,NPZ);;
  1419.  
  1420.                 /** Display Size Of  A Single Voxel  **/
  1421.                 /** In Terms Of PIXELS/FRAGS         **/
  1422.                 F32 zoo_mul =( 128.0 );
  1423.                 F32 zoo_div =( zoo_mul / npm );
  1424.    
  1425.                 /** Camera surface smaller than      **/
  1426.                 /** client viewport means zoomed in  **/
  1427.                 //: H_W = ( F32(TPX) / 2.0 );
  1428.                 //: H_H = ( F32(TPY) / 2.0 );
  1429.  
  1430.                 H_W = ( iResolution.x / 2.0 );
  1431.                 H_H = ( iResolution.y / 2.0 );
  1432.  
  1433.                 H_W = ( H_W / zoo_div );
  1434.                 H_H = ( H_H / zoo_div );
  1435.  
  1436.             }else
  1437.             if( ZOOMED_IN_CAMERA_2020_11_26 <= 0 ){
  1438.  
  1439.                 /** Camera surface exactly same size **/
  1440.                 /** as client viewport means no zoom.**/
  1441.                 H_W = ( iResolution.x / 2.0 );
  1442.                 H_H = ( iResolution.y / 2.0 );
  1443.  
  1444.             };;
  1445.             #undef  ZOOMED_IN_CAMERA_2020_11_26
  1446.  
  1447.             /** To be pixel-perfect, floor and ceil  **/
  1448.             /** need to be used. This is an OCD      **/
  1449.             /** optimization that can probably       **/
  1450.             /** be removed without noticable         **/
  1451.             /** difference in the result.            **/
  1452.             //- P_X = floor( _D_ + ( a_x * H_W ) );  -//
  1453.             //- N_X =  ceil( _D_ - ( a_x * H_W ) );  -//
  1454.             //- P_Y = floor( _D_ + ( a_y * H_H ) );  -//
  1455.             //- N_Y =  ceil( _D_ - ( a_y * H_H ) );  -//
  1456.             //+ We can't do it this way, because the +//
  1457.             //+ plane is not aligned with our native +//
  1458.             //+ XYZ axis.                            +//
  1459.             //+ What I mean is we can't get the top  +//
  1460.             //+ left corner by saying:               +//
  1461.             //+ vec3( N_Y.x , P_X.y , _D_.z )        +//
  1462.             /** ************************************ ***
  1463.             RASTER_GRAPHICS_STYLE_TOP_LEFT_ORIGIN
  1464.                \
  1465.                 +----------- +X ------------>
  1466.                 |    
  1467.                 |     _I_              _J_
  1468.                 |       \      P_X      /  
  1469.                 |        +------+------+        ^
  1470.                 |        |      |      |        |
  1471.                +Y    N_Y +---- _D_ ----+ P_Y [ -y ]
  1472.                 |        |      |      |        |
  1473.                 |        +------+------+        |
  1474.                 |       /      N_X      \       |
  1475.                 V     _K_               _L_     |
  1476.                                                 |
  1477.                     <---------[ -x ]------------+
  1478.  
  1479.             *** *** * * * * * * **** * * * * * * *** **/
  1480.    
  1481.             V_3 _I_ = _D_  - ( a_x * H_W )
  1482.                            - ( a_y * H_H ) ;;
  1483.  
  1484.             V_3 _J_ = _D_  + ( a_x * H_W )
  1485.                            - ( a_y * H_H ) ;;
  1486.  
  1487.             V_3 _K_ = _D_  - ( a_x * H_W )
  1488.                            + ( a_y * H_H ) ;;
  1489.  
  1490.             V_3 _L_ = _D_  + ( a_x * H_W )
  1491.                            + ( a_y * H_H ) ;;
  1492.                    
  1493.             /** ************************************ **/
  1494.             #define USE_ANIMATED_DOLLY_FOR_DEBUG  ( 1 )
  1495.             if(     USE_ANIMATED_DOLLY_FOR_DEBUG >= 1 ){
  1496.  
  1497.                 F32 max_dolly =max(
  1498.                             F32(TPX)
  1499.                 ,
  1500.                         max(
  1501.                             F32(TPY)
  1502.                             ,
  1503.                             F32(TPZ)
  1504.                         )
  1505.                 );;
  1506.  
  1507.                 F32 pos_cos=( (cos(iTime)/2.0)+0.5 );
  1508.                 F32 neg_cos=( (cos(iTime)/2.0)-0.5 );
  1509.  
  1510.                 F32 dolly_amount =(
  1511.                     pos_cos * max_dolly
  1512.                 );;
  1513.                
  1514.                 _I_ += ( a_z * dolly_amount );
  1515.                 _J_ += ( a_z * dolly_amount );
  1516.                 _K_ += ( a_z * dolly_amount );
  1517.                 _L_ += ( a_z * dolly_amount );
  1518.  
  1519.             };;
  1520.             #undef  USE_ANIMATED_DOLLY_FOR_DEBUG
  1521.            
  1522.             V_3 I_J = sdf_i3d( _I_ , _J_ , f_p.x );
  1523.             V_3 K_L = sdf_i3d( _K_ , _L_ , f_p.x );
  1524.                 rwC = sdf_i3d( I_J , K_L , f_p.y );
  1525.  
  1526.                 //:#POSITIVE_Z_DIVES_INTO_SCREEN#://
  1527.                 rwN = normalize( a_z );
  1528.  
  1529.                     rwC_AND_rwN.rwC = rwC;
  1530.                     rwC_AND_rwN.rwN = rwN;
  1531.             return( rwC_AND_rwN );
  1532.         }
  1533.     #undef  _0_
  1534.     #undef   _
  1535.     //:==========:f_p_CTO_rwC_AND_rwN_CAMTYPE_OGP_34D://
  1536.     //:f_p_CTO_rwC_AND_rwN_CAMTYPE_T3O_AAZ:==========://
  1537.  
  1538.                 RWC_AND_RWN
  1539.         f_p_CTO_rwC_AND_rwN_CAMTYPE_T3O_AAZ(
  1540.             V_2 f_p /** 2 dimensional percentage **/
  1541.         )
  1542.         {
  1543.             RWC_AND_RWN
  1544.             rwC_and_rwN;
  1545.  
  1546.             //:TODO: Logic.
  1547.  
  1548.             return( rwC_and_rwN );
  1549.  
  1550.         }
  1551.  
  1552.     //:==========:f_p_CTO_rwC_AND_rwN_CAMTYPE_T3O_AAZ://
  1553.     //:f_p_CTO_rwC_AND_rwN_CAMTYPE_T3I_AAZ:==========://
  1554.     /** TAGS[ t3i_aaz : t3i:aaz ] **/
  1555.     #define RWC rwC_and_rwN.rwC
  1556.     #define RWN rwC_and_rwN.rwN
  1557.  
  1558.                 RWC_AND_RWN
  1559.         f_p_CTO_rwC_AND_rwN_CAMTYPE_T3I_AAZ(
  1560.             V_2 f_p /** 2 dimensional percentage **/
  1561.         )
  1562.         {
  1563.             RWC_AND_RWN
  1564.             rwC_and_rwN;
  1565.  
  1566.             F32 pos_cos=(cos(iTime)+1.0) / 2.0 ;
  1567.  
  1568.             #define F float
  1569.             #define M max
  1570.             F32 N_T = M( M( F(NTX),F(NTY) ),F(NTZ) );
  1571.             F32 N_P = M( M( F(NPX),F(NPY) ),F(NPZ) );
  1572.             F32 rad =( N_T * N_P ) * 2.0 * pos_cos;
  1573.             #undef  F
  1574.             #undef  M
  1575.  
  1576.             //:           123456789
  1577.             F32 PI2 = ( 3.141592653 * 2.0 );
  1578.             F32 hig = (  400.0 ); //:Cylinder Height.
  1579.  
  1580.             F32 pop = f_p.x     ; //: Percent_On_Path
  1581.             V_2 c_n             ; //: Circle_Normal
  1582.             F32 ang = pop * PI2 ; //: Angle
  1583.             RWC.x = c_n.x = (0.0+rad) +cos(ang)*rad;
  1584.             RWC.y = c_n.y = (0.0+rad) +sin(ang)*rad;
  1585.             RWC.z = hig * f_p.y ;
  1586.        
  1587.             RWN.x = 0.0 - c_n.x;
  1588.             RWN.y = 0.0 - c_n.y;
  1589.             RWN.z = 0.0; //:Perpendicular To Z axis.
  1590.    
  1591.             return( rwC_and_rwN );
  1592.         }
  1593.  
  1594.     #undef  RWC
  1595.     #undef  RWN
  1596.     //:==========:f_p_CTO_rwC_AND_rwN_CAMTYPE_T3I_AAZ://
  1597.     //:f_p_CTO_rwC_AND_rwN:==========================://
  1598.     #define ogp_top f_p_CTO_rwC_AND_rwN_CAMTYPE_OGP_TOP
  1599.     #define ogp_34d f_p_CTO_rwC_AND_rwN_CAMTYPE_OGP_34D
  1600.     #define t3o_aaz f_p_CTO_rwC_AND_rwN_CAMTYPE_T3O_AAZ
  1601.     #define t3i_aaz f_p_CTO_rwC_AND_rwN_CAMTYPE_T3I_AAZ
  1602.  
  1603.                 RWC_AND_RWN
  1604.         f_p_CTO_rwC_AND_rwN(
  1605.             V_2 f_p /** 2 dimensional percentage **/
  1606.         )
  1607.         {
  1608.             RWC_AND_RWN
  1609.             rwC_and_rwN;
  1610.  
  1611.             switch( CAMTYPE ){
  1612.  
  1613.                 case          OGP_TOP :
  1614.                 rwC_and_rwN = ogp_top( f_p ); break;
  1615.  
  1616.                 case          OGP_34D :
  1617.                 rwC_and_rwN = ogp_34d( f_p ); break;
  1618.  
  1619.                 case          T3O_AAZ :
  1620.                 rwC_and_rwN = t3o_aaz( f_p ); break;
  1621.  
  1622.                 case          T3I_AAZ :
  1623.                 rwC_and_rwN = t3i_aaz( f_p ); break;
  1624.            
  1625.                 default : /** OGP_TOP **/
  1626.                 rwC_and_rwN = ogp_top( f_p ); break;
  1627.  
  1628.             };;  
  1629.  
  1630.             return( rwC_and_rwN );
  1631.         }
  1632.  
  1633.     #undef  ogp_top  
  1634.     #undef  ogp_34d  
  1635.     #undef  t3o_aaz  
  1636.     #undef  t3i_aaz  
  1637.     //:==========================:f_p_CTO_rwC_AND_rwN://
  1638.     //:========================:FRAGPER_TO_CAMERA_RAY://
  1639.     //:RENDER_SCENE:=================================://
  1640.     //:sdf_RenderScene:==============================://
  1641.     #define T_X vox_000.voc.t_x
  1642.     #define T_Y vox_000.voc.t_y
  1643.     #define T_Z vox_000.voc.t_z
  1644.     #define HAS vox_000.voc.has
  1645.     #define VAL vox_000.voc.val
  1646.     #define D_N vox_000.vod.dis_nex
  1647.  
  1648.         V_4 sdf_RenderScene( RWC_AND_RWN rwC_AND_rwN )
  1649.         {
  1650.             I32 o_k = I32( 1 );
  1651.             V_4 c4d = THE_COLOR_OF_EMPTY_SPACE ;
  1652.  
  1653.             V_3 rwN = rwC_AND_rwN.rwN;
  1654.             V_3 rwC = rwC_AND_rwN.rwC;
  1655.  
  1656.             V_3 xyz = rwC;
  1657.             F32 xyz_TDF_rwC=(0.0);
  1658.             /** xyz_total_distance_from_rwC **/
  1659.          
  1660.             VOX_000
  1661.             vox_000;
  1662.  
  1663.             VOX_MAR vox_mar;
  1664.  
  1665.             //:dis_nex: Distance To NEXT voxel.
  1666.             //:dis_sur: Distance To Surface Geometry inside
  1667.             //:     the current voxel. In world coords.
  1668.             vox_000.vod.dis_nex =( 0.0 );  
  1669.         //: vox_000.vod.dis_sur =( 0.0 );  
  1670.  
  1671.             //:Voxels will be thought of as 3D tiles:
  1672.             vox_000.voc.has     = uint( 0 ); // :1: //
  1673.             vox_000.voc.val     = uint( 0 ); // :2: //
  1674.             vox_000.voc.til_d3d =  int( 0 ); // :3: //
  1675.             vox_000.voc.t_x     =  int( 0 ); // :4: //
  1676.             vox_000.voc.t_y     =  int( 0 ); // :5: //
  1677.             vox_000.voc.t_z     =  int( 0 ); // :6: //
  1678.  
  1679.             //:RAY_MARCH_LOOP:-----------------------://
  1680.             /** #ABOUT_RAY_MARCH_LOOP# **/
  1681.  
  1682.                 //:(RayMarch)March to VOXEL:
  1683.                 for( int i = 0; i < MAX_STE ; i++ ){
  1684.  
  1685.                     //:March by distance to next voxel:
  1686.                    
  1687.                     //:Point_Normal_Form_To_Get:xyz
  1688.                     //:#DISTANCE_IS_NOT_CUMULATIVE#
  1689.                     rwN=normalize(rwN); //:TEMP_DEBUG
  1690.                     xyz =  xyz + ( rwN * (D_N+0.0) );;
  1691.                 //: xyz =  xyz + ( rwN * -8.0 );
  1692.  
  1693.                     /** B4 : GET_vox_000_USE_xyz_rwN **/
  1694.                     xyz_TDF_rwC += D_N;
  1695.                     if( xyz_TDF_rwC > MAX_DIS ){break;};
  1696.                
  1697.                     //:@WHATVOX@://
  1698.                         vox_000 =
  1699.                     GET_vox_000_USE_xyz_rwN(
  1700.                                     xyz,rwN );;
  1701.  
  1702.                     //:if( D_N <= 0.0 we have trouble )
  1703.                     F32 MF3=intBitsToFloat(0x7f7fFFFF);
  1704.                     if( 0.0 - 666.0 == D_N ){
  1705.  
  1706.                         /** Exit On Error            **/
  1707.                         /** #DIST_NEXT_NEVER_ZERO#   **/
  1708.                         c4d=PIX_ERR(ERR_003,c4d,o_k--);
  1709.                         break;
  1710.  
  1711.                     }else
  1712.                     if( vox_000.vod.dis_nex <= 0.0 ){
  1713.                         //:PULSING:ORANGE:VIA:POS_COS:
  1714.                         F32 p_c=((cos(iTime)+1.0)/2.0);
  1715.                         c4d=V_4(V_3(1,0.5,0)*p_c,1.0);
  1716.                         break;
  1717.                     }else
  1718.                     if( D_N == MF3 /** MaxFloat32 **/ ){
  1719.                         F32 p_c=((cos(iTime)+1.0)/2.0);
  1720.                         c4d=V_4(V_3(1,0.5,1)*p_c,1.0);
  1721.                         break;
  1722.                     }else
  1723.                     if( isinf( D_N ) ){
  1724.                         c4d=u32_CTO_c4d(U32(
  1725.                                     0xE0E0E0FF ));
  1726.                     };;
  1727.  
  1728.                     //:If voxel is not empty, ray march
  1729.                     //:inside of the voxel.
  1730.                     #define _0_ U32( 0 ) //:#########://
  1731.  
  1732.                     if( HAS > _0_ && _0_ == VAL ){
  1733.  
  1734.                         //:EMPTY_TILE_INSIDE_MAP_BOUNDS:
  1735.                         c4d=u32_CTO_c4d(U32(
  1736.                                     0x003300FF ));
  1737.  
  1738.                     }else
  1739.                     if( _0_ == HAS ){
  1740.  
  1741.                         //:OUT_OF_MAP_BOUNDS:
  1742.                     //  c4d=u32_CTO_c4d(U32(
  1743.                     //              0x330011FF ));
  1744.    
  1745.                         xyz_TDF_rwC=(length(xyz - rwC));
  1746.                         F32 per=(xyz_TDF_rwC / MAX_DIS);
  1747.                         F32 inv=( 1.0 - per );
  1748.  
  1749.                         c4d=V_4( V_3(1)*(inv) , 1.0 );
  1750.  
  1751.                     }else
  1752.                     if( HAS > _0_ && VAL > _0_  ){
  1753.    
  1754.                         vox_mar =(
  1755.                         sdf_MarchIntoVoxel(
  1756.                             vox_000,xyz,rwN
  1757.                         ));;
  1758.                        
  1759.                         /*[FIX]: ALWAYS RETURNS EXIT */
  1760.                         if( vox_mar.exit >= U32(1) ){
  1761.                        
  1762.                             //: c4d=( u32_CTO_c4d(
  1763.                             //: vox_000.voc.val ) );;
  1764.  
  1765.                             c4d =( vox_000_CTO_c4d(
  1766.                                    vox_000         ));;
  1767.                        
  1768.                             break;
  1769.                         };;
  1770.  
  1771.                     }else{
  1772.  
  1773.                         //:SHOULD_NEVER_EXECUTE:
  1774.                         c4d=V_4(1,0,0,1);
  1775.  
  1776.                     };;
  1777.  
  1778.                     #undef  _0_  //:#################://
  1779.  
  1780.                     /** Don't move the ray anywhere  **/
  1781.                     /** We are going to slice into   **/
  1782.                     /** whatever voxels the camera   **/
  1783.                     /** plane passes through.        **/
  1784.                     if( CFG_SLICE_RENDER >= 1 ){
  1785.                         break;
  1786.                     };;
  1787.  
  1788.                 };;
  1789.  
  1790.             //:-----------------------:RAY_MARCH_LOOP://
  1791.  
  1792.  
  1793.             if( CFG_SLICE_RENDER >= 1 ){
  1794.  
  1795.                 //:Layer value, 1 or 0
  1796.                 int lay = I32_MOD( T_Z, 2 );
  1797.                
  1798.                 //:#MODULO_CHECKER_PATTERN#://
  1799.                 int chk =(  
  1800.                     I32_MOD( //:<<<<<<<<<<<<<<:SET_003
  1801.                         I32_MOD( T_Y, 2 )   //:SET_YYY
  1802.                     +   I32_MOD( T_X, 2 )   //:SET_XXX
  1803.                     ,                 2
  1804.                     )
  1805.                 );;
  1806.            
  1807.                 if(   0 != 0
  1808.                 || ( lay < 0 )
  1809.                 || ( lay > 1 )
  1810.                 || ( chk < 0 || chk > 1 )
  1811.                 || ( HAS > uint(1)      )
  1812.                 ){
  1813.                     //: _0x010101_ & _0x101010_
  1814.                     c4d=PIX_ERR(ERR_001,c4d,o_k--);
  1815.                 };;
  1816.  
  1817.                
  1818.                 F32 M =( 255.0); //:Max RGB value.
  1819.                 F32 X =( 1.0  ); //:FOR_DEBUGGING_COLORS
  1820.              //:F32 ...........;    Replace with "_"
  1821.              //:F32 ...........;    when done debugging.
  1822.                 F32 a =( 1.0  ); //:ALPHA
  1823.                 F32 _ =( 0.0  );
  1824.                 F32 g =( F32(0x33)/M ); //:DARK-GREY
  1825.                 F32 G =( F32(0x38)/M );
  1826.                 F32 w =( F32(0xE5)/M ); //:WHITE-GREY
  1827.                 F32 W =( F32(0xF2)/M );
  1828.  
  1829.                 V_4 _0x333333_ =V_4(g,g,g,a);
  1830.                 V_4 _0x383838_ =V_4(G,G,G,a);
  1831.                 V_4 _0xE5E5E5_ =V_4(w,w,w,a);
  1832.                 V_4 _0xF2F2F2_ =V_4(W,W,W,a);
  1833.                 V_4 _0x003300_ =V_4(_,g,_,a);
  1834.                 V_4 _0x003800_ =V_4(_,G,_,a);
  1835.                 V_4 _0x00E500_ =V_4(_,w,_,a);
  1836.                 V_4 _0x00F200_ =V_4(_,W,_,a);
  1837.  
  1838.                 V_4 tab_000[8]=V_4[8](
  1839.                     //:OUT OF BOUNDS:       //:HAS?
  1840.                     _0x333333_ , _0x383838_ //:LAY0
  1841.                    ,_0xE5E5E5_ , _0xF2F2F2_ //:LAY1
  1842.                 //: |   CHK0   |     CHK1   |::::::::://
  1843.                                    
  1844.                     //:IN BOUNDS:           //:HAS?
  1845.                    ,_0x003300_ , _0x003800_ //:LAY0
  1846.                    ,_0x00E500_ , _0x00F200_ //:LAY1
  1847.                 //: |   CHK0   |     CHK1   |::::::::://
  1848.                 );;
  1849.                
  1850.                 I32 pik = (
  1851.                    (4 * ( HAS >= uint(1) ? 1 : 0 ))
  1852.                 +  (2 * lay ) //: LAY0 -or- LAY1
  1853.                 +  (1 * chk ) //: CHK0 -or- CHK1
  1854.                 );;
  1855.  
  1856.                 if( pik < 0 || pik >= 8 ){
  1857.                     c4d=PIX_ERR(ERR_002,c4d,o_k--);
  1858.                 };;
  1859.                
  1860.                 //:TODO: Why is not rendering as
  1861.                 //:      checker?
  1862.                 if( 1 == o_k ){
  1863.                     c4d = tab_000[ pik ];
  1864.                 };;
  1865.  
  1866.             }else{
  1867.                 //:DEBUG ONLY.
  1868.                 //:c4d=V_4(1,1,1,1);
  1869.             };;
  1870.  
  1871.             return( c4d );
  1872.         }
  1873.  
  1874.     #undef  T_X
  1875.     #undef  T_Y
  1876.     #undef  T_Z
  1877.     #undef  HAS
  1878.     #undef  VAL
  1879.     #undef  D_N
  1880.     //:==============================:sdf_RenderScene://
  1881.     //:=================================:RENDER_SCENE://
  1882.  
  1883. //:11111111111111111111111111111111111111111111111111://
  1884. //:00000000000000000000000000000000000000000000000000://
  1885.  
  1886.     void mainImage(
  1887.         out vec4 fragColor
  1888.     ,   in  V_2 fragCoord
  1889.     )
  1890.     {
  1891.            
  1892.         #define R_Y iResolution.y
  1893.             V_2 f_c = V_2(
  1894.             //:( FLIP? )       ( Discrete XY       ) ://
  1895.                (  0.0  )   +   ( fragCoord.x - 0.5 )
  1896.             ,  (R_Y-1.0)   -   ( fragCoord.y - 0.5 )
  1897.             );;
  1898.         #undef R_Y  
  1899.         V_2 f_p = f_c_CTO_f_p( f_c );
  1900.  
  1901.  
  1902.         //:CAMERA_RAY_FOR_CURRENT_PIXEL:-------------://
  1903.  
  1904.             /** The coordinate and direction of the  **/
  1905.             /** camera ray [rwC,rwN] are closely     **/
  1906.             /** related, so return them using the    **/
  1907.             /** same function. This will save        **/
  1908.             /** processing power when we decide      **/
  1909.             /** to create a camera lense that        **/
  1910.             /** is a 360 degree cylinder around      **/
  1911.             /** an object. (for fun)                 **/
  1912.  
  1913.             RWC_AND_RWN
  1914.             rwC_AND_rwN;
  1915.  
  1916.             rwC_AND_rwN = f_p_CTO_rwC_AND_rwN( f_p );
  1917.  
  1918.         //:-------------:CAMERA_RAY_FOR_CURRENT_PIXEL://
  1919.  
  1920.         fragColor = sdf_RenderScene( rwC_AND_rwN );
  1921.  
  1922.     }
  1923. //:00000000000000000000000000000000000000000000000000://
  1924. //:DOCUMENTATION:====================================://
  1925. /** ************************************************ ***
  1926.     ABBREVIATIONS:
  1927.  
  1928.         f : fragment
  1929.         p : percent (Never Position, use C for coord)
  1930.         c : coordinate
  1931.         r : ray
  1932.         n : normal, for directions.
  1933.         d : distance. NEVER DIRECTION.( use: n:normal )
  1934.        
  1935.     IDENTIFIERS:
  1936.  
  1937.         CTO: Convert_TO
  1938.         rwC: RayWorldCoord
  1939.         rwN: RayWorldNormal
  1940.         f_p: FragPercent
  1941.         f_c: FragCoord (With Discrete Pixel Coords)
  1942.                     (instead of pixel centers  )
  1943.         dad: Distance_And_inDEX
  1944.             Index is 1D index of XYZ voxel tile
  1945.             coordinate.
  1946.         vat: Voxel_Array__of__Tiles
  1947.         c4d: Color_4_Dimensional(RGBA)
  1948.  
  1949.     FUNCTIONS:
  1950.  
  1951.         f_c_CTO_f_p : FragmentCoord -CTO- FragPercent
  1952.         f_c_CTO_per : USE[ f_c_CTO_f_p ]
  1953.         sdf_i3d     : Interpolate_Two_3D_Points
  1954.  
  1955.     CTRL_F_INDEX: (CTRL+F:INDEX, Search Phrases)
  1956.                   (CTR + F)<-- Spaces Between Letters
  1957.  
  1958.         Which Voxel Am I On? .... SEE[  @WHATVOX@  ]
  1959.         What Voxel Am I On? ..... SEE[  @WHATVOX@  ]
  1960.         Find Current Voxel ...... SEE[  @WHATVOX@  ]
  1961.         pix_3d3 ................. TYPOFIX[ pix_d3d ]
  1962.         til_3d3 ................. TYPOFIX[ til_d3d ]
  1963.         cd4 ..................... TYPOFIX[   c4d   ]
  1964.         m3d ..................... TYPOFIX[   m2d   ]
  1965.         Voxel To Color Debug .... SEE[ @VOXBUGCOLOR@ ]
  1966.         gradient,Gradient........ SEE[ @VOXBUGCOLOR@ ]
  1967.         which voxel are we in ... SEE[ @WHATVOX@   ]
  1968.  
  1969.     EXTRACTED_BLOCK_COMMENTS:
  1970.  
  1971.         #ABOUT_RAY_MARCH_LOOP###########################
  1972.  
  1973.             Ray marching loop should be able to look    
  1974.             at the current voxel coordinate returned    
  1975.             and decide to STOP marching if it wants.    
  1976.             By stopping immediately without marching    
  1977.             at all we can make the camera phosphore    
  1978.             surface a slice plane that renders          
  1979.             cross sectional views of tilemap data.      
  1980.    
  1981.         ##########################ABOUT_RAY_MARCH_LOOP##
  1982.         #POSITIVE_Z_DIVES_INTO_SCREEN###################
  1983.  
  1984.             Positive Z is further back into screen.
  1985.             This way to help normalize voxel grid math.
  1986.        
  1987.         ###################POSITIVE_Z_DIVES_INTO_SCREEN#
  1988.         #FIND_POINT_ON_SCREEN_PLANE#####################
  1989.  
  1990.             ORIGINAL_COMMENT:
  1991.  
  1992.                 Polygon in 3d space to serve as the
  1993.                 phosphor surface the CRT monitor
  1994.                 electrons will be projected onto.
  1995.                 Could probably use a mat4 for this.
  1996.  
  1997.             MORE_INFORMATION_IN_RETROSPECT:
  1998.  
  1999.                 "Screen Plane" is also known as
  2000.                 "CRT Phospore" or "PHO" for short.
  2001.                 This is a plane put into 3D space that
  2002.                 represents the pixels of the client
  2003.                 viewport (physical monitor).
  2004.  
  2005.                 The "IMAGE" plane from this diagram:
  2006.                 https://tinyurl.com/IMAGE-PLANE
  2007.  
  2008.         #####################FIND_POINT_ON_SCREEN_PLANE#
  2009.         #MODULO_CHECKER_PATTERN#########################
  2010.  
  2011.             // Checker pattern value, 1 or 0.         //
  2012.             // Combine Sets so that they create       //
  2013.             // a checkerboard of odd/even values,     //
  2014.             // and then convert even to 0 and         //
  2015.             // odd to 1.                              //
  2016.             //                                        //
  2017.             // SET_YYY:[ 0 1 0 1 0 1 0 ]              //
  2018.             // SET_XXX:[ 0 1 0 1 0 1 0 ]              //
  2019.             //                                        //
  2020.             // SET_XXX:     [ 0 1 0 1 0 1 0 ]         //
  2021.             //                | | | | | | |           //
  2022.             // SET_YYY:[ 0 ]- 0 1 0 1 0 1 0           //
  2023.             //         [ 1 ]- 1 2 1 2 1 2 1           //
  2024.             //         [ 0 ]- 0 1 0 1 0 1 0           //
  2025.             //         [ 1 ]- 1 2 1 2 1 2 1           //
  2026.             //         [ 0 ]- 0 1 0 1 0 1 0           //
  2027.             //         [ 1 ]- 1 2 1 2 1 2 1           //
  2028.             //         [ 0 ]- 0 1 0 1 0 1 0           //
  2029.             int chk =(  
  2030.                 I32_MOD( // <<<<<<<<<<<<<< SET_003
  2031.                     I32_MOD( T_Y, 2 )   // SET_YYY
  2032.                 +   I32_MOD( T_X, 2 )   // SET_XXX
  2033.                 ,                 2
  2034.                 )
  2035.             );;
  2036.  
  2037.         #########################MODULO_CHECKER_PATTERN#
  2038.         #CONSISTENT_VOXEL_COORDS########################
  2039.  
  2040.             The tilemap math for calculating what
  2041.             [voxel/tile] we are inside of is
  2042.             geometrically consistent, even when
  2043.             given NEGATIVE numbers.
  2044.  
  2045.             Meaning: The FIRST PIXELS of any
  2046.                      [tile/voxel] are in the same
  2047.                      relative position.
  2048.  
  2049.             +-+-----+-+-----+-+-----+-+-----+
  2050.             | | -1  | |  0  | |  +1 | |  +2 |
  2051.             | |     | |     | |     | |     |
  2052.             | +-----| +-----| +-----| +-----+
  2053.             +-------+-------+-------+-------+
  2054.  
  2055.             +-+
  2056.             | |   <--- The first edge of pixels for
  2057.             | |        [voxel/tile] seen on the X/Y
  2058.             | +-----|  axis.
  2059.             +-------+
  2060.         ########################CONSISTENT_VOXEL_COORDS#
  2061.         #NEXT_VOXEL_BOUNDING_VOLUME#####################
  2062.  
  2063.             Assuming vectors are moving in a positive
  2064.             direction, the intersection point to
  2065.             next voxel MUST be within the bounds of
  2066.             the CURRENT VOXEL + One Pixel All Around.
  2067.  
  2068.             Because we know the DIRECTION of the
  2069.             ray vector, we don't need a bounding volume
  2070.             and can just check that the respective
  2071.             X,Y,Z bounding planes have
  2072.             not been exceeded.
  2073.  
  2074.             +--------------------+--------------------+
  2075.             |                    |                    |
  2076.             |   +- - -  - - -+   |   +- - -  - - -+   |
  2077.             |   |            |   |   |            |   |
  2078.             |                    |                    |
  2079.             |   |            |   |   |            |   |
  2080.             |                    |                    |
  2081.             |   |            |   |   |            |   |
  2082.             |   +- - -  - - -+   |   +- - -  - - -+   |
  2083.          111111111111111111111111111                  |
  2084.          1  +--------------------+-1------------------+
  2085.          1  |                    | 1                  |
  2086.          1  |   +- - -  - - -+   | 1 +- - -  - - -+   |
  2087.          1  |   |            |   | 1 |            |   |
  2088.          1  |                    | 1                  |
  2089.          1  |   |     CV     |   | 1 |            |   |
  2090.          1  |     (CurVoxel)     | 1                  |
  2091.          1  |   |            |   | 1 |            |   |
  2092.          1  |   +- - -  - - -+   | 1 +- - -  - - -+   |
  2093.          1  |                    | 1                  |
  2094.          1  +--------------------+-1------------------+
  2095.          111111111111111111111111111
  2096.  
  2097.         #####################NEXT_VOXEL_BOUNDING_VOLUME#
  2098.         #VOX_MAR_ABOUT##################################
  2099.  
  2100.             VOX_MAR: ( VOXel_MARch )
  2101.  
  2102.                     Holds information about ray
  2103.                     marching WITHIN a single voxel.
  2104.  
  2105.         ##################################VOX_MAR_ABOUT#
  2106.         #DISTANCE_IS_NOT_CUMULATIVE#####################
  2107.  
  2108.             WRONG: xyz =  rwC + ( rwN * D_N );
  2109.             RIGHT: xyz =  xyz + ( rwN * D_N );
  2110.  
  2111.             The distance is NOT cumulative. Our ray
  2112.             marching is not anchored to the original
  2113.             ray world coordinate ( rwC ).
  2114.  
  2115.             Reason:
  2116.                 Collision with the first pixel of
  2117.                 the next voxel is PIXEL PERFECT and
  2118.                 if[  D_N  ]were a cumulative distance
  2119.                 over multiple iterations we would
  2120.                 probably see weird artifacts as slight
  2121.                 rounding errors compound.
  2122.  
  2123.                 Thus do NOT anchor to[  rwC  ]but
  2124.                 rather make a new origin location at
  2125.                 [  xyz  ]each loop iteration.
  2126.    
  2127.                 Think: Folds in orgami.
  2128.    
  2129.         #####################DISTANCE_IS_NOT_CUMULATIVE#
  2130.         #DIST_NEXT_NEVER_ZERO###########################
  2131.  
  2132.             Even if you are 1 pixel away from the next
  2133.             voxel, the distance to the next voxel should
  2134.             NEVER be zero. It should always be a
  2135.             POSITIVE NON-ZERO value.
  2136.    
  2137.             If this is NOT the case, your point-normal
  2138.             form ray marching will fail.
  2139.  
  2140.         ###########################DIST_NEXT_NEVER_ZERO#
  2141.         #TRAP_VALUE_MUST_BE_NEG_666#####################
  2142.  
  2143.             Using ( 0.0 - 666.0 ) as a trap value
  2144.             in our code that determines the distance
  2145.             to the next voxel. If you detect (-666.0)
  2146.             in your ray march loop, it means that
  2147.             the distance to the next voxel was never
  2148.             set. Distance to next voxel should ALWAYS
  2149.             be NON-ZERO and POSITIVE.
  2150.  
  2151.         #####################TRAP_VALUE_MUST_BE_NEG_666#
  2152.         #PIXEL_PROBABILITY_CLOUD########################
  2153.  
  2154.             [TODO](MAYBE)
  2155.  
  2156.             We should probably have 1 pixel equal to
  2157.             3 native frag coords. That way if you
  2158.             are in the CENTER of the pixel, you know
  2159.             you don't need to alias. But if you are
  2160.             on one of the boarder edges, you know
  2161.             you need to use some aliasing.
  2162.  
  2163.                [ONE FRAG COORD]
  2164.                      _|_
  2165.                     /   \
  2166.                     +   +     X: CENTER, no aliasing
  2167.                     |   |        required.
  2168.                     V   V
  2169.             +---+---+---+ <--+
  2170.             |   |   |   |     \
  2171.             +---+---+---+      \
  2172.             |   | X |   |       +--[ ONE PIXEL ]
  2173.             +---+---+---+      /
  2174.             |   |   |   |     /
  2175.             +---+---+---+ <--+
  2176.  
  2177.         ########################PIXEL_PROBABILITY_CLOUD#
  2178.         #VOXEL_EDGE_COLOR###############################
  2179.                
  2180.             When percent(per) is zero the edges are    
  2181.             BLACK and blend with background. That is      
  2182.             not very useful for debugging, so lets
  2183.             give the  edges a useful color coding to    
  2184.             identify which planes of the voxel are  
  2185.             intersecting at that edge.    
  2186.  
  2187.  
  2188.             +--.--+--.--+
  2189.             1\     \     \     [X]: X_Plane: RED
  2190.             1 \  --[Z]--  \    [Y]: Y_PLANE: GREEN
  2191.             1  \     \     \   [Z]: Z_PLANE: BLUE
  2192.             1   +--.--+--.--+
  2193.             1[X]2           3   1: Edge 1, YELLOW (R+G)
  2194.             +   2           3   2: Edge 2, YELLOW (R+G)
  2195.              \  2    [Y]    3   3: Edge 3, YELLOW (R+G)
  2196.               \ 2           3
  2197.                \2           3
  2198.                 +--.--+--.--+
  2199.  
  2200.             +--.--+--.--+       4: Edge 4, MAGENTA (R+B)
  2201.             |4     \     \      5: Edge 5, CYAN    (G+B)
  2202.             | 4  --[Z]--  \     6: Edge 6, YELLOW  (R+G)
  2203.             |  4     \     \
  2204.             |   +55555555555+
  2205.             |[X]6           |  (Edge #'s Are Arbitrary)
  2206.             +   6           |  (and do NOT reflect    )
  2207.              \  6    [Y]    |  (values in our code.   )
  2208.               \ 6           |
  2209.                \6           |  (Aritrary as in for    )
  2210.                 +--.--+--.--+  (illustrative purposes.)
  2211.  
  2212.         ###############################VOXEL_EDGE_COLOR#
  2213.         #NO_ELSE_FOR_EDGE_COLORING######################
  2214.  
  2215.             Statement for calculating edge colors
  2216.             should NOT have "else" or "if else"
  2217.             because 2 planes intersect at edges
  2218.             and 3 planes intersect at vertex.
  2219.  
  2220.             THUS: EDGES : 2ndary(secondary) colors.(CMY)
  2221.                   VERTEX: WHITE (R+G+B)
  2222.  
  2223.         ######################NO_ELSE_FOR_EDGE_COLORING#
  2224.         #STRATA_OF_2D_TILEMAPS##########################
  2225.  
  2226.             We abstract the 3D tilemap (voxelmap) data
  2227.             as a series of 2-dimensional tile maps
  2228.             that are stacked on top of each other.
  2229.  
  2230.             Because positive Z moves DOWN INTO THE
  2231.             MONITOR, larger Z-layers go further
  2232.             back into the screen.
  2233.  
  2234.  
  2235.             U32  
  2236.             VAT[ NTX * NTY * NTZ ]= U32[ 8 * 4 * 7 ](  
  2237.  
  2238.             //: Z == 0 === First 2D TileMap
  2239.  
  2240.             //: 1 2 3 4 5 6 7 8        --- -------------
  2241.                 _,_,_,_,_,_,_,_, //: 1  |        ^
  2242.                 _,_,_,_,_,_,_,_, //: 2  | Z == 0 |
  2243.                 _,_,_,_,_,_,_,_, //: 3  |        |
  2244.                 _,_,_,_,_,_,_,_, //: 4  |        |
  2245.             //:                        ---       |
  2246.             //: 1 2 3 4 5 6 7 8        ---       |
  2247.                 _,_,_,_,_,_,_,_, //: 1  | TILEMAP_STRATA
  2248.                 _,_,_,_,_,_,_,_, //: 2  |        |
  2249.                 _,_,_,_,_,_,_,_, //: 3  | Z == 1 |
  2250.                 _,_,_,_,_,_,_,_, //: 4  |        |
  2251.             //:                        ---       |
  2252.             //: 1 2 3 4 5 6 7 8        ---       |
  2253.                 _,_,_,_,_,R,_,_, //: 1  |        |
  2254.                 _,_,_,_,Y,_,_,_, //: 2  | Z == 2 |
  2255.                 _,_,_,M,_,_,_,_, //: 3  |        |
  2256.                 _,_,C,_,_,_,_,_, //: 4  |        V
  2257.             //:                        --- -------------
  2258.  
  2259.             );
  2260.  
  2261.             //: Z == 2 === First 2D TileMap
  2262.  
  2263.         ##########################STRATA_OF_2D_TILEMAPS#
  2264.         #BACK_SLASH_COMMENT_FUCKERY#####################
  2265.  
  2266.             The use of "\" in a comment line seems
  2267.             to be erroneously interpreted as a newline.
  2268.  
  2269.             Example: Below wil NOT compile, even
  2270.                      though it is syntactically correct.
  2271.  
  2272.             U32  
  2273.             VAT[ NTX * NTY * NTZ ]= U32[ 8 * 4 * 1 ](  
  2274.  
  2275.             //: 1 2 3 4 5 6 7 8        
  2276.                 _,_,_,_,_,_,_,_, //: 1 \
  2277.                 _,_,_,_,_,_,_,_, //: 2  \__ Z == 0
  2278.                 _,_,_,_,_,_,_,_, //: 3  /
  2279.                 _,_,_,_,_,_,_,_, //: 4 /  
  2280.  
  2281.             );
  2282.  
  2283.         #####################BACK_SLASH_COMMENT_FUCKERY#
  2284.  
  2285.  
  2286. *** ************************************************ **/
  2287. //:====================================:DOCUMENTATION://
  2288. //:UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU://
  2289. /** U : Undefine Macros Section **/
  2290.  
  2291.     #undef  V_4  
  2292.     #undef  V_3  
  2293.     #undef  V_2  
  2294.     #undef  F32  
  2295.     #undef  I32  
  2296.     #undef  U32  
  2297.  
  2298. /** U : Undefine Macros Section **/
  2299. //:UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU://
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement