Jump to content
  • Advertisement
  • entries
  • comments
  • views

Planetary engine, part IV ( volumetric fog/haze )

Sign in to follow this  


I have added a simple "tide" effect to the water: a set of cosinus functions modify the water level by +- 20 meters depending on time. At the moment it's a "fixed" effect, but i intend to make it dependent on the presence of a moon.

I still have lots of things to fix on the water, for example the underwater patches are rendered even if the camera is above water ( and vice versa ), which wastes some polycount/cpu. The tiling is still not fixed yet, and i still have to implement a good foam texture based on cellular procedural textures.

To have a break from the terrain engine, i started to code an A-star algorithm to handle A.I., the goal being to experiment NPC traffic in stations in the coming weeks. A-star is a graph algorithm that allows one to implement pathfinding and to associate some "costs" to each segment of the paths graph. That way the A.I. can select the shortest path to go from a point A to a point B, depending on the costs assigned to the graph. A-star is a very fast algorithm, but still too slow IMO to run on thousands of NPCs at the same time, so i'm planning to precompute for each station a 2D table that give, for a current control point and a destination control point, the ID of the "next" control point to go to. This shouldn't waste too much memory either, for example if there are 500 control points in a single station, that'd use 500 * 500 * 2 bytes ( you need 2 bytes to store a control point ID ) = 500 KB of memory to store the table. There would be one of this table per "station type", and not per instance of the station in the universe. Anyway, that's my plan, and time will tell if it works or not.

In other news i have implemented a simple form of volumetric fog / haze for the planetary engine. It is almost 95% vertex shader based, and works by generating a fog sphere of a constant thickness around the planetary sphere. The vertex shader then casts a ray from the vertex to the camera through this fog sphere and calculates the density of fog along this ray. This value is then used to LERP the diffuse color with the fog color. It is an over-simplification, and i've hit a lot of complex issues with this ( particularly with how to handle the case where the ray doesn't intersect the fog sphere at all, or of the atmosphere's fog color not matching the terrain's fog color due to altitude differences ), but the latest version is looking okay.

Some pics:

Sign in to follow this  


Recommended Comments

Will you have any sort of climate system that changes the terrain type and weather depending on how close you are to the equator or magnetic poles of the planet?

Your work is incredible, and as an example, today my girlfriend came over when I was looking at your journal, and when I showed her the last screen on this post and told her how good it looked, her first reaction was to say, "Neat, how did he take that picture?"

Keep up the good work!

Share this comment

Link to comment
I think it would be nice to render the patches below the water even when you are over it and using a nice blending function on the water patch to mix them.

I love the sea in games like Farcry or Joint Operations when you fly above the water and see the deep blue sea.

Share this comment

Link to comment
your work is amazing, and I would love to play a decent space MMO (the likes of which I have not found yet)

Share this comment

Link to comment
Like Tamat said, consider rendering the underwater terrain patches anyway, and making the sea more transparent. The best looking seas from high altitudes are the ones where you can see the depth of the ocean change. Combine that with your blue to green colour shift at varying sea depths, you'll end up making your sea look far less repitive and much more visually stunning.

The fog looks stunning btw! Nice work.

Share this comment

Link to comment
Is the fog totally apart from your atmospheric scattering code? How does it look when the camera is near the terrain, inside the fog? And if not already done: is it possible/easier/beautifuller to integrate the fog with the atmospheric scattering?

Share this comment

Link to comment
Wow, this fog really works a lot as a cloud layer. Have you thought about extending it to handle clouds too (instead of constant density, 3D perlin-noise comes to mind), or it would be too much trouble?

If you integrate by accumulation, it would be relatively easy (acc+=perlin(x,z,y) instead of acc+=constant). Other than that, perlin noise isn't exactly a well-behaved function that you can integrate analytically, like, say, a constant function (I'm guessing this is how you're doing it now). Oh well... the computational cost of that.

Then there's the looks -- it would look sweet, volumetric, but at the same time you might prefer a particle-based approach, for all those close-up bubbly details that you can see in some games. And then this fog-turned-clouds stops being worth it :)

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!