Jump to content
Eternal Lands Official Forums
Roja

Atmospherics

Recommended Posts

I always thought it would be cool to have fog, mist, steam, etc. in the game.

 

Does anyone knwo how to do this? I would think it's mainly client side so maybe someone here can help.

 

We can use different types of fog and such, here they are:

 

-fog that doesn't go too far above your ankles, so it's like you're walking on a cloud.

-thin fog, making it misty around you, but you can still see everything, it's just dimmed.

-thick fog, meaning you can't see too far in front of you at all

-steam rising from teh ground..more opaque towards the ground but easily thinned

-snow falling (this one should be real easy i think)-would just have to flag a map as a SNOW map so it would snow instead of rain.

 

 

If someone wants to do this and they need artwork from me just let me know and i'll get it asap! :D

Share this post


Link to post
Share on other sites
I always thought it would be cool to have fog, mist, steam, etc. in the game.

I am going to do some research on the possibilities that OpenGL offers to us. If anyone has some tips for me, don't hesitate to PM.

 

These are my first, simple ideas:

-thin fog, making it misty around you, but you can still see everything, it's just dimmed.

-thick fog, meaning you can't see too far in front of you at all

For these, there is OpenGL support.

-fog that doesn't go too far above your ankles, so it's like you're walking on a cloud.

-steam rising from teh ground..more opaque towards the ground but easily thinned

These effects might be achieved by using semitransparent white textures on planes slightly above the ground, maybe combined with the OpenGL fog system mentioned above and particle systems to illustrate the raising of the steam.

 

With regards

Lachesis

Edited by Lachesis

Share this post


Link to post
Share on other sites

If you want to have a quick impression of what OpenGL fog can look like, test the following patch, which hard-codes a thick, linear light-grey fog.

--- elc/gl_init.c       2004-12-15 21:18:28.000000000 +0100
+++ elc/gl_init.c      2005-02-21 15:57:43.000000000 +0100
@@ -365,16 +365,26 @@
    glEnable(GL_TEXTURE_2D);
       glShadeModel(GL_SMOOTH);
       glFrontFace(GL_CCW);
       glCullFace(GL_BACK);
       glEnable(GL_NORMALIZE);
-       glClearColor( 0.0, 0.0, 0.0, 0.0 );
+       //glClearColor( 0.0, 0.0, 0.0, 0.0 );
       glClearStencil(0);

-       glFogi(GL_FOG_MODE,GL_LINEAR);
-       glFogf(GL_FOG_START,5.0);
-       glFogf(GL_FOG_END,35.0);
+       //glFogi(GL_FOG_MODE,GL_LINEAR);
+       //glFogf(GL_FOG_START,5.0);
+       //glFogf(GL_FOG_END,35.0);
+
+       float fogColor[4] = { 0.7f,0.7f,0.7f,1.0f };
+       glClearColor(0.7f,0.7f,0.7f,1.0f);              // We'll Clear To The Color Of The Fog (    Modified )
+       glFogi(GL_FOG_MODE, GL_LINEAR);                 // Fog Mode
+       glFogfv(GL_FOG_COLOR, fogColor);                // Set Fog Color
+       glFogf(GL_FOG_DENSITY, 0.35f);                  // How Dense Will The Fog Be
+       glHint(GL_FOG_HINT, GL_DONT_CARE);              // Fog Hint Value
+       glFogf(GL_FOG_START, 1.0f);                     // Fog Start Depth
+       glFogf(GL_FOG_END, 5.0f);                       // Fog End Depth
+       glEnable(GL_FOG);                               // Enables GL_FOG

       SDL_EnableKeyRepeat(200, 100);
       SDL_EnableUNICODE(1);
       build_video_mode_array();
       SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &have_stencil);

Share this post


Link to post
Share on other sites

These effects might be achieved by using semitransparent white textures on planes slightly above the ground...

 

Yes, that would be good for the "cloud" fog below you ankles. Only it doesn't have to be a white texture, in fact that wouldn't look so good. You can texture the plane with a "cloud" texture. Better yet, you can for example blend 4 textured quads(with the same texture) on the same plane, and "move" the texture front,back,left,right for each quad. It will give the impression that the fog cloud is randomly changing shapes.

 

As for the particles, I see you guys use point sprites, not a very good choise IMHO. With billboarded quads, you also have the option to rotate them in addition to moving them around, and can create much better effects.

Edited by mikeman

Share this post


Link to post
Share on other sites

Of course the particles wont be points in that case. Anyway, I noticed that fog is more flexible than I thaught, and maybe we don't need the large quads close to the ground, and can use true fog instead. I am going to play around with this a little.

Edited by Lachesis

Share this post


Link to post
Share on other sites

I am sorry, but it will take some time until I can continue my work on EL, because I have problems linking against NVidia drivers.

Share this post


Link to post
Share on other sites
I am sorry, but it will take some time until I can continue my work on EL, because I have problems linking against NVidia drivers.

