» ParticlesGPU Shader Library
This site relies heavily on Javascript. You should enable it if you want the full experience. Learn more.

ParticlesGPU Shader Library

effect particles 3d 2d
Credits: Michael Mehling, who teached me many hlsl indispensable functions (holy tex2Dlod) while we were at Node08. Viktor Vicsek, who let me discover GPU Sprites function. Tonfilm, for many usefull HLSL transform functions taken from his ShaderTransform.

about

This Shader Library comes from a research i did in these 2 years on possibilities offered by GPU.
You will find classic particle systems via GPU but this is not the end, it's just the beginning: with a similar approach you are able to create many algorithms, shapes, behaviours...not just "particles".

Look into the Readme File for change log.

Here you find a sort of guide to the basic elements of this ParticlesGPU approach:
particlesgpu-library-guide

download

ParticlesGPU_Shader_Library 0.1.zip
09.11.10 [01:13 UTC] by dottore | 3186 downloads
Show 6 older revisions

Older Revisions

ParticlesGPU_Shader_Library 0.15.zip
22.11.10 [17:45 UTC] by dottore | 763 downloads
added 3 behaviours (2d queue, 2d verlet, 3d transform)
ParticlesGPU_Shader_Library 0.2.zip
25.12.10 [02:23 UTC] by dottore | 699 downloads
added 6 behaviours. Merry Xmas!
ParticlesGPU_Shader_Library 0.21.zip
10.01.11 [15:26 UTC] by dottore | 1205 downloads
surfaces with texture, alpha and transform working
ParticlesGPU_Shader_Library 0.3.zip
28.05.11 [01:20 UTC] by dottore | 1586 downloads
3 new behaviours. new utility folder
ParticlesGPU_Shader_Library 0.3.1.zip
19.01.12 [15:57 UTC] by dottore | 659 downloads
works in beta 27
ParticlesGPU_Shader_Library 0.3.2.zip
29.01.12 [17:45 UTC] by dottore | 2931 downloads
new behaviour: ParticlesGPU_3d_Spline_ScreenSize

Bitminster 09/11/2010 - 16:01

scrumptious.

lasal 09/11/2010 - 17:00

yeah man!
i was waiting for something like this long time ;)

aze 09/11/2010 - 18:08

yeah big up! so good to finally use gpu power for translation, scaling and stuff without knowing hlsl!

lecloneur 10/11/2010 - 13:12

Hi,

nothing works on my computer... (WIN7, big GPU and CPU). I have no idea why...

Black or white screen only.

dottore 10/11/2010 - 16:04

@lecloneur: have you got the last vvvv release?
it works with beta24.1

sebl 10/11/2010 - 17:01

wow!!!!

aze 10/11/2010 - 17:23

forgot to say only patches in the folder Behaviour are working for me, those in Sprites don't (black renderer as lecloneur) beta24.1/ati

dottore 10/11/2010 - 18:52

too bad...
strange, i compiled both VS and PS with model 3.0, but seems the problem is not this for sprites...
did you tried to set a lower number of particles? like 64 instead 512 (the default value in 2d sprite patch)
... i don't have any ATI card here, keep on with this updates, hope we'll fix it at the end.

tonfilm 10/11/2010 - 20:09

ati cards cannot access texture data in the vertex shader. in theory they could, but it would need some nasty settings, which vvvv doesnt do...

dottore 10/11/2010 - 20:33

uhm...strange, none of the library patches should work then, because in each particlesGPU shader there is texture access in VS...
...maybe the problem reported by aze has to do with Sprites draw function in hlsl (see the two lines in the technique of the shader), maybe ati has a different sintax...

aze 10/11/2010 - 20:45

couldn't help you on that.. but 64 instead of 512 doesn't change anything

alg 12/11/2010 - 15:42

Yes, sprites not work on my ati mobility 5650.

dottore 12/11/2010 - 17:30

