Jump to content

Creating custom Vertex shader for particle objects


photo

Recommended Posts

Hi,

I want to create birds in my world, to do that I wanted to use a modified version of the particles base material to make them look like a flock of birds.
In a previously developed vertex shader a flock of birds is animated as a set of points, the animation is encoded in a texture.

So, first of all, is it possible in Unigine to directly use the data in the vertex buffer in order to modify the output of the existing vertex shader for particles to make it generate points instead of quads?
If I can do that, I can apply a geometry shader to the vertex shader's output to create 3D birds out of the generated points.

Thanks! 

Pierre

Link to comment

Hi Pierre,

Don't thing that's currently possible to modify ObjectParticles for that. But I have some suggestions for you:

If you want 3D models as birds most likely you'll have more luck with ObjectMeshCluster. Specifically look at setMeshTransform function.
In case you want 2D-like solution checkout ObjectBillboards, specifically similar function setBillboardPosition.
If non of the options are to you liking you can make your own specific object with ObjectExtern. This will allow you to create custom particles that will utilize everything you need.
As another option you can try to look at Mesh-Based particles.

Also regarding geometry shaders, i would suggest avoiding them for performance reasons.
If you want billboards what you can use is INIT_VERTEX_ID and IN_VERTEX_ID in shaders in order to get current vertex's ID. Then divide IN_VERTEX_ID by 4 to get correct ID for transformation per quad. On C++ side - send transformations for all instances with uniforms.

Hope it helps!

Link to comment
×
×
  • Create New...