Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The rotation artifacts you see are a result of the very simple algorithm and the property of the viewing triangle. It renders objects that are farther away when they are near the border of the viewing screen.


I wonder if you could nearly as efficiently draw to fixed distance arcs instead of perpendicular to viewing area lines to avoid that effect?


In the pseudo code in the readme just calculate the (square) distance between pleft and p and don't draw the line if the distance is larger than a given threshold. But this is not very efficient. When you switch the loops this will be easier because this check can be done in the outer loop. But I would suggest to experiment with some fog effect first.


Turns out it can be made quite efficient with a little effort put into arithmetic power reduction. In the outer loop, it is possible to calculate a `dr` value from the existing `dx` and `dy`. Then you just increment the radius traveled at the same time as `px` and `py`, and replace the inner loop condition that puts a bound on `z` with a new condition that puts a bound on the radius.

That fixes the rotation artifacts, and then makes it really easy to add a distance-based fog effect to hide the cut-off where new terrain comes into view as well.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: