Jump to content
  • Advertisement
Sign in to follow this  
Prune

Clouds with less point splatting

This topic is 3416 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In case someone is interested, a simple way to decrease the number of points needed to get a decent cloud is to splat a distorted texture. Since each splatted point is no longer radially symmetric, what's needed is to change the offset into the fractal noise texture depending on the rotation angle. Playing around with the scaling value of the extracted angles, which depends on how noisy the fractal noise texture is, can give a good illusion where the change of each point roughly matches the rotation. With this, I use fewer and larger points. colMap is a radially symmetric gaussian alpha falloff with an extra border, and noiseMap has one perlin noise in the red channel, and a different one in the green.
// Vertex shader
varying vec2 pos;

attribute float size;

void main(void)
{
	gl_Position = ftransform();
	pos = gl_Vertex.xy + vec2(asin(gl_ModelViewMatrix[0].z), asin(gl_ModelViewMatrix[2].y)) * 0.075; // Randomize index by position and rotation angles
	vec4 eye = gl_ModelViewMatrix * gl_Vertex;
	gl_PointSize = size / (-eye.z);
	gl_FrontColor = gl_Color;
}

// Fragment shader
varying vec2 pos;

uniform sampler2D colMap, noiseMap;

void main(void)
{
	vec2 noise = vec2(texture2D(noiseMap, pos + gl_PointCoord * 0.2)) - 0.5;
	gl_FragColor = gl_Color * texture2D(colMap, gl_PointCoord + noise * 0.5); // Note: splat texture should have a sufficient transparent border to accomodate the maximum offset
}
The particles should be lit and sorted as per the cloud article on this site. For generating cloud data, I did something really simple, using a bunch of ellipsoids as below. The random number generator is from the excellent asmlib, which I started using initially for the faster memcpy() etc.
MersenneRandomInit(MODULE_ID);
for (int i = 0; i < 800; i += 4)
{
	float cpx, cpy, cpz;
	do // Generate random coordinates in an ellipse
	{
		cpx = 2.0f * (static_cast<float>(MersenneRandom()) - 0.5f);
		cpy = static_cast<float>(MersenneRandom()) - 0.5f;
		cpz = static_cast<float>(MersenneRandom()) - 0.5f;
	} while (0.25f * cpx * cpx + cpy * cpy + cpz * cpz > 0.25f);
	cloud = cpx * 0.67f;
	cloud[i + 1] = cpy * 0.67f;
	cloud[i + 2] = cpz * 0.67f;
	cloud[i + 3] = 100.0f * static_cast<float>(MersenneRandom()) + 200.0f; // Particle size
}
[Edited by - Prune on January 16, 2009 2:46:23 AM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Elvis Enmanuel
Cool stuff. Any screenshot?


Agreed, a couple of screenshots would be nice.

Share this post


Link to post
Share on other sites
Quote:
Original post by Prune
The particles should be lit and sorted as per the cloud article on this site.


Which article? None of the cloud articles I can find here involve a method like you discuss as far as I can see...

Are you just rendering sprites at various points that make up a cloud "volume"?

Share this post


Link to post
Share on other sites
Huh? http://www.gamedev.net/reference/articles/article2273.asp is splatting radially symmetric particles. Volume rendering by splatting is an ancient and widely used method, there must be a million papers.

Share this post


Link to post
Share on other sites
Quote:
Original post by Prune
Huh? http://www.gamedev.net/reference/articles/article2273.asp is splatting radially symmetric particles. Volume rendering by splatting is an ancient and widely used method, there must be a million papers.

I don't quite understand how you are using "red" and "green" noise channels here
(for creation an unique particles or...?)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!