Advertisement
DEKTEN

SDF_010

Nov 26th, 2020 (edited)
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /** ************************************************ ***
  2. ***                                                  ***
  3. *** EASY_SOURCE_CODE_LINK: tinyurl.com/SDF-010       ***
  4. *** DIRECT_LINK_TO_SOURCE: pastebin.com/rE8av22k     ***
  5. ***             DEMO_LINK: shadertoy.com/view/WsKBzz ***
  6. ***                                                  ***
  7. *** About: Voxel Rendering For Patent Drawings.      ***
  8. ***        This version is a work in progress.       ***
  9. ***                                                  ***
  10. *** ************************************************ **/
  11. //:MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM://
  12. /** M: Macros Section **/
  13.  
  14.     #define V_4  vec4
  15.     #define V_3  vec3
  16.     #define V_2  vec2
  17.     #define F32 float
  18.     #define I32   int
  19.  
  20. /** M: Macros Section **/
  21. //:MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM://
  22. //:DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD://
  23. /** D: Data Section **/
  24.  
  25.     //:DEBUGGING:====================================://
  26.  
  27.         /** Nothing here yet **/
  28.  
  29.     //:====================================:DEBUGGING://
  30.     //:CONFIGURATION:================================://
  31.  
  32.         /** SLICE_RENDER_USING_CAMERA_PLANE **/
  33.         int CFG_SLICE_RENDER=( 1 );
  34.  
  35.     //:================================:CONFIGURATION://
  36.     //:RAYMARCHING_AND_VOXEL_CONSTANTS:==============://
  37.  
  38.         //:These defines are for ray marching when using
  39.         //:fragment coordinates as our coordinate space.
  40.         #define MAX_STE 1000   //:Max Step
  41.         #define MIN_DIS 0.02   //:Min Dist (SurfaceDist)
  42.         #define MAX_DIS 1000.0 //:Max Dist
  43.  
  44.         //:Number of tiles on each axis:
  45.         #define NTX  8  //:Num_Tiles (   in_voxel_map )
  46.         #define NTY  4  //:Num_Tiles (   in_voxel_map )
  47.         #define NTZ  3  //:Num_Tiles (   in_voxel_map )
  48.  
  49.         //:Size_Of_A_Voxel_Tile_Measured_In_Pixels:
  50.         #define NPX  16 //:Num_Pixels_X( in_a_tile    )
  51.         #define NPY  16 //:Num_Pixels_Y( in_a_tile    )
  52.         #define NPZ  16 //:Num_Pixels_Z( in_a_tile    )
  53.  
  54.         //:Total__number_of__Pixels__in_entire_voxel_map
  55.         #define TPX  ( NTX * NPX ) //: Total_Pixels_X
  56.         #define TPY  ( NTY * NPY ) //: Total_Pixels_Y
  57.         #define TPZ  ( NTZ * NPZ ) //: Total_Pixels_Z
  58.  
  59.         #define _ 0                                          
  60.         #define X 1                                          
  61.         int VAT[ NTX * NTY * NTZ ]=int[ 8 * 4 * 3 ](  
  62.  
  63.         /** TODO: Eventually use an integer texture  **/
  64.         /**       for this tilemap data.             **/
  65.            
  66.         //:Highest Z Cross Section Is First Tile Map
  67.         //: 1 2 3 4 5 6 7 8        --- -----------------
  68.             X,X,X,X,X,X,X,X, //: 1  |             ^
  69.             X,_,_,_,_,_,_,X, //: 2  | Z == 0      |
  70.             X,_,_,_,_,_,_,X, //: 3  |             |
  71.             X,X,X,X,X,X,X,X, //: 4  |             |
  72.         //:                        ---            |
  73.         //: 1 2 3 4 5 6 7 8        ---   Cross Sections
  74.             X,_,_,_,_,_,_,X, //: 1  |    Can be thought
  75.             _,_,_,_,_,_,_,_, //: 2  |    of as differ-
  76.             _,_,_,_,_,_,_,_, //: 3  |    -ent 2D
  77.             X,_,_,_,_,_,_,X, //: 4  |    tilemaps.
  78.         //:                        ---            |
  79.         //: 1 2 3 4 5 6 7 8        ---            |
  80.             X,_,_,_,_,_,_,X, //: 1  |             |
  81.             X,_,_,_,_,_,_,X, //: 2  | Z == 2      |
  82.             X,_,_,_,_,_,_,X, //: 3  |             |
  83.             X,_,_,_,_,_,_,X  //: 4  |             V
  84.         //:                        --- -----------------
  85.         );                                                
  86.         #undef  _                                            
  87.         #undef  X  
  88.  
  89.     //:==============:RAYMARCHING_AND_VOXEL_CONSTANTS://
  90.     //:STRUCTS:======================================://
  91.  
  92.         //:RWC_AND_RWN:------------------------------://
  93.  
  94.             struct  RWC_AND_RWN{
  95.                 V_3 rwC        ;
  96.                 V_3         rwN;
  97.             };
  98.        
  99.         //:------------------------------:RWC_AND_RWN://
  100.         //:VOX_000:------------------------------://
  101.  
  102.             /** Current Voxel Information **/
  103.             struct VOC{   //:VOC: VOX_CUR (VoxelCurrent)
  104.                uint has;  //: voxel:exists?
  105.                 int val;  //: voxel:tile_value
  106.                 int dex;  //: voxel:1d_index
  107.                 int t_x;  //: voxel:tile_x
  108.                 int t_y;  //: voxel:tile_y
  109.                 int t_z;  //: voxel:tile_z
  110.             };
  111.  
  112.             /** Distance Information **/
  113.             struct VOD{ //:VOD: VOX_DIS (VoxelDistance)
  114.                 F32 nex; //:Distance_To_Next
  115.             //  F32 d_S; //:Distance_To_Surface
  116.             //           //:Within_Current_Voxel
  117.             };
  118.  
  119.             struct VOX_000{
  120.            
  121.                 VOC  vox_cur; //:Voxel_Current_Info
  122.  
  123.                 VOD  vox_dis; //:Voxel_Distance_Info
  124.            
  125.             };
  126.  
  127.         //:------------------------------:VOX_000://
  128.  
  129.     //:======================================:STRUCTS://
  130.  
  131. /** D: Data Section **/
  132. //:DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD://
  133. //:IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII://
  134. /** I: Inifnite Degree Functions. Always At Top.     **/
  135.  
  136.     //:NO_HALT_USE_ERROR_PIXEL:======================://
  137.     //:PIX_ERR:======================================://
  138.  
  139.         #define ERR_001  1  /** msg_err # 1 **/
  140.         #define ERR_002  2  /** msg_err # 2 **/
  141.  
  142.         V_4     PIX_ERR(
  143.             int msg_err /** EX: MSG_ERR_001 **/
  144.         ,   V_4 pix_err /** Previous Pixel Error **/
  145.         ,   int   o_k
  146.         )
  147.         {
  148.             /** Muddy Pastel Yellow For When You     **/
  149.             /** forget to set the pix_err_out value. **/
  150.             V_4 pix_err_out=V_4(0.5,0.5,0.2,1);
  151.  
  152.             float flux=( mod(iTime,1.0) );
  153.  
  154.             //:COLOR_PICKER_DEBUG_HEX:---------------://
  155.        
  156.             /** Make it easy to find source of error **/
  157.             /** in code by using color picker on     **/
  158.             /** shader output and then doing a       **/
  159.             /** CTRL+F with that hex code to find    **/
  160.             /** the offending source code.           **/
  161.  
  162.                 F32 _ =F32( 0.0    );
  163.                 F32 MAX =F32( 255.0  ); // MaxIntensity
  164.                 F32  A  =F32( 1.0    ); // Alpha_Max
  165.  
  166.                 //:ERROR_CODE_STROBE_COLORS:---------://
  167.  
  168.                 F32 _01_ =( F32(0x01) / MAX );
  169.                 F32 _10_ =( F32(0x10) / MAX );
  170.                 //
  171.                 F32 _02_ =( F32(0x02) / MAX );
  172.                 F32 _20_ =( F32(0x20) / MAX );
  173.                 //
  174.                 F32 _03_ =( F32(0x03) / MAX );
  175.                 F32 _30_ =( F32(0x30) / MAX );
  176.                 //
  177.                 F32 _04_ =( F32(0x04) / MAX );
  178.                 F32 _40_ =( F32(0x40) / MAX );
  179.                 //
  180.                 F32 _05_ =( F32(0x05) / MAX );
  181.                 F32 _50_ =( F32(0x50) / MAX );
  182.                 //
  183.                 F32 _06_ =( F32(0x06) / MAX );
  184.                 F32 _60_ =( F32(0x60) / MAX );
  185.                 //
  186.                 F32 _07_ =( F32(0x07) / MAX );
  187.                 F32 _70_ =( F32(0x70) / MAX );
  188.                 //
  189.                 F32 _08_ =( F32(0x08) / MAX );
  190.                 F32 _80_ =( F32(0x80) / MAX );
  191.                 //
  192.                 F32 _09_ =( F32(0x09) / MAX );
  193.                 F32 _90_ =( F32(0x90) / MAX );
  194.  
  195.                 V_4 _0x010101_ = V_4(_01_,_01_,_01_, A);
  196.                 V_4 _0x101010_ = V_4(_10_,_10_,_10_, A);
  197.  
  198.                 V_4 _0x020202_ = V_4(_02_,_02_,_02_, A);
  199.                 V_4 _0x202020_ = V_4(_20_,_20_,_20_, A);
  200.  
  201.                 V_4 _0x030303_ = V_4(_03_,_03_,_03_, A);
  202.                 V_4 _0x303030_ = V_4(_30_,_30_,_30_, A);
  203.  
  204.                 V_4 _0x040404_ = V_4(_04_,_04_,_04_, A);
  205.                 V_4 _0x404040_ = V_4(_40_,_40_,_40_, A);
  206.  
  207.                 V_4 _0x050505_ = V_4(_05_,_05_,_05_, A);
  208.                 V_4 _0x505050_ = V_4(_50_,_50_,_50_, A);
  209.  
  210.                 V_4 _0x060606_ = V_4(_06_,_06_,_06_, A);
  211.                 V_4 _0x606060_ = V_4(_60_,_60_,_60_, A);
  212.  
  213.                 V_4 _0x070707_ = V_4(_07_,_07_,_07_, A);
  214.                 V_4 _0x707070_ = V_4(_70_,_70_,_70_, A);
  215.  
  216.                 V_4 _0x080808_ = V_4(_08_,_08_,_08_, A);
  217.                 V_4 _0x808080_ = V_4(_80_,_80_,_80_, A);
  218.  
  219.                 V_4 _0x090909_ = V_4(_09_,_09_,_09_, A);
  220.                 V_4 _0x909090_ = V_4(_90_,_90_,_90_, A);
  221.  
  222.                 //:---------:ERROR_CODE_STROBE_COLORS://
  223.                 //:ERROR_ZERO_COLORS:----------------://
  224.                 #define F float
  225.                 #define V vec4
  226.                 /** If you forget to set error code, **/
  227.                 /** you will see flashing red and    **/
  228.                 /** blue. ( _0xFF0666_ & _0x6660FF_ )**/
  229.                  
  230.                 F   _FF_=( F32(0xFF) / MAX );
  231.                 //  _06_=( F32(0x06) / MAX );
  232.                 //  _60_=( F32(0x60) / MAX );
  233.                 F   _66_=( F32(0x66) / MAX );
  234.                 V   _0xFF0666_ =V_4(_FF_,_06_,_66_,A);
  235.                 V   _0x6660FF_ =V_4(_66_,_60_,_FF_,A);
  236.  
  237.                 #undef F
  238.                 #undef V
  239.                 //:----------------:ERROR_ZERO_COLORS://
  240.                 //:BAD_OK_ERROR_COLOR:---------------://
  241.                 #define F float
  242.                 #define V vec4
  243.                 /** You will see this if you init    **/
  244.                 /** o_k to a value other than 1 in   **/
  245.                 /** your source code.                **/
  246.                 /** Strobes between orange and lime. **/
  247.                 /** ( _0xFF7700_ & _0x77FF00_ )      **/
  248.                  
  249.                 //  _FF_=( F32(0xFF) / MAX );
  250.                 F   _77_=( F32(0x77) / MAX );
  251.                 F   _00_=( F32(0x00) / MAX );
  252.                 V   _0xFF7700_ =V_4(_FF_,_77_,_00_,A);
  253.                 V   _0x77FF00_ =V_4(_77_,_FF_,_00_,A);
  254.  
  255.                 #undef F
  256.                 #undef V
  257.                 //:---------------:BAD_OK_ERROR_COLOR://
  258.  
  259.             //:---------------:COLOR_PICKER_DEBUG_HEX://
  260.  
  261.             if( o_k <= 0 ){
  262.                 pix_err_out = pix_err;
  263.             }else
  264.             if( 1 == o_k ){
  265.  
  266.                 /** table of error "messages" #0 **/
  267.                 V_4 tab_err_000[10]=V_4[10](        
  268.                                                
  269.                     // 0: Invalid Error Code    
  270.                     _0xFF0666_  // RED_FLASH
  271.                          
  272.                     // Odd Frame Error Colors:
  273.                 ,   _0x010101_  //  ERR_001 : ODD_FRAME
  274.                 ,   _0x020202_  //  ERR_002 : ODD_FRAME
  275.                 ,   _0x030303_  //  ERR_003 : ODD_FRAME
  276.                 ,   _0x040404_  //  ERR_004 : ODD_FRAME
  277.                 ,   _0x050505_  //  ERR_005 : ODD_FRAME
  278.                 ,   _0x060606_  //  ERR_006 : ODD_FRAME
  279.                 ,   _0x070707_  //  ERR_007 : ODD_FRAME
  280.                 ,   _0x080808_  //  ERR_008 : ODD_FRAME
  281.                 ,   _0x090909_  //  ERR_009 : ODD_FRAME
  282.                 );;        
  283.                 /** table of error "messages" #1 **/
  284.                 V_4 tab_err_001[10]=V_4[10](        
  285.                                                
  286.                     // 0: Invalid Error Code    
  287.                     _0x6660FF_ // BLUE_FLASH    
  288.                          
  289.                     // Even Frame Error Colors:
  290.                 ,   _0x101010_  //  ERR_001 : EVE_FRAME
  291.                 ,   _0x202020_  //  ERR_002 : EVE_FRAME
  292.                 ,   _0x303030_  //  ERR_003 : EVE_FRAME
  293.                 ,   _0x404040_  //  ERR_004 : EVE_FRAME
  294.                 ,   _0x505050_  //  ERR_005 : EVE_FRAME
  295.                 ,   _0x606060_  //  ERR_006 : EVE_FRAME
  296.                 ,   _0x707070_  //  ERR_007 : EVE_FRAME
  297.                 ,   _0x808080_  //  ERR_008 : EVE_FRAME
  298.                 ,   _0x909090_  //  ERR_009 : EVE_FRAME
  299.                 );;                      
  300.  
  301.                 if( mod(iTime*16.0,2.0) < 1.0 ){
  302.                     pix_err_out =( tab_err_000
  303.                                  [ msg_err ] );;
  304.                 }else{
  305.                     pix_err_out =( tab_err_001
  306.                                  [ msg_err ] );;
  307.                 };;
  308.  
  309.             }else{
  310.                 /** Orange strobe for an o_k value   **/
  311.                 /** that is NOT expected. (o_k >= 2) **/
  312.  
  313.                 if( mod(iTime*2.0,2.0) < 1.0 ){
  314.                     pix_err_out = _0xFF7700_; // ORANGE
  315.                 }else{
  316.                     pix_err_out = _0x77FF00_; // LIME
  317.                 };;
  318.  
  319.             };;
  320.                
  321.             return( pix_err_out );
  322.         }
  323.  
  324.     //:======================================:PIX_ERR://
  325.     //:======================:NO_HALT_USE_ERROR_PIXEL://
  326.  
  327. /** I: Inifnite Degree Functions. Always At Top.     **/
  328. //:IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII://
  329. //:22222222222222222222222222222222222222222222222222://
  330.  
  331.     //:INTERPOLATION_3D:=============================://
  332.     //:sfd_i3d:======================================://
  333.  
  334.         V_3 sdf_i3d(
  335.         /**/V_3 _1_
  336.         ,   V_3 _2_
  337.         ,   F32 f_p
  338.         ){
  339.             return( _1_ + ( ( _2_ - _1_ )*f_p ) );
  340.         }
  341.  
  342.     //:=============================:INTERPOLATION_3D://
  343.     //:======================================:sfd_i3d://
  344.     //:FIRST_VOXEL_QUERY_NEEDED:=====================://
  345.  
  346.         #define T_X vox_000.vox_cur.t_x
  347.         #define T_Y vox_000.vox_cur.t_y
  348.         #define T_Z vox_000.vox_cur.t_z
  349.  
  350.         /** rwN used to find distance to NEXT voxel. **/
  351.             VOX_000
  352.         GET_vox_000_USE_xyz_rwN(
  353.                         V_3 xyz
  354.                     ,   V_3     rwN
  355.         )
  356.         {
  357.  
  358.             VOX_000 vox_000;
  359.  
  360.             //:CURRENT_VOXEL_CELL:-------------------://
  361.  
  362.             vox_000.vox_cur.val = int( 0 - 1 );
  363.             T_X = ( int(floor( xyz.x / float( NPX ))));
  364.             T_Y = ( int(floor( xyz.y / float( NPY ))));
  365.             T_Z = ( int(floor( xyz.z / float( NPZ ))));
  366.  
  367.             //:-------------------:CURRENT_VOXEL_CELL://
  368.             //:GET_VOXEL_CELL_VALUE:-----------------://
  369.  
  370.             /** Voxel Volume Is Hard Coded To have   **/
  371.             /** voxel__tile[0,0,0] stuck at world    **/
  372.             /** world_coord[0,0,0]                   **/
  373.             if( T_X >= 0 && T_X < NTX
  374.             &&  T_Y >= 0 && T_Y < NTY
  375.             &&  T_Z >= 0 && T_Z < NTZ
  376.             ){
  377.  
  378.                 //: Index2D -and- Index3D
  379.                 int D2D = T_X + ( NTX    *    T_Y );
  380.                 int D3D = D2D + ( NTX * NTY * T_Z );
  381.  
  382.                 vox_000.vox_cur.dex=(      D3D   );
  383.                 vox_000.vox_cur.val=( VAT[ D3D ] );
  384.  
  385.                 /** NOTE: Voxel value 0 will NOT get **/
  386.                 /**       special treatment. It could**/
  387.                 /**       contain geometry if we     **/
  388.                 /**       really wanted it to.       **/
  389.                 vox_000.vox_cur.has=uint(  1  );
  390.                
  391.             }else{
  392.                 /** Using a "has" flag so we         **/
  393.                 /** can keep more logic UNSIGNED.    **/
  394.                 /** (No need for negative value to ) **/
  395.                 /** (be used for invalid dex or val) **/
  396.                 vox_000.vox_cur.dex= int(  0  );
  397.                 vox_000.vox_cur.val= int(  0  );
  398.                 vox_000.vox_cur.has=uint(  0  );
  399.             };;
  400.             //:-----------------:GET_VOXEL_CELL_VALUE://
  401.  
  402.  
  403.             //:TODO: Figure out distance to the NEXT voxel.
  404.  
  405.          
  406.             return( vox_000 );
  407.         }
  408.         #undef  T_X
  409.         #undef  T_Y
  410.         #undef  T_Z
  411.     //:=====================:FIRST_VOXEL_QUERY_NEEDED://
  412.     //:INTEGER_MODULO:===============================://
  413.  
  414.     #ifndef I32
  415.     #define I32 int
  416.     #endif
  417.  
  418.         /** PRIVATE: Called only by I32_MOD **/
  419.         I32 i32_mod_neg( I32 neg_a , I32 pos_d ){
  420.  
  421.             /** ************************************ ***
  422.             Function Calculates:
  423.            
  424.             FIXED: (d-1)-[ mod(abs(a)+1 , d) ]
  425.  
  426.             GOAL: Negatives keep exact same tiling
  427.                   pattern as the positives.
  428.  
  429.             IN : -6 -5 -4 -3 -2 -1  0 +1 +2 +3 +4 +5 +6
  430.             OUT:  2  3  0  1  2  3  0  1  2  3  0  1  2
  431.  
  432.             0123 -> 0123 -> 0123 -> 0123 -> 0123 -> ect
  433.  
  434.            
  435.  
  436.             *** ************************************ **/
  437.  
  438.                 I32 pos_a = ( 0 - neg_a ) + 1;
  439.                
  440.                 F32 A = F32( pos_a );
  441.                 F32 D = F32( pos_d );
  442.                
  443.                 //: GLSL_MODULUS_WITH_INTEGERS_FORMULA
  444.                 //: WARD:Wholepart,All,Remainder,Divisor
  445.                 int W = int(  trunc( A / (          D  )) );
  446.                 int R = int(         A - ( F32(W) * D  )  );
  447.                
  448.                 return( (pos_d-1) - R );
  449.  
  450.         ///   I32 pos_a = 0 - neg_a; //:make "a" positive.
  451.         ///  
  452.         ///   F32 A = F32( pos_a );
  453.         ///   F32 D = F32( pos_d );
  454.         ///  
  455.         ///   //: GLSL_MODULUS_WITH_INTEGERS_FORMULA
  456.         ///   //: WARD:Wholepart,All,Remainder,Divisor
  457.         ///   int W = int(  trunc( A / (          D  )) );
  458.         ///   int R = int(         A - ( F32(W) * D  )  );
  459.         ///
  460.         ///   return( pos_d - R );
  461.  
  462.         }
  463.  
  464.         I32
  465.         I32_MOD(
  466.         /**/I32 a /** ALL     : CAN BE NEGATIVE **/
  467.         ,   I32 d /** DIVISOR : ALWAYS POSITIVE **/
  468.         ){
  469.  
  470.             /** ************************************ ***
  471.  
  472.             Allow for I32_MOD to be used for wrapping
  473.             even when the input to wrap[ a ] goes
  474.             negative. d should always be positive.
  475.  
  476.             EX: mod( x , 2 ) , where x == -1
  477.             | -1 | 0 [ 1 ] 2 |
  478.             |  1 | 0 [ 1 ] 0 | 1 | 0 |
  479.             d + 1 == 2 + (-1) == 1
  480.             *** ************************************ **/
  481.            //
  482.  
  483.             int R;
  484.  
  485.  
  486.             if( a < 0 ){
  487.  
  488.                 //:This is CLOSE but then new problem
  489.                 //:of lots of green checkers is showing
  490.                 //:up. No clue...
  491.                 R = i32_mod_neg( a , d );
  492.  
  493.             ////    a = d + a;
  494.             ////    
  495.             ////    F32 A = F32( a );
  496.             ////    F32 D = F32( d );
  497.             ////    
  498.             ////    //: WARD:Wholepart,All,Remainder,Divisor
  499.             ////    int W = int(  trunc( A / (          D  )) );
  500.             ////        R = int(         A - ( F32(W) * D  )  );
  501.  
  502.             }else{
  503.  
  504.                 F32 A = F32( a );
  505.                 F32 D = F32( d );
  506.  
  507.                 //: GLSL_MODULUS_WITH_INTEGERS_FORMULA
  508.                 //: WARD:Wholepart,All,Remainder,Divisor
  509.                 int W = int(  trunc( A / (          D  )) );
  510.                     R = int(         A - ( F32(W) * D  )  );
  511.  
  512.             };;
  513.            
  514.             #ifndef F32
  515.             #define F32 float
  516.             #endif
  517.  
  518.  
  519.  
  520.             //:EXAMPLE: I32_MOD( 9,2 )
  521.             //:         W == 4
  522.             //:         R == 1    (9 - ( 4 * 2 ) )
  523.  
  524.  
  525.  
  526.             return( R );
  527.         }
  528.     //:===============================:INTEGER_MODULO://
  529.  
  530. //:22222222222222222222222222222222222222222222222222://
  531. //:11111111111111111111111111111111111111111111111111://
  532.  
  533.     //:FRAGCOORD_TO_FRAGPERCENT:=====================://
  534.     //:f_c_CTO_f_p:==================================://
  535.  
  536.         V_2 f_c_CTO_f_p( V_2 f_c ){
  537.         V_2         f_p;
  538.             f_p = f_c / ( iResolution.xy - 1.0 );
  539.             return(  f_p );
  540.         }
  541.  
  542.     //:==================================:f_c_CTO_f_p://
  543.     //:=====================:FRAGCOORD_TO_FRAGPERCENT://
  544.     //:FRAGPER_TO_CAMERA_RAY:========================://
  545.     //:f_p_CTO_rwC_AND_rwN:==========================://
  546.     #define _0_  (0.0)
  547.     #define  _   (0.0)
  548.  
  549.                 RWC_AND_RWN
  550.         f_p_CTO_rwC_AND_rwN(
  551.             V_2 f_p /** 2 dimensional percentage **/
  552.         )
  553.         {
  554.             V_3 rwC; //:ray_word__COORDINATE
  555.             V_3 rwN; //:ray_world_NORMAL____
  556.  
  557.             //:#FIND_POINT_ON_SCREEN_PLANE#
  558.             /** ************************************ ***
  559.             Could possibly use these as slice planes.
  560.             But for now using these to navigate our
  561.             voxel map bounds.
  562.  
  563.             [ A ]Is_Directly_Above[ E ]On_Z_Axis
  564.             [ B ]Is_Directly_Above[ F ]On_Z_Axis
  565.             [ C ]Is_Directly_Above[ G ]On_Z_Axis
  566.             [ D ]Is_Directly_Above[ H ]On_Z_Axis
  567.            
  568.                         (In World/Frag Coords)
  569.                             [0,0,0]
  570.                                 \
  571.                 A_B              \
  572.             A----|------B  A -->  +=======+  <-- B
  573.             |    |      |        /.       .\
  574.             | rwC_001   |       / .       . \
  575.             |    |      |      /  .       .  \
  576.             C----|------D  C->+===============+<-D
  577.                 C_D           [   ._....._.   ]
  578.                               [  /         \  ]
  579.                               [ .           . ]
  580.                               [/             \]
  581.                               +===============+<-H
  582.  
  583.                               +===============+  
  584.                               [\             /]
  585.                               [ .           . ]
  586.                               [  \_......._/  ]
  587.                 E_F           [   .       .   ]
  588.             E----|------F  G->+===============+<-H
  589.             |    |      |      \  .       .  /
  590.             | rwC_002   |       \ .       . /
  591.             |    |      |        \.       ./
  592.             G----|------H  E -->  +=======+  <-- F
  593.                 G_H          
  594.                            
  595.             *** ************************************ **/
  596.  
  597.             //:Dimensions Of Voxel Volume:
  598.             //:As maximum indexes.
  599.             F32 M_X =( F32(TPX) - 1.0 );
  600.             F32 M_Y =( F32(TPY) - 1.0 );
  601.             F32 M_Z =( F32(TPZ) - 1.0 );
  602.  
  603.             //:TOP LAYER OF PIXELS OF VOXEL VOLUME:
  604.             //:(INCLUSIVE MATH. We are inside the)
  605.             //:(first layer of pixels of the first)
  606.             //:(layer of voxels)
  607.             V_3 _A_ = V_3( _-_ , _-_ , _-_ );
  608.             V_3 _B_ = V_3( M_X , _-_ , _-_ );      
  609.             V_3 _C_ = V_3( _-_ , M_Y , _-_ );
  610.             V_3 _D_ = V_3( M_X , M_Y , _-_ );
  611.  
  612.             //:BOTTOM LAYER OF PIXELS OF VOXEL VOLUME
  613.             //:(Incluseive Math. We are inside the )
  614.             //:(last layer of pixels of the last   )
  615.             //:(layer of voxels.                   )
  616.             V_3 _E_ = V_3( _-_ , _-_ , M_Z );
  617.             V_3 _F_ = V_3( M_X , _-_ , M_Z );      
  618.             V_3 _G_ = V_3( _-_ , M_Y , M_Z );
  619.             V_3 _H_ = V_3( M_X , M_Y , M_Z );
  620.  
  621.             /** ************************************ ***
  622.             Take our plane and pretend it is
  623.             the top of a cube that we want to
  624.             get plane in an isometric position to.
  625.             Where the new plane tangents corner _D_
  626.            
  627.            
  628.                    A------_B_            vec_D_B
  629.                   /|       \\                  \
  630.                  / |       |\\                  \
  631.                 /  |       | \\      vec_D_C <---D
  632.               _C_============_D_                 ^
  633.                |   |_ _ _ _|  ||                 |
  634.                |  /E       F\ ||            vec_H_D
  635.                | /           \||
  636.                |/             ||     Corner_Vector:
  637.                G-------------_H_  
  638.             *** *** * * * * * * **** * * * * * * *** **/
  639.  
  640.             /** Edge Vectors **/
  641.  
  642.             V_3 vec_C_D = normalize( _D_ - _C_ );
  643.             V_3 vec_D_C = normalize( _C_ - _D_ );
  644.             V_3 vec_D_B = normalize( _B_ - _D_ );
  645.             V_3 vec_H_D = normalize( _D_ - _H_ );
  646.             V_3 vec_D_H = normalize( _H_ - _D_ );
  647.  
  648.             /** *** * * * * * * **** * * * * * * *** ***
  649.             Use Corner_Vector to calculate a 3/4        
  650.             perspective plane that tangents _D_.
  651.             *** ************************************ **/
  652.             /** ************************************ ***
  653.    
  654.             X axis vector is pretty easy because the
  655.             camera X axis does not move in the Z
  656.             direction.
  657.                     ^         /
  658.                     |       /    ^
  659.             A-------B     /      |    a_x Is Average
  660.             |       |   /        |  
  661.             |       | /     vec_D_B
  662.             C-------D-->    vec_C_D ----->
  663.                   /
  664.                 /
  665.               /<-- goal is THIS line for X-axis.(a_x)
  666.             /
  667.             *** *** * * * * * * **** * * * * * * *** **/
  668.             #define _X_ vec_C_D
  669.             #define _Y_ vec_D_B
  670.             V_3 a_x =normalize(
  671.  
  672.                 /** 45 degree line on XY plane **/
  673.                 ( _X_ + _Y_ ) / 2.0  
  674.  
  675.             );;
  676.             #undef  _X_
  677.             #undef  _Y_
  678.             /** *** * * * * * * **** * * * * * * *** ***
  679.            
  680.             Y axis vector is a bit tricky because it
  681.             moves on all axis(es). XYZ.
  682.  
  683.             +--B  If we average vec_D_C & vec_D_B
  684.             |\ |  To get a 45 degree on the XY plane,
  685.             | \|  we can then tilt that vector up
  686.             C--D  by 45 degrees by averaging it
  687.                |  with vec_H_D
  688.                |
  689.                H
  690.  
  691.             *** ************************************ **/
  692.  
  693.             //: a_y: Axis_Y
  694.             #define _X_ vec_D_C
  695.             #define _Y_ vec_D_B
  696.             #define _Z_ vec_H_D
  697.             V_3 a_y =normalize(
  698.  
  699.                 (
  700.                     normalize( (_X_ + _Y_)/2.0 )
  701.                     +        (     _Z_         )
  702.                 ) /2.0
  703.             );;
  704.             #undef  _X_
  705.             #undef  _Y_
  706.             #undef  _Z_
  707.  
  708.            
  709.             /** Looking into the voxel volume from   **/
  710.             /** a 3/4 isometric direction.           **/
  711.             V_3 a_z = normalize(
  712.                 ( vec_D_C + vec_D_B + vec_D_H ) / 3.0
  713.             );;
  714.  
  715.             /** ************************************ ***
  716.  
  717.             We can now use point-normal form to
  718.             build our camera polygon. We will start
  719.             from point _D_ and walk HALFWAY the
  720.             WIDTH in both directions on our altered
  721.             x-axis vector( a_x ) and HALFWAY the
  722.             HEIGHT in both directions on our altered
  723.             y-axis vector( a_y ).
  724.  
  725.             HEIGHT: The height of our camera plane.
  726.              WIDTH: The width  of our camera plane.
  727.  
  728.                       P_X                   +---+
  729.                 +------+------+             |   |
  730.                 |      |      |         +---+---+
  731.             N_Y +---- _D_ ----+ P_Y     |_D_|
  732.                 |      |      |     +---+---+
  733.                 +------+------+     |   |#DIA_CAMCENTER#
  734.                       N_X           +---+
  735.  
  736.                 #CAMCENTER#:
  737.                 In order for the camera to be 100%
  738.                 centered, it may be necessary to
  739.                 squash or stretch the camera by 1
  740.                 pixel IF the camera is NOT an odd
  741.                 number of pixels on that axis.
  742.                 SEE_DIAGRAM[ #DIA_CAMCENTER# ]
  743.  
  744.                     +0 +1 +2 +2.5       +0 +1 +2 +3  
  745.                     [D]   [+]           ||     [+]    
  746.                 [ ][ ][ ][ ][ ]   [ ][ ][ ][ ][ ][ ]  
  747.                 |<---- 5 ---->|   |<------ 6 ----->|  
  748.  
  749.             *** ************************************ **/
  750.  
  751.             #define ZOOMED_IN_CAMERA_2020_11_26 ( 1 )
  752.             float H_W ;
  753.             float H_H ;
  754.             if( ZOOMED_IN_CAMERA_2020_11_26 >= 1 ){
  755.    
  756.                 /** Camera surface smaller than      **/
  757.                 /** client viewport means zoomed in  **/
  758.                 H_W = ( F32(TPX) / 2.0 );
  759.                 H_H = ( F32(TPY) / 2.0 );
  760.  
  761.             }else
  762.             if( ZOOMED_IN_CAMERA_2020_11_26 <= 0 ){
  763.  
  764.                 /** Camera surface exactly same size **/
  765.                 /** as client viewport means no zoom.**/
  766.                 H_W = ( iResolution.x / 2.0 );
  767.                 H_H = ( iResolution.y / 2.0 );
  768.  
  769.             };;
  770.             #undef  ZOOMED_IN_CAMERA_2020_11_26
  771.  
  772.             /** To be pixel-perfect, floor and ceil  **/
  773.             /** need to be used. This is an OCD      **/
  774.             /** optimization that can probably       **/
  775.             /** be removed without noticable         **/
  776.             /** difference in the result.            **/
  777.             //- P_X = floor( _D_ + ( a_x * H_W ) );  -//
  778.             //- N_X =  ceil( _D_ - ( a_x * H_W ) );  -//
  779.             //- P_Y = floor( _D_ + ( a_y * H_H ) );  -//
  780.             //- N_Y =  ceil( _D_ - ( a_y * H_H ) );  -//
  781.             //+ We can't do it this way, because the +//
  782.             //+ plane is not aligned with our native +//
  783.             //+ XYZ axis.                            +//
  784.             //+ What I mean is we can't get the top  +//
  785.             //+ left corner by saying:               +//
  786.             //+ vec3( N_Y.x , P_X.y , _D_.z )        +//
  787.             /** ************************************ ***
  788.             RASTER_GRAPHICS_STYLE_TOP_LEFT_ORIGIN
  789.                \
  790.                 +----------- +X ------------>
  791.                 |    
  792.                 |     _I_              _J_
  793.                 |       \      P_X      /  
  794.                 |        +------+------+        ^
  795.                 |        |      |      |        |
  796.                +Y    N_Y +---- _D_ ----+ P_Y [ -y ]
  797.                 |        |      |      |        |
  798.                 |        +------+------+        |
  799.                 |       /      N_X      \       |
  800.                 V     _K_               _L_     |
  801.                                                 |
  802.                     <---------[ -x ]------------+
  803.  
  804.             *** *** * * * * * * **** * * * * * * *** **/
  805.    
  806.             V_3 _I_ = _D_  - ( a_x * H_W )
  807.                            - ( a_y * H_H ) ;;
  808.  
  809.             V_3 _J_ = _D_  + ( a_x * H_W )
  810.                            - ( a_y * H_H ) ;;
  811.  
  812.             V_3 _K_ = _D_  - ( a_x * H_W )
  813.                            + ( a_y * H_H ) ;;
  814.  
  815.             V_3 _L_ = _D_  + ( a_x * H_W )
  816.                            + ( a_y * H_H ) ;;
  817.                    
  818.             /** ************************************ **/
  819.             #define USE_ANIMATED_DOLLY_FOR_DEBUG  ( 1 )
  820.             if(     USE_ANIMATED_DOLLY_FOR_DEBUG >= 1 ){
  821.  
  822.                 F32 max_dolly =max(
  823.                             F32(TPX)
  824.                 ,
  825.                         max(
  826.                             F32(TPY)
  827.                             ,
  828.                             F32(TPZ)
  829.                         )
  830.                 );;
  831.  
  832.                 F32 dolly_amount =(
  833.                     cos( iTime ) * max_dolly
  834.                 );;
  835.                
  836.                 _I_ += ( a_z * dolly_amount );
  837.                 _J_ += ( a_z * dolly_amount );
  838.                 _K_ += ( a_z * dolly_amount );
  839.                 _L_ += ( a_z * dolly_amount );
  840.  
  841.             };;
  842.             #undef  USE_ANIMATED_DOLLY_FOR_DEBUG
  843.            
  844.             V_3 I_J = sdf_i3d( _I_ , _J_ , f_p.x );
  845.             V_3 K_L = sdf_i3d( _K_ , _L_ , f_p.x );
  846.                 rwC = sdf_i3d( I_J , K_L , f_p.y );
  847.  
  848.                 //:#POSITIVE_Z_DIVES_INTO_SCREEN#://
  849.                 rwN = normalize( a_z );
  850.  
  851.                     RWC_AND_RWN
  852.                     rwC_AND_rwN;
  853.                     rwC_AND_rwN.rwC = rwC;
  854.                     rwC_AND_rwN.rwN = rwN;
  855.             return( rwC_AND_rwN );
  856.         }
  857.  
  858.     #undef  _0_
  859.     #undef   _
  860.     //:==========================:f_p_CTO_rwC_AND_rwN://
  861.     //:========================:FRAGPER_TO_CAMERA_RAY://
  862.     //:RENDER_SCENE:=================================://
  863.     //:sdf_RenderScene:==============================://
  864.     #define T_X vox_000.vox_cur.t_x
  865.     #define T_Y vox_000.vox_cur.t_y
  866.     #define T_Z vox_000.vox_cur.t_z
  867.     #define HAS vox_000.vox_cur.has
  868.  
  869.         V_4 sdf_RenderScene( RWC_AND_RWN rwC_AND_rwN )
  870.         {
  871.             I32 o_k = I32( 1 );
  872.             V_4 c4d = V_4(1,1,1,1);
  873.  
  874.             V_3 rwN = rwC_AND_rwN.rwN;
  875.             V_3 rwC = rwC_AND_rwN.rwC;
  876.  
  877.             V_3 xyz = rwC;
  878.          
  879.             VOX_000
  880.             vox_000;
  881.  
  882.             //:nex: Distance To NEXT voxel.
  883.             //:d_S: Distance To Surface Geometry inside
  884.             //:     the current voxel. In world coords.
  885.             vox_000.vox_dis.nex =( 0.0 );  
  886.         //: vox_000.vox_dis.d_S =( 0.0 );  
  887.  
  888.             //:Voxels will be thought of as 3D tiles:
  889.             vox_000.vox_cur.has = uint( 0 );
  890.             vox_000.vox_cur.dex =  int( 0 );
  891.             vox_000.vox_cur.t_x =  int( 0 );
  892.             vox_000.vox_cur.t_y =  int( 0 );
  893.             vox_000.vox_cur.t_z =  int( 0 );
  894.  
  895.             //:RAY_MARCH_LOOP:-----------------------://
  896.             /** #ABOUT_RAY_MARCH_LOOP# **/
  897.  
  898.                 //:March to VOXEL:
  899.                 for( int i = 0; i < MAX_STE ; i++ ){
  900.  
  901.                     //:March by distance to next voxel:
  902.                    
  903.                     //:Point_Normal_Form_To_Get:xyz
  904.                     xyz =
  905.                         rwC
  906.                     + ( rwN * vox_000.vox_dis.nex )
  907.                     ;;
  908.                
  909.                         vox_000 =
  910.                     GET_vox_000_USE_xyz_rwN(
  911.                                         xyz,rwN );;
  912.  
  913.                     //:If voxel is not empty, ray march
  914.                     //:inside of the voxel.
  915.                     if( vox_000.vox_cur.val > 0 ){
  916.                     for( int v = 0; v < MAX_STE ; v++ ){
  917.  
  918.  
  919.                     };;};;
  920.  
  921.                     /** Don't move the ray anywhere  **/
  922.                     /** We are going to slice into   **/
  923.                     /** whatever voxels the camera   **/
  924.                     /** plane passes through.        **/
  925.                     if( CFG_SLICE_RENDER >= 1 ){
  926.                         break;
  927.                     };;
  928.  
  929.                 };;
  930.  
  931.             //:-----------------------:RAY_MARCH_LOOP://
  932.  
  933.  
  934.             if( CFG_SLICE_RENDER >= 1 ){
  935.  
  936.                 //:Layer value, 1 or 0
  937.                 int lay = I32_MOD( T_Z, 2 );
  938.                
  939.                 //:#MODULO_CHECKER_PATTERN#://
  940.                 int chk =(  
  941.                     I32_MOD( //:<<<<<<<<<<<<<<:SET_003
  942.                         I32_MOD( T_Y, 2 )   //:SET_YYY
  943.                     +   I32_MOD( T_X, 2 )   //:SET_XXX
  944.                     ,                 2
  945.                     )
  946.                 );;
  947.            
  948.                 if(   0 != 0
  949.                 || ( lay < 0 )
  950.                 || ( lay > 1 )
  951.                 || ( chk < 0 || chk > 1 )
  952.                 || ( HAS > uint(1)      )
  953.                 ){
  954.                     //: _0x010101_ & _0x101010_
  955.                     c4d=PIX_ERR(ERR_001,c4d,o_k--);
  956.                 };;
  957.  
  958.                
  959.                 F32 M =( 255.0); //:Max RGB value.
  960.                 F32 X =( 1.0  ); //:FOR_DEBUGGING_COLORS
  961.              //:F32 ...........;    Replace with "_"
  962.              //:F32 ...........;    when done debugging.
  963.                 F32 a =( 1.0  ); //:ALPHA
  964.                 F32 _ =( 0.0  );
  965.                 F32 g =( F32(0x33)/M ); //:DARK-GREY
  966.                 F32 G =( F32(0x38)/M );
  967.                 F32 w =( F32(0xE5)/M ); //:WHITE-GREY
  968.                 F32 W =( F32(0xF2)/M );
  969.  
  970.                 V_4 _0x333333_ =V_4(g,g,g,a);
  971.                 V_4 _0x383838_ =V_4(G,G,G,a);
  972.                 V_4 _0xE5E5E5_ =V_4(w,w,w,a);
  973.                 V_4 _0xF2F2F2_ =V_4(W,W,W,a);
  974.                 V_4 _0x003300_ =V_4(_,g,_,a);
  975.                 V_4 _0x003800_ =V_4(_,G,_,a);
  976.                 V_4 _0x00E500_ =V_4(_,w,_,a);
  977.                 V_4 _0x00F200_ =V_4(_,W,_,a);
  978.  
  979.                 V_4 tab_000[8]=V_4[8](
  980.                     //:OUT OF BOUNDS:       //:HAS?
  981.                     _0x333333_ , _0x383838_ //:LAY0
  982.                    ,_0xE5E5E5_ , _0xF2F2F2_ //:LAY1
  983.                 //: |   CHK0   |     CHK1   |::::::::://
  984.                                    
  985.                     //:IN BOUNDS:           //:HAS?
  986.                    ,_0x003300_ , _0x003800_ //:LAY0
  987.                    ,_0x00E500_ , _0x00F200_ //:LAY1
  988.                 //: |   CHK0   |     CHK1   |::::::::://
  989.                 );;
  990.                
  991.                 I32 pik = (
  992.                    (4 * ( HAS >= uint(1) ? 1 : 0 ))
  993.                 +  (2 * lay ) //: LAY0 -or- LAY1
  994.                 +  (1 * chk ) //: CHK0 -or- CHK1
  995.                 );;
  996.  
  997.                 if( pik < 0 || pik >= 8 ){
  998.                     c4d=PIX_ERR(ERR_002,c4d,o_k--);
  999.                 };;
  1000.                
  1001.                 //:TODO: Why is not rendering as
  1002.                 //:      checker?
  1003.                 if( 1 == o_k ){
  1004.                     c4d = tab_000[ pik ];
  1005.                 };;
  1006.  
  1007.             }else{
  1008.                 //:DEBUG ONLY.
  1009.                 c4d=V_4(1,1,1,1);
  1010.             };;
  1011.  
  1012.             return( c4d );
  1013.         }
  1014.  
  1015.     #undef  T_X
  1016.     #undef  T_Y
  1017.     #undef  T_Z
  1018.     #undef  HAS
  1019.     //:==============================:sdf_RenderScene://
  1020.     //:=================================:RENDER_SCENE://
  1021.  
  1022. //:11111111111111111111111111111111111111111111111111://
  1023. //:00000000000000000000000000000000000000000000000000://
  1024.  
  1025.     void mainImage(
  1026.         out vec4 fragColor
  1027.     ,   in  V_2 fragCoord
  1028.     )
  1029.     {
  1030.            
  1031.         #define R_Y iResolution.y
  1032.             V_2 f_c = V_2(
  1033.             //:( FLIP? )       ( Discrete XY       ) ://
  1034.                (  0.0  )   +   ( fragCoord.x - 0.5 )
  1035.             ,  (R_Y-1.0)   -   ( fragCoord.y - 0.5 )
  1036.             );;
  1037.         #undef R_Y  
  1038.         V_2 f_p = f_c_CTO_f_p( f_c );
  1039.  
  1040.  
  1041.         //:CAMERA_RAY_FOR_CURRENT_PIXEL:-------------://
  1042.  
  1043.             /** The coordinate and direction of the  **/
  1044.             /** camera ray [rwC,rwN] are closely     **/
  1045.             /** related, so return them using the    **/
  1046.             /** same function. This will save        **/
  1047.             /** processing power when we decide      **/
  1048.             /** to create a camera lense that        **/
  1049.             /** is a 360 degree cylinder around      **/
  1050.             /** an object. (for fun)                 **/
  1051.  
  1052.             RWC_AND_RWN
  1053.             rwC_AND_rwN;
  1054.  
  1055.             rwC_AND_rwN = f_p_CTO_rwC_AND_rwN( f_p );
  1056.  
  1057.         //:-------------:CAMERA_RAY_FOR_CURRENT_PIXEL://
  1058.  
  1059.         fragColor = sdf_RenderScene( rwC_AND_rwN );
  1060.  
  1061.     }
  1062. //:00000000000000000000000000000000000000000000000000://
  1063. //:DOCUMENTATION:====================================://
  1064. /** ************************************************ ***
  1065.     ABBREVIATIONS:
  1066.  
  1067.         f : fragment
  1068.         p : percent (Never Position, use C for coord)
  1069.         c : coordinate
  1070.         r : ray
  1071.         n : normal, for directions.
  1072.         d : distance. NEVER DIRECTION.( use: n:normal )
  1073.        
  1074.     IDENTIFIERS:
  1075.  
  1076.         CTO: Convert_TO
  1077.         rwC: RayWorldCoord
  1078.         rwN: RayWorldNormal
  1079.         f_p: FragPercent
  1080.         f_c: FragCoord (With Discrete Pixel Coords)
  1081.                     (instead of pixel centers  )
  1082.         dad: Distance_And_inDEX
  1083.             Index is 1D index of XYZ voxel tile
  1084.             coordinate.
  1085.         vat: Voxel_Array__of__Tiles
  1086.         c4d: Color_4_Dimensional(RGBA)
  1087.  
  1088.     FUNCTIONS:
  1089.  
  1090.         f_c_CTO_f_p : FragmentCoord -CTO- FragPercent
  1091.         f_c_CTO_per : USE[ f_c_CTO_f_p ]
  1092.         sdf_i3d     : Interpolate_Two_3D_Points
  1093.  
  1094.     EXTRACTED_BLOCK_COMMENTS:
  1095.  
  1096.         #ABOUT_RAY_MARCH_LOOP###########################
  1097.  
  1098.             Ray marching loop should be able to look    
  1099.             at the current voxel coordinate returned    
  1100.             and decide to STOP marching if it wants.    
  1101.             By stopping immediately without marching    
  1102.             at all we can make the camera phosphore    
  1103.             surface a slice plane that renders          
  1104.             cross sectional views of tilemap data.      
  1105.    
  1106.         ##########################ABOUT_RAY_MARCH_LOOP##
  1107.         #POSITIVE_Z_DIVES_INTO_SCREEN###################
  1108.  
  1109.             Positive Z is further back into screen.
  1110.             This way to help normalize voxel grid math.
  1111.        
  1112.         ###################POSITIVE_Z_DIVES_INTO_SCREEN#
  1113.         #FIND_POINT_ON_SCREEN_PLANE#####################
  1114.  
  1115.             ORIGINAL_COMMENT:
  1116.  
  1117.                 Polygon in 3d space to serve as the
  1118.                 phosphor surface the CRT monitor
  1119.                 electrons will be projected onto.
  1120.                 Could probably use a mat4 for this.
  1121.  
  1122.             MORE_INFORMATION_IN_RETROSPECT:
  1123.  
  1124.                 "Screen Plane" is also known as
  1125.                 "CRT Phospore" or "PHO" for short.
  1126.                 This is a plane put into 3D space that
  1127.                 represents the pixels of the client
  1128.                 viewport (physical monitor).
  1129.  
  1130.                 The "IMAGE" plane from this diagram:
  1131.                 https://tinyurl.com/IMAGE-PLANE
  1132.  
  1133.         #####################FIND_POINT_ON_SCREEN_PLANE#
  1134.         #MODULO_CHECKER_PATTERN#########################
  1135.  
  1136.             // Checker pattern value, 1 or 0.         //
  1137.             // Combine Sets so that they create       //
  1138.             // a checkerboard of odd/even values,     //
  1139.             // and then convert even to 0 and         //
  1140.             // odd to 1.                              //
  1141.             //                                        //
  1142.             // SET_YYY:[ 0 1 0 1 0 1 0 ]              //
  1143.             // SET_XXX:[ 0 1 0 1 0 1 0 ]              //
  1144.             //                                        //
  1145.             // SET_XXX:     [ 0 1 0 1 0 1 0 ]         //
  1146.             //                | | | | | | |           //
  1147.             // SET_YYY:[ 0 ]- 0 1 0 1 0 1 0           //
  1148.             //         [ 1 ]- 1 2 1 2 1 2 1           //
  1149.             //         [ 0 ]- 0 1 0 1 0 1 0           //
  1150.             //         [ 1 ]- 1 2 1 2 1 2 1           //
  1151.             //         [ 0 ]- 0 1 0 1 0 1 0           //
  1152.             //         [ 1 ]- 1 2 1 2 1 2 1           //
  1153.             //         [ 0 ]- 0 1 0 1 0 1 0           //
  1154.             int chk =(  
  1155.                 I32_MOD( // <<<<<<<<<<<<<< SET_003
  1156.                     I32_MOD( T_Y, 2 )   // SET_YYY
  1157.                 +   I32_MOD( T_X, 2 )   // SET_XXX
  1158.                 ,                 2
  1159.                 )
  1160.             );;
  1161.  
  1162.         #########################MODULO_CHECKER_PATTERN#
  1163.  
  1164. *** ************************************************ **/
  1165. //:====================================:DOCUMENTATION://
  1166. //:UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU://
  1167. /** U : Undefine Macros Section **/
  1168.  
  1169.     #undef  V_4
  1170.     #undef  V_3
  1171.     #undef  V_2
  1172.     #undef  F32
  1173.     #undef  I32
  1174.  
  1175. /** U : Undefine Macros Section **/
  1176. //:UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU://
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement