Fog Generating Shader? (MGE)

Post » Mon Jun 21, 2010 2:52 am

Has anyone released shader that creates fog (much like morrowind already does) that is separate from morrowind's fog?

The reason I want this is because objects on a clear day in the distance should be shrouded in a sky blue (technically the same color as the deepest part of the sky, becoming more opaque a distance increases and less opaque as distance decreases) but setting morrowind's fog color to blue results in a blue horizon (the sky doesn't fade saturation at edges).

I figure the easiest way to get this effect is to have a separate fogging and push morrowind's fog way back so it just acts like a horizon color.

If there isn't already a shader that does this, how easy/hard would this be to achieve? And further more, while I'm not afraid to learn, would anyone like to create a shader that does this? (I know next to nothing of shader editing as of yet)

Note: this shader would have to limit the fog effects to objects/distant land so it is not to extend to the horizon and cover the white background fog. It would also need to be able to vary color and density/range based on weather conditions.

Note 2: If a shader is a stupid idea and there are so much simpler ways to do this feel free to let me know.

Thanks,
User avatar
Jake Easom
 
Posts: 3424
Joined: Sun Jul 29, 2007 4:33 am

Post » Mon Jun 21, 2010 12:14 am

Just so I'm clear about this, you don't like how clear MGE can make the weather?

peachykeen is working on a region-based palette system that can alter fog colors and distances/densities just like you're describing, but it's still in its early stages at the moment. So yes, there is a shader for this in the works. There's a thread with an alpha demo http://www.gamesas.com/index.php?/topic/1098619-wipz-better-colors/page__p__16054737&#entry16054737, if you'd like to see it. It's SUPER-ALPHA, though.

There is one quick way to fog things up. On MGE's distant land tab, try setting the Above Water Fog Start setting to something very small. The smaller that number, the closer the fog is to you. MGE will smoothly fade that fog from clear to opaque over the distance of the Start and End settings. I used to have mine set at 0.0 for start and 7.0 for end, which means I could see into the distance but there was still an "atmosphere." :P

If you're going to change the MW fog color in the INI file, remember to change the sky color to a matching color. Otherwise, the sky and fog won't match. Unless that's what you're going for.

Hope that helps.
User avatar
Minako
 
Posts: 3379
Joined: Sun Mar 18, 2007 9:50 pm

Post » Sun Jun 20, 2010 8:33 pm

The latest beta revisions of MGE also include an exponential fog feature which greatly enhances the realism of fog blending between the sky, horizon, and distant objects (valleys actually look foggier while surrounding high ridges have less fogging as expected). You can find it on the Distant Land tab, but be warned it requires that the draw distance is set 3-4x normal which can greatly impact framerate if you try to use too great a draw distance. It's best to start with a base draw distance of 4 or 5 cells, then activate the exponential fogging.
User avatar
Ezekiel Macallister
 
Posts: 3493
Joined: Fri Jun 22, 2007 12:08 pm

Post » Sun Jun 20, 2010 11:36 pm

Thanks for the reply guys, but I think you are missing the point... The goal here is to separate the horizon from the fog. Far away objects should, to look realistic, have a blue fog, while the sky should fade from blue to a white horizon. Perhaps I can find some pics to help demonstrate.

In morrowind:

http://i46.tinypic.com/zx1ov6.jpg

Irl:

http://i45.tinypic.com/jl1l44.jpg

Technically FOG isn't really the word for what I am trying to accurately replicate but I figure another layer of *fog* is a good way of doing it.

In case your wondering what the right word for it is; it's called Rayleigh scattering. Simply put, gaseous molecules (the atmosphere) allow longer wave lengths of light (reds, oranges, greens etc.) to pass through but shorter ones (ie: blue) are absorbed and radiated, thus making the sky appear blue.

Anyway, shader? How conceivable is this to achieve in morrowind?
User avatar
ashleigh bryden
 
Posts: 3446
Joined: Thu Jun 29, 2006 5:43 am

Post » Mon Jun 21, 2010 8:53 am

It's theoretically possible, combining extrapolation of world coordinates from eye position and direction and depth. It's not particularly easy, though. I toyed around with a shader like this some time ago, had the fog split into 3 layers and did different blending and coloring on each, smoothing them together, but it didn't look terribly good and was a bit slower. Hardware fogging is a much better solution, but is slightly limited (single-color, usually). With some work, you could blend them nicely and have it work much better. For simple atmospheric scattering like this, it shouldn't be hard (I have shader code to replace hardware fog, you could adapt it to color properly). So it's possible to do this, it would just take some work.
User avatar
Joe Alvarado
 
