Advertisement
DEKTEN

SDF_015

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