How do I initialize the t-variables in “A Fast Voxel Traversal Algorithm for Ray Tracing”?

后端 未结 2 1885
一整个雨季
一整个雨季 2020-12-14 02:15

I am trying to implement the algorithm explained on this paper, used to traverse grid cells in order following a straight line, which is useful for ray tracing:

http

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-14 02:55

    Initialization for X-coordinate variables (the same for Y)

      DX = X2 - X1
      tDeltaX = GridCellWidth / DX
      tMaxX = tDeltaX * (1.0 - Frac(X1 / GridCellWidth)) 
      //Frac if fractional part of float, for example, Frac(1.3) = 0.3, Frac(-1.7)=0.3
    

    Example:

      GridCellWidth, Height = 20
      X1 = 5, X2 = 105 
      Y1 = 5, Y2 = 55 
      DX = 100, DY  = 50
      tDeltaX = 0.2, tDeltaY = 0.4 
      tMaxX = 0.2 * (1.0 - 0.25) = 0.15  //ray will meet first vertical line at this param
      tMaxY = 0.4 * (1.0 - 0.25) = 0.3   //ray will meet first horizontal line at this param
    

    We can see that first cell border will be met at parameter t = 0.15

提交回复
热议问题