VOLUMIC & REALISTIC cloud system

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.

VOLUMIC & REALISTIC cloud system

Postby jimy-byerley » Thu Feb 18, 2016 9:49 am

I all,
I finished a simple module to make photorealistic volumic cloud.
We use it as a SceneNode.
cpp Code: Select all
 
// Before creating any cloud, we have to initialize the material of clouds:
setup_cloud_material(driver, driver->getTexture("clouds-group.png"),  4,  4); // texture, and number of texture by line and by row (see clouds.h)
 
//                                   parent,                      ...         position            scale
CloudNode * cloud = new CloudNode(scenemgr->getRootSceneNode(), scenemgr, vector3df(1,0,0), vector3df(10,8,12));
 

Copyright is free (in attempt of a true license ^^, but it will still open).
You can download the archive at google drive

The maximum number of faces by cloud is 100 and can be changed in cloud.h. The effective cound depend on the camera distance to the cloud.

Screenshot of a scene mith 3 lamps: a big white, a small blue and a small red: 100 faces
Image
As you see, the high number of faces makes a good effect for the light diffusion in the cloud.

With around 60 faces (~2 times farther)
Image

With around 40 faces (~4 times farther)
Image

KNOWN ISSUES:
* Alpha sorting problems with 2 differents clouds:
Faces are sorted before each render, to have a good alpha rendering. The sorting is done for each cloud before each frame, but only for the faces of the cloud. So when a cloud cover an other, there is sometimes transparency bugs. It appends when a cloud cover a more recently created cloud (render order of irrlicht)
Image

* Very short bugs in alpha sorting when the camera moves fast
Faces are sorted during the method OnRegisterSceneNode called before every render, but maybe before the update of the camera position. A offset can appear sometimes between the orientation of the faces and the camera direction.

THE GEOMETRY
At the creationg time of the cloud, A tuple of points is determined to represent the cloud's geometry: its poles (by default it is a 5-uple, but can be changed in the header)
When the distance to the camera has changed a lot, the geometry is adapted: if the camera is farther than before, faces are removed around each pole.
When the distance have decreased, faces are added around each pole.
This way the cloud keep allways the same form.

THE ALPHA SORTING
At contrary of the way of the engine, faces haven't to be sorted by distance to the camera. Each face is orthogonal to the camera direction vector, and so are parallel. The only way is to sort it with the algebric distance to the camera, on the focal axis:
Image
Last edited by jimy-byerley on Thu Feb 18, 2016 1:44 pm, edited 1 time in total.
jimy-byerley
 
Posts: 27
Joined: Thu Oct 22, 2015 10:42 am

Re: VOLUMIC & REALISTIC cloud system

Postby AReichl » Thu Feb 18, 2016 12:49 pm

Great!

Could that be used for a "region of fog" (volumetric fog?)?
Could you fly THROUGH such a cloud?
AReichl
 
Posts: 235
Joined: Wed Jul 13, 2011 2:34 pm

Re: VOLUMIC & REALISTIC cloud system

Postby jimy-byerley » Thu Feb 18, 2016 1:49 pm

Yes it could be ! The shader makes the faces opacity decrease when the camera is near, so We can see when the camera travel across the cloud. We just feel to fly trough a fog.
The light is also adapted by the faces: the light diffusion is inverse linear and not inverse quadratic. That makes the light diffusion you can see.
jimy-byerley
 
Posts: 27
Joined: Thu Oct 22, 2015 10:42 am

Re: VOLUMIC & REALISTIC cloud system

Postby AReichl » Tue Mar 15, 2016 10:01 am

Just wanted to respond:

I found a problem in
void CloudFace::render()
:

I had to change
const u16 indices[] = { 0,1,3, 0,3,2 }; // order of indices of points decide the normal of the plane
to
const u16 indices[] = { 0,2,3, 2,1,3, 1,0,3, 2,0,1 };
or it would crash with Visual Studio. I took the indices from an Irrlicht sample, don't know if they have the right order.


Then i also added

#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
precision highp int;
#else
precision mediump float;
precision mediump int;
#endif

to both shaders, or they would not run on my machine.
AReichl
 
Posts: 235
Joined: Wed Jul 13, 2011 2:34 pm

Re: VOLUMIC & REALISTIC cloud system

Postby chronologicaldot » Tue Mar 22, 2016 2:47 am

How about this? http://www.iquilezles.org/www/articles/dynclouds/dynclouds.htm
It's an article on how to make dynamic 2D clouds for the skydome and account for sunlight, all done cheaply. It's old (2002), yes, but even something like this is absent from Irrlicht afaik.
User avatar
chronologicaldot
Competition winner
 
Posts: 553
Joined: Mon Sep 10, 2012 8:51 am

Re: VOLUMIC & REALISTIC cloud system

Postby AReichl » Tue Mar 22, 2016 8:05 am

Yes, but you cannot fly THROUGH it. What we have here is VOLUMETRIC clouds.
In my opinion it could be used for volumetric fog, but i am not sure.
AReichl
 
Posts: 235
Joined: Wed Jul 13, 2011 2:34 pm

Re: VOLUMIC & REALISTIC cloud system

Postby REDDemon » Thu Mar 31, 2016 12:07 pm

you can keep clouds inside a bounding volume (box/sphere are simple)
if 2 clouds are likely to touch each other (bounding volume intersecting) you could instead merge theme into one so you both save 1 drawcall and prevent the sorting glitch.

it is true that sorting each cloud individually may be faster than sorting all faces at once (if you use heapsorto), but I think it is more worth saving extra drawcalls than saving sorting cost (and anyway we have radix sort wich is linear in cost).

Really nice effect by the way :)
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
User avatar
REDDemon
Developer
 
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: VOLUMIC & REALISTIC cloud system

Postby jimy-byerley » Tue Jun 28, 2016 12:50 pm

@REDDemon
It's a great idea, I will try to make something like that !

@AReichl
These indices are the vertex indices to draw the cloud face's triangles: The order is important to have the triangle to be oriented in the right direction (backface culling enabled). For a cloud face, (that is a square) there is just 2 triangles needed. So I don't know why it shouldn't work on Visual Studio.
I may correct my shader, but what is your graphical card ?

My clouds can be used for volumetric fog only if your camera doesn't move too much, or if you use a high number of cloud faces. Else It would be possible to see faces reorientation to the camera origin.
jimy-byerley
 
Posts: 27
Joined: Thu Oct 22, 2015 10:42 am


Return to Everything 2d/3d Graphics

Who is online

Users browsing this forum: No registered users and 1 guest