Posts: 3467
Joined: Sat Nov 24, 2007 11:13 pm

Post » Sun Jun 20, 2010 10:52 pm

That shader you were working on interests me... but I think only one layer is necessary. The way I am imagining it right now (with no shader experience), there would just need to be one color of fog that becomes more opaque the farther an object is. That simple! :lol:

Anyway I don't mind a little work... would you be willing to share these shaders in progress you have? Or your time to experiment with the idea (if you have time to waste of course)
User avatar
Bird
 
Posts: 3492
Joined: Fri Nov 30, 2007 12:45 am

Post » Mon Jun 21, 2010 2:20 am

...
Anyway, shader? How conceivable is this to achieve in morrowind?

Atmospheric scattering. The atmosphere needs to be lit unevenly.

http://img27.imageshack.us/ifs/7423/img44/3/79667811.jpg
http://img8.imageshack.us/img8/9126/62982169.jpg
http://img43.imageshack.us/img43/1412/45716186s.jpg

They are Phal's. It was introduced for a short time and then removed, temporarily. ;) Hopefully they will find their way in a feature release.

When per-pixel velocity motion-blur finds its way, it will be perfect with addition of shadows.
http://s51.photobucket.com/albums/f386/vtastek/morrowind/Morrowind2009/sc08/MGEScreenshotbattlemotion.jpg
http://s51.photobucket.com/albums/f386/vtastek/morrowind/Morrowind2009/sc08/MGEScreenshotsuddendeath.jpg
screens don't do justice to this effect, you need to see it in motion. :)

Question is, where is Knu?

PS. http://www.gamesas.com/index.php?/topic/1047048-mge-screenshot-thread-3/page__view__findpost__p__15241621
User avatar
Hayley Bristow
 
Posts: 3467
Joined: Tue Oct 31, 2006 12:24 am

Post » Sun Jun 20, 2010 5:49 pm

One layer would work, but I had added 3 and a blur pass so that nearby objects would have a fog-free zone around them. It was able to create a soft-fog effect, in addition to scattering.

I'll see if I can dig up the shader, but the basic code is:
float3 lowColor = { 0.0, 0.5, 1.0 }; // bluefloat3 highColor = { 1.0, 0.0, 0.0 }; // red, for testingfloat depth = tex2D(depthFrame, uv);float3 fog = 0;fog.r = smoothstep(0, 500, depth); // first layerfog.g = smoothstep(500, 2000, depth); // secondfog.b = smoothstep(2000, 16000, depth); // third-- run a gaussian blur --float4 worldPos = eyeVec * eyePos * depth; // not accurate, but extrapolate world-pos herefloat height = smoothstep(0, 1000, worldPos.z); // at 0, height will be 0, at 1k it will be 1float fogAmount = fog.r + fog.g + fog.b;fogAmount /= 3; // generate a 0-1 fog value, using a rough curvefloat3 curcolor = lerp(lowcolor, highColor, height ); // select the right fog colorfloat4 finalColor = tex2D(lastShader, uv);finalColor.rgb = lerp(finalColor.rgb, curColor.rgb, fogAmount ); // lerp between the actaul and fog colors based on distancereturn finalColor;


It's messy, but that's the idea. :)
User avatar
FoReVeR_Me_N
 
Posts: 3556
Joined: Wed Sep 05, 2007 8:25 pm

Post » Mon Jun 21, 2010 6:06 am

I'm sure vtastek's insta-splash! shader could be worked into something like this. http://www.gamesas.com/index.php?/topic/1089104-wipz-relz-vtasteks-npr-shaders/ers__fromsearch__1&#entry15876908. The only three issues being that you would have to replace the scroll texture with a color of choice, you would have to figure out a good value for distance, and you would have to find a way to keep the sky from being affected.

[edit] WOAH. That stuff is nice.
User avatar
Daniel Holgate
 
Posts: 3538
Joined: Tue May 29, 2007 1:02 am

Post » Sun Jun 20, 2010 9:02 pm

