Sign in to follow this  
pot

GLSL - Particle Systems

Recommended Posts

Hi, Has anyone else read this - http://www.2ld.de/gdc2004/ In essence im trying to create a 2D particle system. What im aiming to do is have a background texture and a number of different particle textures and blend the particle system together with the background texture. So the first stage of my implementation is to parse two textures, one background and one particle through a shader and blend them together. But im not to sure the best way to do this. I can perform multitexturing where the texture coords are the same but I cant seem to work out how to do a situation like this - Does anyone have any suggestions? Im a little stuck where to start. cheers pot

Share this post


Link to post
Share on other sites
I'm not sure of your overall design, but perhaps this might spark some thought?

...

Pass in the texture's unrotated coordinates in terms of background space (as I'm sure you already are), as well as the desired rotation value.

Perform the rotation in reverse on the current fragment location in background space.

Calculate the blend as normal using this new background space location by first transforming it into the texture's space.

The centre point used to rotate the fragment location is 0.5, 0.5 in background space, , and not 0.0, 0.0 like usual. For this I would probably come up with a way to convert the texture space from 0 to 1 into -1 to 1 on both axes, perform the rotation, and then convert the new background space location back to 0 to 1 notation.

Share this post


Link to post
Share on other sites
I think I know what you mean, sounds like a good idea if im understanding you correctly.

Could you expand on your points please? Like what do u mean exactly by "Pass in the texture's unrotated coordinates in background space" - what would is background space? How do i perform rotation in the shader?

thanks
pot

Share this post


Link to post
Share on other sites
If the particle texture starts halfway across the background, then its top-left coordinate in background space is 0.5, 0.5. Of course, in its own local space, that top-left corner is 1.0, 0.0 (according to the UV mapping method you've shown in your diagram).

As for performing rotation on a point in R2, check out some elementary Linear Algebra resources. wikipedia and mathworld should have all of the info you need in order to learn rotation, translation, scaling, skewing, you name it.

See my above post for more info. I edited it after.

Do you know how I can post an image to this forum?

Share this post


Link to post
Share on other sites
cheers,

see here for image tags
http://www.gamedev.net/community/forums/faq.asp#tags>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this