Volumetric Ground Clouds

Volumetric Ground Clouds

Discuss maps & map creation - from concept to execution to the ever elusive release.

Moderator: Moderators

User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Volumetric Ground Clouds

Post by Anarchid »

I've been posting some pictures of a fog shader for a while now, so it's time to actually let people have it.

Image
Image

This is a widget that draws volumetric ground clouds which scroll with the wind. That means, one of TA-derivative invisible economies can become very much visible!

It requires GLSL and won't work without. Being a widget means that if it is included in a map and then annoys some people, they can turn it off easily and without restarting the game.

Conceptually, it's a bastard child of jK's glsl ground fog in Blueprint's dual_fog widget, and this.

It is configurable in a map's mapinfo, like this:

Code: Select all

custom = {
		clouds = {
			speed = 1, -- multiplier for speed of scrolling with wind
			color    = {0.46, 0.32, 0.2}, -- diffuse color of the fog
                        -- all altitude values can be either absolute, in percent, or "auto"
			height   = "90%", -- opacity of fog above and at this altitude will be zero
                        bottom = 0, -- no fog below this altitude
			fade_alt = "70%"; -- fog will linearly fade away between this and "height", should be between height and bottom
			scale = 255, -- how large will the clouds be 
			opacity = 0.4, -- what it says
			clamp_to_map = true, -- whether fog volume is sliced to fit map, or spreads to horizon
			sun_penetration = 15, -- how much does the sun penetrate the fog
		},
}
An extra hidden parameter is your sun and its ground specularity color, which are used for fog highlights.

OBTAIN THUSLY

P.S. i've been thinking of putting it into Blueprint but i have failed to make it activate/deactivate based on mapOptions. Maybe i just used wrong case or something.
Last edited by Anarchid on 26 Jan 2015, 17:23, edited 5 times in total.
User avatar
qray
Posts: 377
Joined: 02 Feb 2009, 18:49

Re: Volumetric Ground Clouds

Post by qray »

Hmm, works on one system here but not on the other (test with Quagmire, Linux, Nvidia with prop. drivers, text. compr. off). I see a small change when switching widget on/off, but definetely not the clouds as on the working system (no error message in infolog). Can't spot the difference ATM.

But definetely a neat effect when it works 8)
User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Re: Volumetric Ground Clouds

Post by Funkencool »

Looks awesome :shock: makes me want to go back to some of the maps I abandoned :regret:

I don't know nearly as much about shaders as I should but I'm just curious.
Would it be possible to use the LOS texture as a mask to the texture used for noise?
If so, would it have a large impact on performance?
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Volumetric Ground Clouds

Post by Anarchid »

Some people have been having issues with previous version on Quagmire, but you should notice that the released version of that map has rather nasty settings for its standard Spring fog, which seems to cause things like completely gray units and in-world UI elements.

If you want to test it on Quag, you should download it and modify its mapinfo as follows:
atmosphere = {
minWind = 1.0,
maxWind = 4.0,

fogStart = 0.8,
fogEnd = 2.0,
fogColor = {0.0, 0.0, 0.0},

sunColor = {0.9, 0.9, 0.9},
skyColor = {0.45, 0.1, 0.6},
skyDir = {0.0, 0.0, -1.0},
skyBox = "",

cloudDensity = 0.8,
cloudColor = {0.85, 0.6, 0.8},
},

Also, for some people on linux+nvidia-proprietary, this would happen. I'm not sure if it happens on non-Quag maps.
Would it be possible to use the LOS texture as a mask to the texture used for noise?
It is possible and it should not be expensive. In fact, using the volume fog as "literal fog of war" has been suggested, but that would be a game shader thing and not a map shader thing.

I guess once/if the issues with this are sorted, i'll make a "literal fog of war" version :)

