procedural flares

If you are using particle systems you always need different types of smoke, flares and other “cool” textures. As I am not going to draw something in Photoshop I want them the procedural way, as usual.

The process is very simple actually. First we create a new empty image to use it as a final texture or for saving it to the disk. After the image is created programmatically we are iterating each single pixel and evaluate a final color for it. Then we load it as texture or store it to disk.

Here is a simple example loop:

for(y=0;y<imageSize;y++)
{
	for(x=0;x<imageSize;x++)
	{
		//prepare the vector from center
		vx=(imageSize/2.0f)-(float)x;
		vy=(imageSize/2.0f)-(float)y;
		vector.set(vx,vy);

		//get distance
		distance=vector.length();

		//get flare intensity
		intensity=clamp(1.0-distance/imageSize,0.0,1.0);

		//add some noise
		noise=perlin(x,y);

		//prepare color
		color.set(intensity,intensity,intensity,intensity);
		color.clamp();

		//set pixel
		image.setPixel(x,y,color);
	}
}

You could add streaks with using the angle from center, etc… I create a class with a lot of parameters to setup. Here are some examples of the outcome:

– syphobia

Advertisements

~ by syphobia on 2011-04-11.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s