Ralith / hypermine

A hyperbolic voxel game
Apache License 2.0
160 stars 20 forks source link

Distance fog changes colour based on height relative to ground plane #54

Open danieldeankon opened 4 years ago

danieldeankon commented 4 years ago

It would be helpful when navigating to have some visual feedback about how deep or how high you are on a large scale. Equidistant surfaces tend to look equally curved beyond a certain size and it is difficult to find your way back to planar ground when you're on an equidistant.

Ralith commented 4 years ago

A naive solution, passing the elevation into the shader and just picking a color before proceeding as usual, would be simple but incorrect and a bit ugly, as it doesn't account for the appearance of a view ray that passes through multiple layers of fog.

I suspect a reasonably cheap analytic model for the color of a ray passing through elevation-sensitive fog could be derived (@MagmaMcFry how's your calculus? I think we can pose this as a fairly straightforward integral), and even if not, a precomputed 2D LUT could still be used, parameterized by altitude and angle.

We'd have to fudge it a bit to keep visibility similar to the nonphysical exponential-squared fog we have now, of course.

Ralith commented 4 years ago

Relevant discussion of elevation fog in euclidean space: https://www.iquilezles.org/www/articles/fog/fog.htm

Ralith commented 4 years ago

it is difficult to find your way back to planar ground when you're on an equidistant.

While this is very true for the time being, I think it will be mitigated once we have collision detection, gravity, and gravity-based camera orientation. That said, nonuniform fog is still pretty.

danieldeankon commented 4 years ago

A naive solution, passing the elevation into the shader and just picking a color before proceeding as usual, would be simple but incorrect and a bit ugly, as it doesn't account for the appearance of a view ray that passes through multiple layers of fog.

The naive solution was what I had in mind when I raised the issue---global fog colour as a function of elevation instead of a constant.

It seems there are multiple motivations, pulling in different directions, when it comes to designing and implementing how fog works. On one hand there's fog as merely something to solve problems such as chunks popping into existence too suddenly, or not knowing how far you are from the plane. On the other, there's fog treated as a physical feature of the world, where simulating it correctly is important for its own sake. And then there are aesthetic considerations. What's your overall vision for the place of fog in hypermine?

Ralith commented 4 years ago

I see thick fog as an unfortunate compromise we have to make due to a poor view distance, but so long as we're going to have it I'd like it to be pretty. In an ideal world where our view distance is much larger, we still want slight fog because it's a key element of depth perception, but it would be far more subtle, and more physically plausible. Elevation-based color variation is desirable regardless.

The naive solution is definitely an improvement, but an approach that models the effect of a ray passing through a range of elevations will be a large improvement.