Hello tekcor,
When I studied dottore’s particlesgpu-shader-library, I tried to create a 3D version of his ParticlesGPU_2d_Dynamic behaviour.
Since he did most of it in one patch, I created some subpatches to order it in a more logical way (at least to me, I needed that in order to understand exactly what he was doing).
Anyway in the attached example, if you open ‘ParticlesGPU_3d_Dynamic help.v4p’, you will find that it contains 1 subpatch called ‘ParticlesGPU_3d_Dynamic’, which contains one shader ‘ParticlesGPU_3d_PositionVelocityCycle.fx’ (that I don’t think works totally as it should at this time), and another subpatch called ‘ParticlesGPU_DrawParticles.v4p’ (this is the one that could be of interest to you).
The shader is for calculating the particles’ positions and writing them into a texture. I hardcoded some code to rotate the particles in there.
‘ParticlesGPU_DrawParticles.v4p’ contains some code for creating a mesh and contains a shader that will draw the given texture at the positions and rotations given by the ‘data’ texture. The way I do the rotation is by calculating a new sample position based on rotation. This will make some pixels ‘fall off’ as you rotate, so it is best to take a square texture with some tranparency around, such that the whole particle will still be visible when rotated (the one I added is ok, use the ‘world map’ from girlpower as the texture if you want to see what I mean by pixels falling off).
I am using point sprites (only using 1 vertex per particle), whereas dottore’s original version needed 4 vertices per particles.
I hope this helps… The above post suggests that you should be able to apply a rotation matrix to the vertices, which would make the texture rotate? I don’t really know, so if anyone can show me how to edit the ParticlesGPU_3d_Dynamic_Constant.fx shader in order to have the sprites rotated by the vertex shader, that would be very cool.
ft’s ParticlesGPU_3d_Dynamic 02.zip (596.1 kB)