DEV Community

Cover image for My Hardships with ray marching
No_Arms_studio
No_Arms_studio

Posted on

My Hardships with ray marching

   I have made a Ray marching algorithm in scratch to better my work in creating a full ray traced game in real time. The implantation of the ray marcher started with me creating small distance fields with a position in a list. 
   In the algorithm the ray runs a function that finds the nearest distance and moves that distance, then it repeats this cycle until it has gone too far off the screen or the closest distance is very small. The way that a normal ray marcher works. but the one thing that I had a problem with was the sizing of the representation of the distance to the point. I want you to try and figure out what is wrong with this code that I spent 2 days on:
          set size to ((100 / 5) * Closest dist)
   It's really simple once you know the answer. It's:
          set size to ((100 / 5) * (Closest dist * 2))
   The reason for the (* 2) is that the Closest distance is only the radius of the circle not the diameter as I needed it. Anyway thanks for reading my little rant section, goodbye :)
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
no_arms_studio profile image
No_Arms_studio

I don't like easy answers.