Saturday, October 27, 2018

UNITY VEG - 01 - First steps

I'll post here my trials and tribulations of learning the new VFX editor of unity called "Visual Effect Graph".

right now it's still in beta, and only work with HDRP (high def rendering pipeline), more info here : https://unity.com/visual-effect-graph

Here is the kind of stuff I have been able to do after playing with it for a evening, I already love it, I see a lot of potential !


EDIT : https://github.com/Unity-Technologies/ScriptableRenderPipeline/wiki/Visual-Effect-Graph   I just found this documentation, which make this blog post useless :P  


Installation :



Make sure you have at least 2018.3+. You can get it in the Unity hub



Then, download this : https://github.com/Unity-Technologies/ScriptableRenderPipeline/tree/release/2018.3  (Green button on the right "Clone or Download", and download ZIP). Extract it somewhere.

Once it's done, create a new project with the HDRP preset, and go to Windows > Package manager, and clic the "+" button on the bottom, and look for the Visual effect graph


First Steps :


Now let the fun begins !!

In the project we can create a new Visual Effect Graph Asset. (Right click > Visual Effect > Visual Effect Graph).
you can now drag and drop it in the scene view, and clic the Edit button start working on it.




A visual effect graph asset, out of the box


As you can see it come with a default Emitter set up, we can start looking at the node to understand what's going on.
As we can see the default system is divided into four big blocks, each of them containing multiple blocks.


  • spawn
  • Initialize
  • Upate
  • Quad Output



SPAWN:


This one seems to be responsible for...well, spawning the particles. If you right clic and try to add node, you'll see that only a few are available, and all related to spawning. It's similar to the "Emission" parameters of shuriken.

Here are a few example of different emission types.

Constant rate ( here 60 particle are spawn per second)

Periodic Burst ( here, between 20 and 30 particles are spawned each 1.5 seconds)

and before I continue, we can already see the power of the VEG : a lot of parameters have connector on the left, and we could connect parameters, math expressions, texture samples,...on those !

INITIALIZE:

the blocks in this section define the attributes of the particules when they are created, it seems to be the best place to set the lifetime, start velocity, start color,...


Everything here seems pretty straightforward :
  • Capacity : Max number of particles
  • Set Velocity Random : Assign a random velocity between two float3 for each particles
  • Set LifeTime random : Assgin a random lifetime between to float for each particles
If we right click in the Initialize section, we have a lot more node accessible. 
I'll focus only in the Attribute Section now.
It looks like you can Set Attribute of a particle in 4 way



  • Curve : Set an attribute based on a curve. The curve can be linked to anything (lifetime,speed,maths)
  • Derived : not sure yet
  • Map : Set an attribute based on a texture (didn't explore that yet)
  • Set : The simpled way to set something, just give it a value.
"Attributes" remind me a lot of Houdini points attribute. If we select the Initialize context, and look at the inspector, it seems there is a list of available attribute we can work with.


But let's not worry about this scary window for now, and try to just play with colors...
I added a "Set Color" attribute, and just added a color. By changing the inspector Random mode you can get a variation between two color.


All of this is very cool, but since the beginning, we haven't seen anything we couldn't really do with the classic Particles system (Expect that, since it's gpu particles, you can have millions of them easily :) )

UPDATE:

Onto the next section ! The Update. As it's name implies, all the blocks here should be executed every frame for each particle during its life.

I won't spend too much time here, maybe on the next post.

OUTPUT:

Right now, we only have a Quad  Output, but if you try to add a new block and type "output" you'll see that we can have a lot of stuff (Quad, Cube, Sphere, Lit or unlit, lines, points!)


Let's check how the default one is set up : 


I'll go block by block :
  • This block has no name and seems to be mandatory with Quad Output, it's the setting specific to the outputed geometry. We can set the blend mode, and the texture. Not sure if can have the ability to change the shader on the ouputs ?
  • Orient : Face Camera Plane : This one is responsible for making the quad look at the camera (billoards). If you uncheck it, you'll see what happens ! We can change the orientation type here.
  • Set Size over Life : This one will sample the curve, and set the size of the quad over its life time. One important thing to notice if you select the node : the "composition" is set to "overwrite" meaning, if you play with size before, this will totally replace it. 
  • Color/Alpha Overlife :  This one will change the color and alpha of the particles during their lifetime according to a gradient. We can see that the composition of those are set to "scale"...Looks like Scale = Multiply.

That's it for this post, please don't see this as a tutorial, but more of me thinking out loud, and trying to understand how everything work ! :)



9 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Awesome, thank you man! just started playing with it too

    ReplyDelete
  3. I download it,but it did't work .no particles appears in unity.

    ReplyDelete
    Replies
    1. Add the stuff in the Tool folder to Unity's install Tools folder

      Delete
    2. Which Tools folders do you mean Anthony? Do you mean the "pre-push" file in the ScriptableRenderPipeline/Tools?

      Delete
    3. same prob, copied pre-push file to the tools folder in unity, and still can't see VisualGraph Listed in Create, any hints?...

      Delete
  4. same prob & see this
    Shader error in 'Hidden/VFX/ParticleQuads': 'EvaluateAtmosphericScattering': no matching 1 parameter function at /Unity/ScriptableRenderPipeline-release-2018.3/com.unity.visualeffectgraph/Shaders/RenderPipeline/HDRP/VFXCommon.cginc(80) (on d3d11)

    Compiling Vertex program
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR


    u can helpme? pls

    ReplyDelete

Pinned

"This year I'll learn Learning Blender" he said for the 5th year in a row. + BforArtists

- What a fool   Context: I have 10+ years of 3DS Max experience, I initially started learning it by myself, then went to 3D school, and spen...