0

I have a strange distortion in my raycasting program.

I have already multiplied the lengths of the vector with its cosine to correct the normal fish eye effect

This is the whole code https://editor.p5js.org/BlackPhoenix/sketches/FgTRwH2WF

This is the calculation of the distance to the wall.

  if(closest){
    let dis = p5.Vector.dist(this.pos, pt)
      if(dis < record){
        closest = pt
        record = dis * cos(radians(r - 45))
      }     

 }
John Coleman
  • 51,337
  • 7
  • 54
  • 119
Lukas Neumann
  • 656
  • 5
  • 18
  • 2
    the strange distortion comes from the fact that you have increased the angle by a consistent amount, while wolfenstein3d ray cast methods cast a ray to a "projection plane" where the rays on the projection plane are the same distance apart, but the angles are different this question may answer your problem: https://stackoverflow.com/questions/24173966/raycasting-engine-rendering-creating-slight-distortion-increasing-towards-edges – Joshua Usi Aug 07 '19 at 12:59
  • this [Ray Casting with different height size](https://stackoverflow.com/a/47251071/2521214) might interest you – Spektre Aug 08 '19 at 07:12

0 Answers0