@ ATI users:
Download "PointSprites.fx" from the old vvvvebsite (http://legacy.vvvv.org/tiki-index.php?page=User+Shaders).
If not even this works, it means the Sprite function has a different sintax on ATI.

aze 12/11/2010 - 17:57

PointSprites.fx is working on mine.. (mobility 5850)

phl 19/11/2010 - 11:47

thanks for sharing!

everyoneishappy 20/11/2010 - 15:07

Looks great, thanks for posting those!

I noticed that when I moved render window to second screen it freezes and I get a "range check error" come up in tty.
Moving it back to the first screen lets it start up again. Not sure why?

everyoneishappy 20/11/2010 - 18:02

sorry, my bad. Not sure why I'm getting this, but it's doing it with everything atm. Just first noticed when was playing with these.

Noir 20/11/2010 - 19:00

SBAM

Meierhans 22/11/2010 - 18:36

For me also most patches beside the Sprite stuff is working. ATI on notebook here, but will check on Nvidia tonight.

Thanks for these shaders, they can do really amazing things I guess. Now its just the question how to get them in motion.

m4d 22/11/2010 - 19:07

yay for teh update!!
mindblowing stuff, natan! :)

dottore 22/11/2010 - 19:59

;)

Bitminster 20/12/2010 - 12:41

oh nice update, I've got an odd problem though. In the new 3d Transform patch if I have OVER 9000! cubes the scaling is wrong, for instance if they're at uniform scale in xyz, and I have OVER 9000! then the Pitch input starts to affect scaling. Any ideas? I'm guessing it's to do with texture formats?

Noir 20/12/2010 - 19:54

SBAM PT.2

dottore 21/12/2010 - 05:29

@Bitminster: i have to say that that patch is really an experimental one i did just before posting. i didn't tested it enough and i know there are problems with it. i'll check it if have time. now I have other priorities... you will see...

@Noir: wait for SBAM PT.3 ;)

Bitminster 21/12/2010 - 11:30

awesome.

Noir 25/12/2010 - 17:00

SBAAAAM PT.3
BIG UP DOTTORE FOR THE XMAS PRESENT

Bitminster 26/12/2010 - 02:12

It's like... SBAAAA-WTF!?!!

amazing stuff.

aze 26/12/2010 - 12:41

yea awsome sbambam! thx a lot mister

catweasel 28/12/2010 - 15:11

Cool stuff :D
Been playing with the surfaces, is there any way to have the transform input transform the object, it just seems to affect the lighting of the surface at ther moment, is that a limitation of doing it in shader?

lasal 09/01/2011 - 22:10

Hey Dottore,

there is any way to make textured surfaces?

thanks for the release, and waiting for more ;)

dottore 09/01/2011 - 22:20

hi lasal,
actually it's really easy to add an image texture on the Bicubic resampled surface (is that you mean?):
in the shader just add a new texture+sampler.
then in the pixel shader multiply the color (from Phong function) with the tex2D(sampler of your texture, texCoord).
you can use the same texcoord i'm using to sample the position texture.

:)

lasal 09/01/2011 - 23:14

Hi Dottore,

i´ve tried it but maybe (for sure) i´m missing something,
could you check the pixel shader code?
thanks again

-----------------------------------------
// PIXELSHADERS:
// --------------------------------------------------------------------------------------------------
float Alpha <float uimin=0.0; float uimax=1.0;> = 1;
float4 PS(vs2ps In): COLOR
{
   // float4 col = PhongDirectional(In.NormV, In.ViewDirV, In.LightDirV)*Alpha;
   float4 col = tex2D(Samp, In.Tex2Cd); 
   col.rgb = PhongDirectional(In.NormV, In.ViewDirV, In.LightDirV);
   col.a = Alpha;
   return col ;
 
 
 
}
lasal 09/01/2011 - 23:47

Here i have the texture but it looks wrong...

float4 PS(vs2ps In): COLOR
{
    float4 col = tex2D(Samp2, PhongDirectional(In.NormV, In.ViewDirV, In.LightDirV)*Alpha);
 
   return col ;
 
 
 
}
dottore 09/01/2011 - 23:52