Additionally, this technique could possibly be extended to render smoke or explosions. That would, however, require one to basically engineer fourth dimensional functions for the rendered objects, something that returns the volume opacity (or even color) for a given point in space-time (x,y,z,t).
not on the other (test with Quagmire, Linux, Nvidia with prop. drivers, text. compr. off). I see a small change when switching widget on/off, but definetely not the clouds as on the working system (no error message in infolog). Can't spot the difference ATM.
Can you post your springsettings? Preferably all of them, that is:
1) ~/.spring/springsettings.txt
2) ~/.springrc
3) ~/.config/spring/springsettings.txt

I have some suspicions, let's see if that works.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Volumetric Ground Clouds

Post by gajop »

Github it?
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Volumetric Ground Clouds

Post by Anarchid »

Dunno if it makes sense to github a single widget that would be better served as part of Blueprint. But since i already have it in a git repo, i'll do that anyway.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Volumetric Ground Clouds

Post by gajop »

Still better than a .zip. If it's really one file you can use https://gist.github.com/
But seeing you also have instructions, maybe a real project?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Volumetric Ground Clouds

Post by jK »

Anarchid wrote:Dunno if it makes sense to github a single widget that would be better served as part of Blueprint. But since i already have it in a git repo, i'll do that anyway.
Just fork blueprint?
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Volumetric Ground Clouds

Post by smoth »

why not add it? I mean once you get the chance to once over the code?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Volumetric Ground Clouds

Post by gajop »

smoth wrote:why not add it? I mean once you get the chance to once over the code?
Thats how it gets added usually. Fork, commit and send pull requests
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Volumetric Ground Clouds

Post by Anarchid »

Here's the repository.

The reason i didn't add it to blueprint yet is that - as i've mentioned above - at some point i failed to make it activate/deactivate based on map options like the other things do in Blueprint.

jK seems to have given me a not very high grade for this homework and said he has fixes that more than double the performance (155fps ->320fps).
User avatar
qray
Posts: 377
Joined: 02 Feb 2009, 18:49

Re: Volumetric Ground Clouds

Post by qray »

Anarchid wrote: Can you post your springsettings? Preferably all of them, that is:
1) ~/.spring/springsettings.txt
2) ~/.springrc
3) ~/.config/spring/springsettings.txt

I have some suspicions, let's see if that works.
Attached to this post. I have only one settings file (payed very much attention to this after having some problems; and just checked it again).
Attachments
springsettings.cfg
(1.98 KiB) Downloaded 12 times
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Volumetric Ground Clouds

Post by PicassoCT »

Actually the nuke is in production hell..

Code: Select all

//NUKE
#define NukeHeight 180

//COLUMN
#define ColumnRadiusMin 50
#define ColumnHeight(frame) 

//CIRCLCOLUM
#define CIRCLCOLUM_RAD(frame) 
#define CIRCLCOLUM_DIAMETER(frame) 

//CORIUM
#CoriumMax     160
#CoriumHeight(frame)
#CoriumDiameter(frame)
#CoriumYScalar(frame)

//ANIMATION
#define MaxFrame 1200

#define Stage_BlindingLight 0
#define Stage_Exploded 1
#define Stage_RisingUp 2
#define Stage_PunchingAirLayers 3;
#define Stage_Peak 4

void nuke(vec3 pos, int frame)
{

corium(vec3 pos,int frame);
outClouds(vec3 pos, int frame);

}

int partOfCubeApproximation(vec3 pos, vec3 dim, vec3 posInQuestion)
{
}

int within(int min, int val, int max)
{return min < val && val > max;}

int Stage(int frame)
{
if (within(0,frame,150)) return Stage_BlindingLight;
if (within(150,frame,300)) return Stage_Exploded;
if (within(301,frame,560)) return Stage_RisingUp;
if (within(561,frame,780)) return Stage_PunchingAirLayers;
if (within(781,frame,MaxFrame)) return Stage_Peak;

}

void randNom()
{
	return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}

int coriumPos(frame)
{if (Stage(frame)== StageMax) 
	return NukeHeight+15;
 else
	return NukeHeight/MaxFrame* frame+15;	
}