Making a wild guess (happened to me twice now): Is the problem that you still have the Mesa libraries installed, and that it's linking against those instead of the /usr/lib/libGL.so provided by nVidia? In that case, rename the Mesa libraries (/usr/X11R6/lib/libGL.so* ) to something like /usr/X11R6/lib/XXXlibGL.so* to convince the linker that it real, REALLY, should not use those libraries.

 

PS: blindly assuming you're using Linux. Are you?

Share this post


Link to post
Share on other sites

Finally, I got it working again. I am currently experimenting with glFog and examining some OpenGL extensions weather it would be possible to use them for ground fog, and maybe even steam, since this would look much nicer and more realistic than the solutions in my previous post.

Edit: If anyone knows a good documentation for the fog coord OpenGL extension (EXT_fog_coord) please tell me I would jump for joy :P.

2nd edit: I suspended this task in favor of encyclopedia rework. Some news though: EXT_fog_coord is too ugly to code, I think the best solution for static fog would be an additional linear-blended rendering run without textures but a special 3D fog texture instead. Motion effects such as raising steam could be done the same way, but would require expensive recalculation of the texture, so using alpha-textured particle objects currently appears the best solution to me.

 

With regards

Lachesis

Edited by Lachesis

Share this post


Link to post
Share on other sites

bump. Don't forget about this guys..if someone is willing to take on this project, we can use your help :P

Share this post


Link to post
Share on other sites

I don't have documents or something like this, but maybe you could look into the code of some freely available programs?

At Delphi3D.net for example are many OpenGL Programs...

They're written in delphi but I think that the OpenGL "Commandos" should be the same...

 

And wouldn't nVidias developer-section http://developer.nvidia.com help you?

 

Sorry, but I don't know anything about 3D-Programming...

I can't even program C (well... only something that puts out two lines... Or stupid copy&paste). But I hope that I will learn it soon...

Share this post


Link to post
Share on other sites

I haven't yet. Now that we are migrating to Cal3D, I can't even tell if it'll be possible at all ATM. I already had a glance at Cal3D but I think it doesn't make much sense to investigate further until I know mikeman's code.

Edited by Lachesis

Share this post


Link to post
Share on other sites
I haven't yet. Now that we are migrating to Cal3D, I can't even tell if it'll be possible at all ATM. I already had a glance at Cal3D but I think it doesn't make much sense to investigate further until I know mikeman's code.

164346[/snapback]

 

What Cal3D has to do with fog, or any other special effect? It's just a different way to handle animation. It still uses OpenGL for rendering.

Share this post


Link to post
Share on other sites

If you use a 3D texture for fog, you have to render the scene an additional time using this texture instead of the actual objects' textures. It depends on how the rendering using Cal3D is done whether this is possible.

 

With regards

Lachesis

Share this post


Link to post
Share on other sites
You don' need the objects...

Just render a FOG 3D texture.

164691[/snapback]

 

Hm, you can't "render" textures. You will use a 3D texture, but this texture will need to be applied to a primitive of course. In case there's something I'm missing, you will have to render the objects with a 3D texture binded.

 

But in any case, using a fog texture will burn a texture stage, which means you will need another rendering pass. I'm thinking the best idea is to use vertex shaders, since they're supported all the way down to GF2(even in software, they're fast). In that case, any special effect is simply reduced to writing a special vertex shader for it. For instance, for "fog below your legs", you simply calculate the distance between the vertex and a horizontal plane, and set the fog accordingly.

Share this post


Link to post
Share on other sites

Of course you need an object to render the texture on.

So you make some sort of cube, or sphere, or, if that doesn't work right, then some cloud like 3d object.

The idea is for this object to be bigger than the scene.

Share this post


Link to post
Share on other sites

I can't possibly imagine how that would work. Let's say you just render a sphere or a box surrounding the scene, how would that give a fog effect? You'll just have something like a skydome with a fog texture. It might give the impression of a fog to objects that are supposed to be away from the viewer, but it won't affect objects that are inside the box, and it surely won't make them fade in/out according to fog density between viewer and object.

Share this post


Link to post
Share on other sites

Not even if you use alpha blending?

Think of it, a real life room full of fog is actually a box with a 3d texture (the fog particles).

Share this post


Link to post
Share on other sites

No, we're not talking about voxels here, unfortunately :P

 

3D textures is basically a way to encode a 3D function into a texture. In our case, we encode the fog into 3D space. But a box is just 6 quads, 12 vertices. As such, it will only sample the borders of a 3d texture. It's not like you somehow rendering the "inside" of the box too. You will need to render the objects inside the box volume and sample the 3D texture according to their vertex positions.

 

In volumetric fog, we need to render the fog "shape", but we also need to render all the objects inside it. See this:

 

http://nothings.org/computer/vfog/vfog.txt

 

It's pretty short, but covers the issue.

Edited by mikeman

Share this post


Link to post
Share on other sites

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×