your code is wrong:

  • you create a float4 and assign to it the color from texture;
  • but then you overwrite the rgb channels with the phong component. in this way there will be no blend between these and your texture.

this is the correct way:

// PIXELSHADERS:
 
float Alpha <float uimin=0.0; float uimax=1.0;> = 1;
float4 PS(vs2ps In): COLOR
{
   float4 col = PhongDirectional(In.NormV, In.ViewDirV, In.LightDirV);
   col *= tex2D(Samp, In.Tex2Cd); 
   col.a *= Alpha;
 
   return col ;
}

make shure the sampler (samp) is the one from your texture.
and the texCoord are the same of the position texture.

lasal 10/01/2011 - 11:49

Hey Natan,
thanks for your response ;)
with this code i can´t see the texture, only an alternate green-black fading color,
have you check it?

thanks in advance

ari.

dottore 10/01/2011 - 15:31

ParticlesGPU release 0.21
@catweasel: now transform works on surfaces
@lasal: surfaces have texture now. look into the code to see your error ;)

lasal 10/01/2011 - 16:55

You are my new hero ;)

lasal 10/01/2011 - 17:29

Hello again,

i don´t know if i´m doing something wrong but the new shaders doesn´t show the texture and alpha pins, but they are in the code...
weird

i´ve cleaned the cache and they are still with this problem.

i will try with my version and your code.
thanks again

dottore 10/01/2011 - 17:53

beta25? use that

lasal 10/01/2011 - 18:08

of course

lasal 10/01/2011 - 18:09

i´ll check it again at home

lasal 10/01/2011 - 20:44

The same in the other computer,
has anybody the same problem?

hrovac 11/01/2011 - 16:38

helo,

 thank you for the great contribution

wow!

what is the difference between sprite3d and sprite2d?
a scale with eg xscale=0 connected to the sprite3d does the same like sprite2d? or am i missing sth?
the framerate is the same when using sprite2d

that is not a critic just for better understanding when to use what..
and
if you already wrote this down in your mentioned .pdf ... ok i will wait for the documentation

lasal 11/01/2011 - 19:24

Resolved, there was a conflict between the old and the new shaders.
thanks

catweasel 12/01/2011 - 14:50

Thank you!
I'll give them a go later :)

lasal 13/01/2011 - 12:10

Hi Dottore,

only a question,
in the 2d Dynamic field texture, is there any way to transform all the system? like in the new bicubic surface? or add to the shader a transform all pin?.

i want to make a symetrie and the only posible solution that i´ve found is to make the transform in the camera.

thanks again for your fantastic contribution.

dottore 13/01/2011 - 21:53

yes you can easily add a transform to the shader. i could do it for you but it's better that you learn how to do it. ;)
you have to declare a floa4x4 in the variables declaration part (the first part of the code) and call it as you want.
like..

float4x4 tPost <string uiname="Post Transform";>;

then in the vertex shader you must apply your input matrix transform to the vertices, after the particlesGPU transforms and just before passing the vertices to the pixel shader;
vertex position come out from the vertex shader were there's the "Out." :

Out.Pos = mul(Pos, tVP);

this means mul(Pos, tVP) is the last transformation before pixel shader (infact this transformation deform the vertex position using the viewProjection matrix, preparing them to fit into the 2d screen space)
you just have to play before this last operation.
"mul" is the function that allows you to transform vertices by a transform matrix:
position = (position, transform);
so..

Pos = mul(Pos, tPost);   
// and then:
Out.Pos = mul(Pos, tVP);

good luck!
:)

lasal 14/01/2011 - 17:32

Thanks a lot Natan,
you are very didactic, very apreciated your usefull comments.
i´ll try it.

:)

lasal 14/01/2011 - 19:54

I´ve got it!

my vertex shader now looks like this,
thanks again, i owe you a beer ;)

