What is the best way to align grass to a terrain or mesh using VFX graph?
I’ve tried many way of doing it, and I’m not sure that VFX graph can do it.
Conditions:
Mesh Particle Output.
Normals from terrain or mesh.
I have used an orient block and it never lines up, (All options of Orient block).
I have used angles, based on normals (which is weird but I wanted to test it)
Its Bizzare. I can do it with material property blocks and custom instancing systems. (All of them)
Is this because VFX graph is not an ideal solution for mesh instances?
Edit: Please dont say read more. I have read and watched for over 20 hours and to my best guess, the current VFX graph only aligns things to one axes and it expects the camera to orient them. Nothing else makes sense at this point. And with mesh outputs (HDRP) my guess is that its impossible to distribute .5 mil meshes over a map and have accurate orientations.
Edit: Assuming a concave mesh with several undulations. IE: Terrain.
This is also using TILE/WARP Block to reuse instances.
Hello, what you are trying to achieve should be possible. Scattering small instances like rocks, grass is something where VFX Graph can be used. Now, being able to handle large number of particles will require some proper setup and optimization so that it can properly scale.
Now, having a stable orientation usually requires at least two vectors. This is true in VFX Graph but also with other solution. Most orient blocks modes allow you to orient your particles thanks to a vector and assume that the rest will be derived from the Current Camera. This is something pretty common with real-time VFX. (Billboard facing quad, etc.).
Now if you want to control both the Alignment and Facing Vector you can use the “Advanced Mode” of the Orient Block. This mode allows you to provide both AxisZ (Facing Vector) and AxisY( Aligment Vector). In the case of a terrain, you could use the terrain Normals for the AxisY and the Tangent for the AxisX. I’m guessing that if you don’t want your grass to follow the camera is because you are using Interleaved Quad meshes for the grass. Alternatively, a cross-product between the terrain normal and the World-Up could work.
To sample the Terrain normals, UVs, Tangent and other properties, just use a Sample Mesh operator, and select what you want to output in the inspector.
Here, I’m spawning particles on the terrain and storing both the tangent and normals in attributes.
From here, those attributes are used in the Advanced mode of the Orient block:
This should get you the alignment that you are looking for:
I’m just using a regular unlit quad here, but it should work for meshes.
With this setup, you can easily add some swaying motion by modulating slightly the angle.
Here I’m using some animated noise bases on the particle position:
I hope that it will help you to achieve what you are looking for. I wish you a pleasant weekend.