Fog doesn't render to the sky #417

Closed
JanSeW opened this Issue Feb 19, 2017 · 6 comments

Comments

Projects
None yet
4 participants
@JanSeW

JanSeW commented Feb 19, 2017

Hey guys,

yesterday I discovered that Chunky doesn't render fog in the sky. This is a bit annoying 'cause the result looks kind of wrong.
Maybe this can be fixed in the next update?

Thxalot,
JanSe

@empirebuilder1

This comment has been minimized.

Show comment
Hide comment
@empirebuilder1

empirebuilder1 Feb 27, 2017

I also am annoyed a bit with the fog, but it's not so simple as just making it render there.

See, the fog levels are calculated by distance from the camera, and then magic is done in the renderer to raytrace it (as I understand it). Now the sky technically has an unmeasurable distance from the camera - it is ∞. So something has to be chosen as a distance, it could be the farthest visible block from the camera, or an arbitrary value from the edge of the imported world. Perhaps one way to do it would be to create an actual skybox at the edge of the imported world, it would at least have a consistent fog level.

One way to avoid the sharp edge is to mess with your skybox color gradient, so it's the same color as your fog at flat and a blue sky color above. This should get you a decent looking fog gradient, but it's tricky to get looking right in actual practice (and impractical if you want a custom skybox texture)

I also am annoyed a bit with the fog, but it's not so simple as just making it render there.

See, the fog levels are calculated by distance from the camera, and then magic is done in the renderer to raytrace it (as I understand it). Now the sky technically has an unmeasurable distance from the camera - it is ∞. So something has to be chosen as a distance, it could be the farthest visible block from the camera, or an arbitrary value from the edge of the imported world. Perhaps one way to do it would be to create an actual skybox at the edge of the imported world, it would at least have a consistent fog level.

One way to avoid the sharp edge is to mess with your skybox color gradient, so it's the same color as your fog at flat and a blue sky color above. This should get you a decent looking fog gradient, but it's tricky to get looking right in actual practice (and impractical if you want a custom skybox texture)

@syrinxsean

This comment has been minimized.

Show comment
Hide comment
@syrinxsean

syrinxsean Feb 27, 2017

If it's at an infinite distance from the camera, then should it by definition be the full fog color?

If it's at an infinite distance from the camera, then should it by definition be the full fog color?

@llbit

This comment has been minimized.

Show comment
Hide comment
@llbit

llbit Feb 28, 2017

Owner

@syrinxsean Yes, that's the idea. In real life we never have infinite fog because the atmosphere curves over the horizon so the sky bleeds seamlessly into the fog at the horizon. That's pretty difficult to simulate, especially when the world you are rendering is totally flat, so the atmosphere does not bend.

Owner

llbit commented Feb 28, 2017

@syrinxsean Yes, that's the idea. In real life we never have infinite fog because the atmosphere curves over the horizon so the sky bleeds seamlessly into the fog at the horizon. That's pretty difficult to simulate, especially when the world you are rendering is totally flat, so the atmosphere does not bend.

@llbit

This comment has been minimized.

Show comment
Hide comment
@llbit

llbit Feb 28, 2017

Owner

Maybe this can be fixed in the next update?

Regardless of the difficulties with rendering fog accurately, Chunky could make some oversimplifications to get a fog blending effect near the horizon. This is something that I considered a bit when I rewrote the fog code most recently, but I decided to put off.

I'm not sure right now how it could be implemented but it doesn't seem too tricky to render fake fog over the sky - just blend the sky and fog color based on azimuth angle. I think I could add this in the next release, or if someone wants to try hack it in I'll accept a pull request with this.

Owner

llbit commented Feb 28, 2017

Maybe this can be fixed in the next update?

Regardless of the difficulties with rendering fog accurately, Chunky could make some oversimplifications to get a fog blending effect near the horizon. This is something that I considered a bit when I rewrote the fog code most recently, but I decided to put off.

I'm not sure right now how it could be implemented but it doesn't seem too tricky to render fake fog over the sky - just blend the sky and fog color based on azimuth angle. I think I could add this in the next release, or if someone wants to try hack it in I'll accept a pull request with this.

@syrinxsean

This comment has been minimized.

Show comment
Hide comment
@syrinxsean

syrinxsean Feb 28, 2017

I've been wondering lately whether Chunky should actually have the world bend at large distances. Given that I've had significant trouble getting it to handle even 10,000 chunks, I wonder whether there would be advantages (not just to fog) to having the world drop away after a kilometer or two.

I like the idea of doing "sky" fog based on azimuth angle. (Throwing in some small Perlin noise might even make it a bit more realistic. 🙂)

I've been wondering lately whether Chunky should actually have the world bend at large distances. Given that I've had significant trouble getting it to handle even 10,000 chunks, I wonder whether there would be advantages (not just to fog) to having the world drop away after a kilometer or two.

I like the idea of doing "sky" fog based on azimuth angle. (Throwing in some small Perlin noise might even make it a bit more realistic. 🙂)

@llbit

This comment has been minimized.

Show comment
Hide comment
@llbit

llbit Jul 7, 2017

Owner

By azimuth I meant altitude. I tried implementing the idea of fading in the fog color near the horizon and it seems to work pretty well for my test scenes. This will be available in the next snapshot (1.4.3-alpha3) which will be published sometime today.

screenshot 2017-07-07 09 02 15

Owner

llbit commented Jul 7, 2017

By azimuth I meant altitude. I tried implementing the idea of fading in the fog color near the horizon and it seems to work pretty well for my test scenes. This will be available in the next snapshot (1.4.3-alpha3) which will be published sometime today.

screenshot 2017-07-07 09 02 15

@llbit llbit closed this in e3b4172 Jul 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment