0

I'm trying to write a raycaster based on this tutorial(https://lodev.org/cgtutor/raycasting.html) , but with the ability to render in 3D with voxels. However, it doesn't produce any output. When I view the output, side is always 1, sdist.z can sometimes be infinity, and pWallDist is at an unusually high number. I may have made a mistake in the code, but after multiple checks I am unable to find it.

Code: https://pastebin.com/3MxmzwYa

Russell356
  • 99
  • 1
  • 4
  • 3
    Please put the smallest code that demonstrates the problem, in the question. I don't know what the problem is, but in this case I suspect you might find the problem while trying to make the code smaller. – user253751 Dec 04 '19 at 10:49
  • what do you mean by `ability to render in 3D` ? something like this: [2D Ray Casting with different height size](https://stackoverflow.com/a/47251071/2521214) or this: [3D Ray Casting](https://stackoverflow.com/a/48092685/2521214) ? – Spektre Dec 04 '19 at 17:11
  • Rendering voxels (your second example) – Russell356 Dec 05 '19 at 01:38
  • @Russell356 you need to debug ... so place a break point somewhere and trace your code ... for single ray check its direction and look at your variables values each step until first discrepancy to expected state happens ... Beware 3D voxel ray tracing is slow (especially on CPU SW rendering) and if you have some kind of FPS limiter/enforcer its possible you simply render not yet finished image ... one frame can take even several seconds to compute (depending on resolution of screen and map). Also check if you are looking at something and not facing bakwards to your map ... – Spektre Dec 05 '19 at 08:18

0 Answers0