vs2ps VS(
    float4 Pos : POSITION,
    float4 TexCd : TEXCOORD0,
    float4 TexCdCol : TEXCOORD1)
{
    //inititalize all fields of output struct with 0
    vs2ps Out = (vs2ps)0;
 
    //get the position info from the Position-velocity texture:
    float2 particlePosition = tex2Dlod(SampData, TexCd).rg;
 
    Pos = mul(Pos, tW);
 
   //now apply the position taken from the texture
    Pos.xy += particlePosition;
 
    Out.Pos = mul(Pos, tVP);
 
    Pos = mul(Pos, tPost);   
 
 
    //then apply the tVP
    Out.Pos = mul(Pos, tVP);
 
 
    Out.TexCdCol = mul(TexCdCol, tTexCol);
 
    return Out;
}
dottore 14/01/2011 - 21:07

Good to ear you did it ;)
btw, the first Out.Pos is useless. this is better:

vs2ps VS(
    float4 Pos : POSITION,
    float4 TexCd : TEXCOORD0,
    float4 TexCdCol : TEXCOORD1)
{
    //inititalize all fields of output struct with 0
    vs2ps Out = (vs2ps)0;
 
    //get the position info from the Position-velocity texture:
    float2 particlePosition = tex2Dlod(SampData, TexCd).rg;
 
    Pos = mul(Pos, tW);
 
   //now apply the position taken from the texture
    Pos.xy += particlePosition;
   //apply the post mesh transform
    Pos = mul(Pos, tPost);   
 
    //then apply the tVP
    Out.Pos = mul(Pos, tVP);
    Out.TexCdCol = mul(TexCdCol, tTexCol);
 
    return Out;
}

bye! :)

lasal 15/01/2011 - 15:16

Thanks for the correction,
ciao ;)

sinus 16/01/2011 - 14:09

fantastic work!!!!

in my ParticlesGPU_3d_Dynamic_PosCycle help patch some connections seem to be broken. i tried to fix it, but it does not work...

allthevvvverybest,

dd

hrovac 17/01/2011 - 10:57

helo,

i tried to use the ParticlesGPU_Shader_Queue at the second graphicCard output and i got a lot of errors.
TTY said:
"access violation at adress 0043B4CA
error in the layer ParticlesGPU_Shader_Queue.fx"
and
when closing vvvv: "Exception EInvalidPointer in module vvvv.exe at 000047C9"
or
"Exception EAccess violation in module ntdll.dll at 0001B21A
access violation at adress 7C91B21A in module 'ntdll.dll'. Write of address 00000010."
or
"Exception EAccess violation in module vvvv.exe at 0000480C.
access violation at adress 0040480C in module 'vvvv.exe' Read of address FFFFFFFC."

is it just me and my NVidia GeForce 8800GTX in DualViewMode (XP32bit)
or someone else got the same problem?

when using the last renderer at screen1 it works

dottore 17/01/2011 - 16:08

@sinus: strange, is this happening with beta25 plus addons pack?

