I'm working on a 2D (pseudo-3D) raycaster which operates on a 2D tile grid.
For each ray sent out, the screen draws a rectangle with a certain height depending on the distance between the camera and the wall the ray collided with (like Wolfenstein 3D).
I am now working on drawing texture images and have run into a problem:
If for example six rays hits a wall segment (tile) then the image which corresponds to this tile should be sliced into six parts. If there was 100 rays then the image needs to have 100 slices.
However, obviously there exist no image width which can be divided by all numbers.
How to go about this?
My current idea is:
Load several resolutions of the image texture, for example: (100x100, 200x200, 400x400, 800x800)
Identify how many rays has hit wall segment X
Identify which image resolution fits best to the scaled height of the rectangle (depending on distance from camera to target). Lower resolution for more distant objects etc.
Transform the selected image into the closest resolution which can be divided into a whole number by the amounts of rays which hit the segment
I believe this could work in principle; however I would hope there is an easier solution which requires less image transforms.