Jump to content
Eternal Lands Official Forums
Roja

Atmospherics

Recommended Posts

Hey, I thought we were going for cool(per-pixel) looking fog, imagine how would it look if we made volumes of fog divided into boxes.

 

Anyway, Roja required 3 types of fog, and I don't think we need true 3D volumetric for for any of them.

 

1) Regular all-around fog. OpenGL handles that.

2) Smoke coming off the ground. A good particle system can take care of that.

3) Fog beneath your feet: It's a simplified version of volumetric fog, since everything below a plane (y=C) is fogged. You can use glFogCoordEXT or a very simple vertex shader for this, no extra passes.

Share this post


Link to post
Share on other sites

Well, you are teh expert, so do it as you think it's best.

But I really don't think it's a good idea to make the fog with particles. We'd need a LOT of them, for a good looking fog.

Share this post


Link to post
Share on other sites
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.

164692[/snapback]

 

That sounds great, mikeman, it's exactly what we need. If you know a good guide to vertex shaders, just post it here, please.

 

P.S. After reading a bit, I wonder whether a fragment shader would suit that purpose better?

Edited by Lachesis

Share this post


Link to post
Share on other sites

P.P.S I learned more and I think we could go without a fragment shader and use a plain vertex shader. However, that vertex shader would have to be applied to the whole (3D) scene. Since we don't know what OpenGL features are used by Cal3D in advance, I suspect it would have to support quite a comprehensive featureset regarding textures, normals, materials, lighting and whatever else it is replacing. I have never written one line of GPU programming, so this task is way too complex for me. If I had the GLSL source of a vertex shader that does everything like OpenGL would do when not using the shader it would be easy to modify it, but without I'm afraid I can't.

 

With regards

Lachesis

Share this post


Link to post
Share on other sites

Ok, once and for all: Cal3d doesn't change a thing. I have a function cal_render_actor(). All it does it gets the vertex,texture coordinate and normal data and renders them. Nothing more. Exactly the same as every other model in the game. Don't worry about that.

 

But it's true that if you use vertex shaders you need to replace the whole fixed pipeline(tranformations,texgen,lighting...) too.

 

I'm wondering if 2 rendering passes aren't so bad after all: First we render the scene normally, to achieve texturing,shadows and lighting. The second pass(with vertex shaders) will be with texturing,lighting and shadows off, so it will be much faster and only implement the desired effect. The shader will look like this:

 


uniform vec3 fog_point;//A point in the fog plane(eye space)
uniform vec3 fog_norm;//The normal of the fog plane(eye space)

void main()
{
 vec4 V_eye;
 float distance;

 V_eye=gl_Vertex*gl_ModelViewMatrix;
 distance=dot( (V_eye.xyz-fog_point), fog_norm);//signed distance from the fog plane

 gl_Position=ftransform();//Emulate the fixed pipeline to avoid z-fighting
 gl_FrontColor=vec4(0,0,0,0);
 gl_FogFragCoord=distance;
}

 

Something like that anyway. Maybe sampling a 1D fog texture would give better quality.

Edited by mikeman

Share this post


Link to post
Share on other sites
All it does it gets the vertex,texture coordinate and normal data and renders them. Nothing more.

I know, I know. I was just talking about that:

But it's true that if you use vertex shaders you need to replace the whole fixed pipeline(tranformations,texgen,lighting...) too.

 

so it will be much faster and only implement the desired effect.

So using a shader for a single pass wouldn't be faster? But maybe we could compare both.

 

Thank you for your example! I haven't read about predefined functions yet, it seems emulating the fixed functionality is much simpler than I assumed. I'll continue reading, of course; maybe one day I will be able to do these things. Your shader looks like ground fog to me, the plane defined by fog_point and fog_norm certainly is the upper border of the fog. I guess we could hard-code the normal, it's always pointing down directly, so we could just use the corresponding coordinate of the vertex position and do without the scalar product.

 

If you find some time, could you implement the atmospherics? It would certainly take you significantly less time and probably your results would be better than those of most of us.

Share this post


Link to post
Share on other sites

Ok... well, I played around a little in my own engine because I want to do atmospherics there too. The problem is not so much with the static ground fog how with how to do the animated mist("steam coming of the ground"). I implemented an idea I had, and it looks interesting:

 

mist6ls.jpg

 

All it needs is a quick second pass(no shaders) and a 2D animated texture. The static ground fog is done the same way, you just have a totally white texture instead. When I'm done with Cal3D, I'll try to incoporate it into EL too.

Edited by mikeman

Share this post


Link to post
Share on other sites

hey that looks really nice :P

Do you need me to make the textures for it or do you already have them?

Share this post


Link to post
Share on other sites

Looks really nice, mikeman! I would really like to see how it looks animated ;) Can you explain how this is done? Only if you find the time and to feed my curiousness.

Edited by Lachesis

Share this post


Link to post
Share on other sites

Well, it's 2 passes as I said:

 

1)You render the geometry and make it so that in low heights it has white color and black in high heights. I used a 1D gradient texture to do that. You then enable modulative blending and draw a single animated fog plane. That way, pixels that are in low heights get much fog, while pixels that are in high heights get little or no fog.

 

2)Enable additive blending and perform the second pass, which is basically the scene rendered normally(unfogged).

 

This is the technique visually:

 

fog3ox.jpg

 

Roja, can you make animated noise textures using a special program or something? If so, then it would be nice. I'm currently using a single noise texture and do a primitive animation based on that, not too ugly but a true animation would look better.

Edited by mikeman

Share this post


Link to post
Share on other sites

Hmm... we are using a few texture units already (normal texture, clouds shadows, and I think some are used for the deepth buffer shadows as well).

So you might have to do it in two phases (might be slower).

Share this post


Link to post
Share on other sites
Hmm... we are using a few texture units already (normal texture, clouds shadows, and I think some are used for the deepth buffer shadows as well).

So you might have to do it in two phases (might be slower).

166060[/snapback]

 

Yes, I already said that it needs 2 rendering passes. The first pass is pretty quick though, and after all this effect won't be on all maps. Wherever there's ground fog, that means you can't see water reflections, so you just trade the reflection pass with the additional fog pass.

 

Also, this first pass has the advantage of setting up the z-buffer for the scene. When the normal scene will be rendered(textures+lighting), there will be zero overdraw due to early z-rejection, so that would speed up things too.

Edited by mikeman

Share this post


Link to post
Share on other sites

Hm..no I don't have any programs to make animated noise..i'd just probably have to wing it..just make a few different noise textures and hope they look good animated together :/

Share this post


Link to post
Share on other sites

Idea: let's use a 3D noise function, compute it and use it as a 3D texture? Then we can move the the texture through the plane and create interesting effects

Share this post


Link to post
Share on other sites

I haven't used their programming interfaces yet, only the command line tools.

 

I'm not exactly sure if it can be done with magickwand. Maybe Magick Core could do the trick better.

 

What I was thinking was adding effects to the existing cloud textures over time. Like a progressive blur and or ripple effect or somthing.

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.

×