@hrovac: because we are using directly the GPU, there are many problems related to each graphic card.
in general i saw that ParticlesGPU on multiscreen is problematic: seams there's no way to share a rendered texture between two different screens; so if we evaluate the position texture (in your case the Queue shader+renderer) on the first monitor, we can't send this texture to the second screen (where there's the final render).
Try to keep all the renderer in the same screen (moving the renderer windows), also if just one goes to fullscreen.
As i said, it could also depend on your specific graphic card...
hope this will help you.
best

Natan

lasal 17/01/2011 - 20:25

I have the same behavior in most of the particles help files (not in the surface one)

Saving the render window in the other monitor works, but not in the 3d particles field, it doesn´t work for me in dualview mode :(

nvidia geforce gtx 260m, xp32.

lasal 17/01/2011 - 22:10

Hello Dottore,
only a question, in the 3d surface shader, would it be possible to adapt it for using flat shading instead phong?

how?

thanks

ari.

sinus 18/01/2011 - 01:12

hi dottore! yes, i am using the latest version of vvvv and addonpack.

hrovac 18/01/2011 - 18:21

@natan

thank you for explaining the graphiccard issue.

i have another question:
can you please explain why the fogis not working?

thanks_alex.

lasal 18/01/2011 - 20:58
Hello Dottore,
only a question, in the 3d surface shader, would it be possible to adapt it for using flat shading instead phong?

how?

thanks

ari.

i mean if would it be possible to implement the flat shading in the 3d sufaces based in the original grid size?.

Other possibility (but not the same that flat shading) is using the normal map without bicubic interpolation, but when i use a texture on the shader it looks distorted.

thanks

ari.

dottore 20/01/2011 - 16:59

ahhaha guys, there's a lot of requests coming on here... :D
the problem is atm i have no time to customize particle Shaders for every one... that's why in these days i started to write a proper guide to this library and i hope will be ready in few days. in this way you will understand how everything works and will be able to modify and try new things without my help in every step. I thing it's better, it's also more rewarding for you.
keep updated!

@sinus: i really don't know how is it possible.. try to reinstall vvvv and check if there's something missing (last directx,net 3.5,...).

Natan

lasal 20/01/2011 - 20:19

There is a lot of requests because this is an amazing library ;)
waiting for your guide to be more independent.

screamer 21/01/2011 - 19:12

hi,
for of all, vvvvery nice library, amazing. I'm triyng to use it in a multiscreen setup but it work only on the first monitor. I think it's something dx related, anyway, do you thing there's a workaround or something i can do to see the particles in all my monitors/projectors? i've tried to make a texture of the final rendering and use it splitted in 2 quads with different transforms, but nothing to do.
thx for any hint ;))

kalle 21/01/2011 - 19:46
professore; a few posts ago said
in general i saw that ParticlesGPU on multiscreen is problematic: seams there's no way to share a rendered texture between two different screens; so if we evaluate the position texture (in your case the Queue shader+renderer) on the first monitor, we can't send this texture to the second screen (where there's the final render).
Try to keep all the renderer in the same screen (moving the renderer windows), also if just one goes to fullscreen.
dottore 22/01/2011 - 11:09

@screamer: the only thing comes in my mind is to duplicate the particlesGPU system for each monitor you need. this means duplicate the whole patch containing all the shader cycles and the final renders and to place these duplicated patches one for each screen you need (also with the relative render window).
It's not at all the optimized way (and if your particle system it's already heavy in single screen, the whole renderes could be really slow...)but you can try if it works. it would be a clear clue.

screamer 22/01/2011 - 15:12

hi dottore, i thought the same thing, but i did'nt tried because of the heavy patch. anyway thx for the help, and compliments for the particlesgpu guide ;D

screamer 28/01/2011 - 14:53

hi, i write here because this seems the much similar contribution to what i'll want to do. so probably dottore is the best one to tell me if it's possible (i tried for a day, then abandoned for my poor ability in hlsl).
there's a fantastic fluidsolver (navier stokes) in the amd/ati collection (just a sample in rendermonkey). But the problem is that this shader is a complex multipass shader, with something like 50passes. Should be fantastic to split this passes in a patch with multiple shaders (something similar to the gpu transform approach i think).
anyway rendermonkey can be downloaded here: http://developer.amd.com/archive/gpu/rendermonkey/pages/default.aspx#download

bye :)

dottore 28/01/2011 - 15:42

hi screamer, you should start a new post in the forum about this idea. i spent some thoughts at node10 about a shader version of fluid solver. as you mentioned, it would take many passes... vux told me he's working on some GPGPU navier stroke solver in cuda, that would be really nice and easier...
Make a post with all your ideas and online sources, we can have a look at it

bo27 28/05/2011 - 01:50

thanks again!

everyoneishappy 28/05/2011 - 06:12

Nice update- these are hot.

Noir 28/05/2011 - 10:20

Sbaaam!

lasal 28/05/2011 - 14:06

wow!!!

Lightmare 28/05/2011 - 16:34

so badass man thankyou so much!

hrovac 30/05/2011 - 08:35

amazing great super yeah wow

u7angel 31/05/2011 - 08:53

magic stuff !

lasal 31/05/2011 - 18:25

It would be interesting to adapt the new vux behaviours to multipoint attractor, i was checking the Fibo´s multipoint attractor but it use other way to do it...