I'm sure vtastek's insta-splash! shader could be worked into something like this. http://www.gamesas.com/index.php?/topic/1089104-wipz-relz-vtasteks-npr-shaders/ers__fromsearch__1&#entry15876908. The only three issues being that you would have to replace the scroll texture with a color of choice, you would have to figure out a good value for distance, and you would have to find a way to keep the sky from being affected.

It is similar, as depth and color is being multiplied but that's it. We will need a special code for this task. Some approximations of real life equations. ;)
User avatar
Ella Loapaga
 
Posts: 3376
Joined: Fri Mar 09, 2007 2:45 pm

Post » Sun Jun 20, 2010 11:22 pm

Atmospheric scattering. The atmosphere needs to be lit unevenly.

http://img27.imageshack.us/ifs/7423/img44/3/79667811.jpg
http://img8.imageshack.us/img8/9126/62982169.jpg
http://img43.imageshack.us/img43/1412/45716186s.jpg

They are Phal's. It was introduced for a short time and then removed, temporarily. ;) Hopefully they will find their way in a feature release.



Why do I always see crazy amazing screens from phal and never shaders? :(

There are multiple directions to go with this idea in this thread... which one seems to be the best way to go for those here who actually know what they are doing?
User avatar
josh evans
 
Posts: 3471
Joined: Mon Jun 04, 2007 1:37 am

Post » Mon Jun 21, 2010 4:15 am

Atmospheric scattering, like what phal did, is the most correct method. It's also the most difficult.
Replacing hardware fog with a shader is quick and easy, and is sufficient to do what you want until a full physically correct scattering shader can be written.
User avatar
Zach Hunter
 
Posts: 3444
Joined: Wed Aug 08, 2007 3:26 pm

Post » Sun Jun 20, 2010 6:30 pm

Why do I always see crazy amazing screens from phal and never shaders? :(

What do you mean? The atmospheric scattering was dropped in a later revision, his sunshafts shader is still available, and his water tweaks are in the default MGE setup now... I don't really remember much posted by Phal that was actually never released.

----------

Excuse me while I go dream of a Morrowind powered by a brand new official MGE 3.9 release with atmospheric scattering and cloud shadows and an update to the Morrowind Code Patch with static shadows and Connary's full texture compendium and Westly's Head Replacer and a new Tamriel Rebuilt release and and and... :ahhh: :nuke:
User avatar
Sarah Edmunds
 
Posts: 3461
Joined: Sat Jul 08, 2006 8:03 pm

Post » Sun Jun 20, 2010 6:35 pm

I recall seeing some amazing sky shots from Phal that haven't yet been seen elsewhere, but you're right, pretty much everything else has made it through (though the atmospheric scattering has not yet been reintroduced). :)


A fog shader like this or the return of atmospheric scattering would be awesome, though!

(edit: PK, neat avatar, it took a double take for me to realize what was up and a few refreshes to convince myself ^_^ )

(edit 2: found them http://www.gamesas.com/index.php?/topic/1076125-mge-screenshot-thread-no5/page__st__180__p__15826237__fromsearch__1&#entry15826237)
User avatar
SexyPimpAss
 
Posts: 3416
Joined: Wed Nov 15, 2006 9:24 am

Post » Mon Jun 21, 2010 4:01 am

My bad I kind of use the wrong words: "never" and "any". I love his water and sun shafts (all I really use) and I am extremely thankful for them. I guess I was just referring to the last few days in which I discovered those stalker skies screens and the atmospheric scattering ones...

lol I feel bad now...
User avatar
Rik Douglas
 
Posts: 3385
Joined: Sat Jul 07, 2007 1:40 pm

Post » Sun Jun 20, 2010 9:17 pm

Oh right I forgot about the STALKER skies... Good stuff.

Also I could never get the clouds version of the Sunshafts shader to work, I'm guessing that's also not compatible with the latest revision?

Or I'm still doing it wrong. :shakehead:
User avatar
Cheryl Rice
 
Posts: 3412
Joined: Sat Aug 11, 2007 7:44 am

Post » Mon Jun 21, 2010 7:10 am

Oh right I forgot about the STALKER skies... Good stuff.

Also I could never get the clouds version of the Sunshafts shader to work, I'm guessing that's also not compatible with the latest revision?

Or I'm still doing it wrong. :shakehead:



It required a specific build of 118b3 if I recall correctly =(.
User avatar
MarilĂș
 
Posts: 3449
Joined: Sat Oct 07, 2006 7:17 am


Return to III - Morrowind