Search Unity

Question VFX Graph - Copy ground shader on a top of a particle mesh

Discussion in 'Visual Effect Graph' started by Keymih, Oct 20, 2022.

  1. Keymih

    Keymih

    Joined:
    Nov 5, 2021
    Posts:
    2
    Hey guys !

    I'm not sure if I posted at the right place so feel free to scream if I didn't.

    https://gyazo.com/b057aaa8d7dba4b4de2d21f03eba2dd1

    So here is my question. In a case like in my gif, I have rocks coming out of the ground. The meshes are place holders here but in my dreams, they would have a flat top, and a muddy bottom. The top would copy the shader or at least the albedo frop the ground itself because we will have several levels very differents from each others.

    The other thing is it would need to copy the ground when the particle is born, since if it's being updated depending on the position it will slide on the mesh when it will be moving.

    I imagine it will involved a lot of different stuff and I'm willing to look it up more in detail after but I'd like to know if it sounds at least possible to you guys, and be guided to the things to look for if it is.

    Thanks in advance !
    Have a nice day.
     
  2. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    188
    Hello.

    I think what you want to achieve is doable and can be more or less tricky based on your needs.
    First you want the Surface to "Match" between the Ground and the Particle Mesh.

    Based on the Number Of Ground/levels the approach can be drastically different.

    Does all the VFX are gonna have the Same Mesh ?
    Does they all gonna have the same Behavior ? (maybe a Snowy patch will be lighter than a Rocky ground etc..)

    Let's say you have 5 different Ground/levels and you want the VFX to feel unique for each environment, you might gonna need to Create separate VFX, to create Visual and Behavior specific and unique for each levels.

    But If you have 15 different levels or more... Maybe creating unique variation is gonna be time consuming and you need to take a more procedural approach.


    To Match the Ground I guess that using the "WorldPosition" as Uvs would be the way to go.
    This Way You could Have Perfectly Matching Patterns between the ground and the VFXMesh.
    You can have more infos over here
    Unity_qvMW7sD2Jb.gif

    To avoid the Sliding, you can use the "ObjectPosition" and Subtract it to the Uvs, so that the Pattern Stay in Place. Unity_5VkmM7JV0Q.gif
    upload_2022-10-20_13-46-11.png
    In the case of the VFXGraph, the "ObjectPosition" that is Subtracted should be instead the Particles Position.
    You can do this by creating an "Expose Properties" vector and Feed the Particle Position in VFXGraph.
    upload_2022-10-20_13-47-44.png upload_2022-10-20_13-48-36.png
     
    XieJiJun, Keymih, Qriva and 1 other person like this.
  3. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    188
    So if you don't have a lot of Grounds/Lvls and that you have time to make all the VFXGraph Variants, you'll "only" need to spawn/fire the corresponding VFXGraph depending on the Levels.

    But you can also go on a more "Procedural/modular" approach...
    You should be able to create one VFXGraph with some Parameters...

    Example :
    You can Create an Exposed Properties, and Change it through script when "Firing"the VFXGraph.
    upload_2022-10-20_13-56-17.png
    This Way you should be able to pass this Infos to the Shader, and Switch Textures.

    But maybe you need different Shader based on the Level/Ground...
    In this Case, you could use the same Approach, but add Several "Output" and use of them based on this Exposed Properties.
    upload_2022-10-20_14-5-36.png
    Note that if the Number of Levels is high, this approach might be bad for performances..

    The nice thing, is that editing/updating one VFXGraph of Ground will propagate to all the different ground type

    I don't know if it's answer all your questions, but I hope that I will help a little.
    I guess what you really should keep in mind is that the "Best Solution/approach" is dependent on your needs/use case. You really need to properly "frame" what you want to achieve, what really matter (Visual ?Ability to easily update all VFXG Grounds etc...) as each Solution have their Strength and Weakness.
     
    Keymih likes this.
  4. Keymih

    Keymih

    Joined:
    Nov 5, 2021
    Posts:
    2
    Dayum that's a detailed answer, thanks a lot !

    I think I'll indeed have a lot of different levels, and even inside one the ground could have different variations in it. I'll have to experiment with all you said because I'd really like to have the ground texture only on top of my mesh, and make a muddy shader for the bottom part so I don't know if the VFX Graph can understand a mix of shader depending of the normals or something ? I suppose it's possible.

    I really do not use enough the these custom properties tho, thanks for this hint aswell !

    I'll try to work a bit with all you gave me. Have a nice day !
     
    OrsonFavrel likes this.