any idea?

mrboni 14/06/2011 - 22:24

When are we getting this then Vux :)

vux 27/06/2011 - 17:07

Next release, got a 3d version i forgot to put as well, so gonna make spreadable too, plus another bonus ;)

lasal 28/06/2011 - 21:07

Vux for president!

tekcor 20/07/2011 - 11:31

thanks a lot! this is so great.
almost completely changed my live :>

sebl 09/08/2011 - 12:39

is there a way to add a alpha-texture to "ParticlesGPU_SplineMesh" to control the opacity of each spline-geometry?

thx

everyoneishappy 01/09/2011 - 02:55

does anyone have working version of SplineMesh behavior handy for beta 26?

hrovac 09/09/2011 - 09:39

@everyoneishappy:

you have to change 2 shader:

inside bicubic_yresample:
all double to float

inside particleGPU_SplaneMesh:
change the name of the techniques (PhongPoint, PhongDirectional)(as mentioned here:beta-26-shader-syntax-error)

tekcor 17/09/2011 - 14:13

hey please have a look in this thread:
gpu-particles-wrong-clipping-z-buffer-problem

something is not rigth with the ParticlesGPU_3d_Constant_PPcolor.fx or for some oither reason particles are not drawn in the correct depth order.

photropik 20/09/2011 - 17:37

@Screamer; I fixed the second monitor output by opening all render windows, moving to second monitor, and then minimising back to patch.
With changing 'double' to 'float' and changing 'point' to 'pointy' and the other naming fixes, everything now appears to work perfectly on an ATI 4850.
Fabulous stuff.

Edit : The first way I tried to fix second head output was DX9Texture > AsVideo > VideoTexture. Worked, halved the frame rate.

Edit 2 : No it doesn't :o/ At least I am having a good look at the actual shader code :oD

tonfilm 20/09/2011 - 17:40

would be nice to have an update which works on all cards.

lasal 21/09/2011 - 12:22

indeed, and also the multipoint attractor would be great...

Noir 19/01/2012 - 21:20

update version per la 27 ...bravo natan!

gomi 08/04/2012 - 11:14

@photropik; could you please share your knowledge (or code ;) how you got to work the sprites functions on your ATI?

I am struggling since a week on my HD4870...

cheers

gomi 27/04/2012 - 21:16

never mind... found my own way.
finally-‚gpu-particles-working-on-ati-cards‘#

io 02/06/2012 - 14:42

Hi
is it possible to spread the emitter ON/OFF ? Or do I need to create a single shader for each instance?
S>

chico 24/07/2012 - 08:19

The Uberlibrary!

robe 10/12/2012 - 16:18

Hi, just a shout to bring this contribution on the top of the list...

Browsing youtube I found this video:http://www.youtube.com/watch?v=eSWm_VImgFQ

the behaviour of particles is simlar to vux "ParticlesGPU_2d_Dynamic_Attractor_Bounce"

I invite you to download the binary or the source code from the description or below and testing by yourself.
http://www.craigmouser.com/random/cudaparticles.ziphttp://www.craigmouser.com/random/ParticleEngine.zip

The fact is that this program works across mulpiple heads and multiple cards!

It would be possible to make this library multi-head?
Is this a limit of shader architecture in VVVV?
Is this a limit of VVVV?

Just to know
Thanks for reply.

Curveau 09/11/2013 - 14:29

Wonderful! Thank you :)

anonymous user login

Shoutbox

~17h ago

vnm: Does Intensity Pro 4K work with VideoIn(dx11)?

~5d ago

joreg: siggraph asia 2017 technical papers trailer: https://www.youtube.com/watch?v=3OGKh_9Rj_8

~6d ago

drupal_admin: we're back

~6d ago

drupal_admin: hello. maintenance reboot at 2:06am. save your work! should be back in a few minutes

~9d ago

tekcor: Following the steps of the current vvvv chat, we put up a vvvv.js dev support. https://riot.im/app/#/room/#vvvv.js:matrix.org