//Explodes at start
void corium(vec3 pos,int frame)
{

int condition=Stage(frame);

switch (condition)
case Stage_BlindingLight: {break;}
case Stage_Exploded		: {break;}
case Stage_RisingUp		: {break;}
case Stage_PunchingAirLayers		: {break;}
case Stage_Peak		: {break;}
default: {break;}
};

vec3 colourGradientByCoriumDistance()
{
	
}

//how far out from the colum do the clouds move .. distance follows a streched upwards and squeezed sidewars x^2 - 
//scaled sidwards by time
void outClouds(vec3 pos, int frame)
{

};
What do i have to do with your shadder- to get something simple. Like SC2s drifting dust/sand?
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Volumetric Ground Clouds

Post by Anarchid »

Drifing sand is what it does by default, see the Red Comet screenshot.

With assistance from federation jK, the compression issue has also been fixed.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Volumetric Ground Clouds

Post by PicassoCT »

Anarchid wrote:Drifing sand is what it does by default, see the Red Comet screenshot.

With assistance from federation jK, the compression issue has also been fixed.
It does this?
http://youtu.be/qZkcstuf2Fw?t=2m15s
Cant really check cause shadder-challenged grafics card on laptop.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Volumetric Ground Clouds

Post by Anarchid »

Less pretty, but basically yes.

It doesn't bend with terrain (though it could easily enough), and it doesn't move dunes :)

The original reason for existence of this entire thing was that some people in ZK decided that our Featured maps need to be nicened up, and a whole "touch-up" project started. Its first target was Red Comet, and i somehow volunteered to make something to draw Martian dust storms.

I though it would take a week.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Volumetric Ground Clouds

Post by PicassoCT »

who volunteered for the skybox?
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Volumetric Ground Clouds

Post by Anarchid »

Noone; is default.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Volumetric Ground Clouds

Post by jK »

needs more pics!
Image
Attachments
fog.jpg
(162.94 KiB) Downloaded 1 time
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Volumetric Ground Clouds

Post by PicassoCT »

Volumetric Fire

Code: Select all

vec3 savannahFire(vec3 pos, float groundHeight, int timeSinceSpotStartedBurning)
 {
vec3 returnVec= new Vec3(0,0,0);
if (timeSinceSpotStartedBurning <= 0) return returnVec;
 //smoke rises with temprature, which we will assume is doing a log curve from the start
float heat= log(timeSinceSpotStartedBurning+1)*600;
 //assuming that the smoke starts to pour out immediatly and cools over a distance of 300 meters
 // smoke rises 0.376 m/s
 float maxHeight= min(300,0.376*time);
 //our colourgradient stretches over the whole distance;
 float colourgrad={0.2; 0;3; 0.8;1;}
 float mygrad=pos.y/maxHeight;
 
 if (colourgrad[1] >=mygrad) return orangeFire(); 
 if (colourgrad[2] >=mygrad) return redGlowSmoke(); 
 if (colourgrad[3] >=mygrad) return blackThickSmoke(); 
 if (colourgrad[4] >=mygrad) return greySmoke(); 
 
 }
 
 void randNom()
{
	return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}

 vec3 orangeFire()
 {
 return new Vec3(	mixAPair(randNom(),1,0.95),
					mixAPair(randNom(),0.6,0.9),
					0.2f);
 }
 
 vec3 redGlowSmoke()
 {
 return new Vec3(	mixAPair(randNom(),1,0.6),
					mixAPair(randNom(),0.3,0.1),
					0.05f);
 }
 
  vec3 blackThickSmoke()
 {
 return new Vec3(	mixAPair(randNom(),0.4,0.1),
					mixAPair(randNom(),0.2,0.1),
					mixAPair(randNom(),0.2,0.1));
 }  
 
 vec3 greySmoke()
 {
 return new Vec3(	mixAPair(randNom(),0.5,0.7),
					mixAPair(randNom(),0.45,0.7),
					mixAPair(randNom(),0.54,0.7));
 }
 
 
 float mixAPair(float rand, valx, valy)
 {return valX*rand + valy*(1-rand);}
Post Reply

Return to “Map Creation”