Smoke/Gas effect

Posted By: LawnmowerMan

Smoke/Gas effect - 09/30/15 19:14

I need the ambient effect of evaporation gas from swampy water, smoke or something like. It is for static cut scene in my horror game. I'm sure I've seen it somewhere before, but after days of searching, I have not found anything like it. If anyone could share some code or texture I would be most grateful.

Thanks!
Posted By: Anonymous

Re: Smoke/Gas effect - 09/30/15 19:25

Particle effect maybe,
Screen shader maybe
Posted By: Realspawn

Re: Smoke/Gas effect - 10/09/15 10:26

is there a picture so you can show what you mean ? laugh
Posted By: LawnmowerMan

Re: Smoke/Gas effect - 10/09/15 19:18

I not found the best example, but something like this https://www.youtube.com/watch?v=yUdJU5xEajI
Posted By: Realspawn

Re: Smoke/Gas effect - 10/09/15 21:28

This one creates excellet fog you can make thicker or more
translucent. Make sure you have 2 dust graphics if you use it.


Code:
#define max_alpha skill1
#define max_fog 150

var cam_fog = 100; // needs to be a variable so it can get closer and further away to the camera as needed
VECTOR wind;

void set_alpha() 
{
	var fade_speed = 0.5;
	// fade model in
	my.alpha=70;
	my.max_alpha = integer(random(30));
	if(my.max_alpha < 10){ my.max_alpha = 25; }
	
	while(my.alpha < my.max_alpha)
	{
		my.alpha += fade_speed*time_step;
		wait(1);
	}
	my.alpha = my.max_alpha;
}

void fog_wind()
{
	while(1)
	{
		// new wind direction...
		vec_set(wind.x, vector((random(1) - .5)*1.5, (random(1) - .5)*1.5, random(1)*.4));
		wait(-5 + random(3));
	}
}

void move_fog()
{
	var roll_speed;
	var fade_distance = cam_fog+(cam_fog/6);
	var fog_speed = 20;
	
	roll_speed = random(2)-1; 
	
	while(me)
	{
		my.roll += roll_speed*time_step; //roll this sprite
		
		// update position globally
		c_move(my, nullvector, vector(random(fog_speed)*wind.x*time_step, random(fog_speed)*wind.y*time_step, 0), IGNORE_PASSABLE);
		
		// fade sprite when close to camera
		if(vec_dist(my.x, camera.x) < fade_distance) 
		{
			my.alpha = minv(my.max_alpha, vec_dist(camera.x, my.x) * my.max_alpha / fade_distance);
		}
		
		wait(1);
	}
}

void autofog()
{
	VECTOR cam_pos;
	var randint;
	
	vec_scale(my.scale_x, 0.8);
	set(my, PASSABLE | TRANSLUCENT); // can add BRIGHT, but slows FPS down
	
	//fade in slowly
	set_alpha();
	move_fog();
	
	while(me)
	{
		if(my.alpha < my.max_alpha) { my.alpha += time_step; }
		
		vec_set(cam_pos, camera.x);
		cam_pos.z = my.z;
		
		if(vec_dist(my.x, cam_pos) >= cam_fog)
		{
			// fade the fog out
			while(my.alpha > 0) { my.alpha -= time_step; wait(1); }
			
			// set on new position at edge of fog distance
			vec_set(my.x, vector(cycle(my.x, camera.x - cam_fog, camera.x + cam_fog), cycle(my.y, camera.y - cam_fog, camera.y + cam_fog), camera.z - random(100) + random (200)));
		}
		
		wait(5);
	}
}

void generate_fog()
{
	var randint; // random fog sprite
	var fogcount;
	
	VECTOR pos_place;
	
	fog_wind(); // sets a random fog position every so often
	
	for(fogcount=0; fogcount<max_fog; fogcount++)
	{
		// set random position around camera
		vec_set(pos_place.x, vector(((camera.x - random(cam_fog)) + (camera.x + random(cam_fog))), ((camera.y - random(cam_fog)) + (camera.y + random(cam_fog))), ((camera.z - random(cam_fog/4)) + random(cam_fog/2))));
		//		vec_set(pos_place.x, nullvector);
		
		// get a random number
		randint = integer(random(2));
		// create different fog, based on random number
		if(randint == 0){ ent_create("Dust_1.tga", pos_place, autofog); }
		if(randint == 1){ ent_create("Dust_2.tga", pos_place, autofog); }
	}
}

Posted By: LawnmowerMan

Re: Smoke/Gas effect - 10/10/15 15:05

Thank you, I already have this code in my game. Sorry my example video is not good. I found good example in video from Superku game https://www.youtube.com/watch?v=hIsjyAhVo68
I need to smoke coming from the ground, or swamp, as in the video at 1:07 where smoke coming from lava, and slowly disappearing not so far from land.
Posted By: Anonymous

Re: Smoke/Gas effect - 10/11/15 17:16

@Lawn---Man, I need more info about your project. You referenced Superku, is you project a 2d,2.5d, 3d side scroller like Superku?

If so here are a few ideas.
Use a 2d animated sprite, attach the base to your swamp. Basically build a 2d image that graduates to full fade (32 tga alpha), apply a solid noise to it. Then use it to produce a animated sprite.

2) Use a single tga with noise, then use a shader to animate it and fade it's (possibly with a second alpha image)

3) use a 3d cube, assign a white noise texture to it, set all sides but the front facings with a full alpha texture, Use the mtl_turbulent for the standard lib to move the surface texture of the cube in a smoke like manner. Or the mtl_uvspeed possibly.
Posted By: LawnmowerMan

Re: Smoke/Gas effect - 10/12/15 15:37

Project is 3d, but the level in which is the swamp has a static camera that looks forward, without rotation, and the player should kill the monsters that come out of the swamp, just moving the target and not the camera. I just need some effect evaporation from swamp watter to make it look better, almost identical as in the second video
Malice, thank you for help. I will put aside your ideas 1 and 3. The first one beacuse it is really hard find some good and free animated sprite for this, and second I guess it is for free camera. Idea 2 sounds like that's what I need, but unfortunately I do not understand the shaders, and I do not have a idea how make texture fading, like in particles.
© 2024 lite-C Forums