Best approach for slicing texture images for raycasting

Trending 9 months ago

I'm moving connected a 2D (pseudo-3D) raycaster which operates connected a 2D tile grid.

For each ray sent out, nan surface draws a rectangle pinch a definite tallness depending connected nan region betwixt nan camera and nan wall nan ray collided pinch (like Wolfenstein 3D).

I americium now moving connected drafting texture images and person tally into a problem:

If for illustration six rays hits a wall conception (tile) past nan image which corresponds to this tile should beryllium sliced into six parts. If location was 100 rays past nan image needs to person 100 slices.

However, evidently location beryllium nary image width which tin beryllium divided by each numbers.

How to spell astir this?

My existent thought is:

  • Load respective resolutions of nan image texture, for example: (100x100, 200x200, 400x400, 800x800)

  • Identify really galore rays has deed wall conception X

  • Identify which image solution fits champion to nan scaled tallness of nan rectangle (depending connected region from camera to target). Lower solution for much distant objects etc.

  • Transform nan selected image into nan closest solution which tin beryllium divided into a full number by nan amounts of rays which deed nan segment

I judge this could activity successful principle; nevertheless I would dream location is an easier solution which requires little image transforms.