A Preliminary Study of Unity VFX

Unity’s vfx has actually been seen in the Editor——Preference of the editor a long time ago. At that time, was I using the 2017 or 18 version? At that time, I didn't know what it was. I searched and found that there was something similar to particles, but I didn't pay attention to it, because the particle system was not familiar with it at that time. Later, it was the first time I officially came into contact with vfx in the HDRP scene, but at that time, I thought that butterflies and bamboo leaves could also be made with practical particles, so I didn't care much. until I saw these. . . . . .
insert image description here
insert image description here
insert image description here
Note: The author of the above VFX special effects is Keijiro, Unity’s Japanese distribution technology director. It’s very cool. You can go to GitHub to see his works. Obviously, GitHub portal
particles can’t do this kind of very high number and relatively smooth operation. , and then try it.

1. Preparation

Try to use a slightly newer version. I use 2020.3.3f1c1 to create a new HDRP project. Make sure you have vfx in your Assets package, if not, go to the package manager to install one.
insert image description here

Second, opening and closing

First right-click in Asset to create a new visual effect graph, and name it casually.
insert image description here
Then create a new visual effect in the scene Hierarchy panel,
insert image description here
and finally drag our new visual effect graph into the property panel of the visual effect
insert image description here

3. Description

The default vfx has nothing, what we see is similar to creating a new particle, multiple continuously generated pictures. Double-click the newly created visual effect graph to open the editing panel. It is almost such a layout. The two toggle switches in the upper right corner control the display and hiding of the two panels pointed by the arrows. . Here is a point to mention, if we download the vfx made by others and use it, we cannot use it directly after importing the project. We must go through a process of opening-compiling and saving, otherwise it will not be used without compiling.
insert image description here

1. First talk about the blackboard panel

The name of this panel is the name when you create a new visual effect graph. The function of this panel is to store some public variables, similar to creating a new script to store our static variables when programming. Click the plus sign in the upper right corner of the panel, we can see the variable types it supports besides some basic types and some unique to vfx, you can take a look at the official document. I put the document link here.
insert image description here
I will use float as an example to talk about their properties. The newly created variables are basically New + variable type. Double-click it to rename it. Whether Exposed is checked or not determines its visual effect. Whether to expose this variable on the property panel is a bit similar to [Hideininspector] in the script, value is the value, tooltip is the custom explanatory text of the variable that will be displayed when the mouse is placed on it, there are two modes, and default is our picture above form, and the range mode is to change the variable into the form of a slider (similar to a slider). When we want to use this variable in the vfx editor, we only need to right-click to create and enter the name of our variable or click on the variable and drag it to the blank space.

2. Then the Target visual effect gameobject panel

This panel will only activate the attach button when we select the visual effect in the scene. At this time, click the attach button and we can get a console to control vfx.
insert image description here

3. Here comes the key point, the rendering process of VFX

Spawn——Initialize——update——output, why do I call him the rendering process, because the life cycle of particles is called from generation to disappearance. Each small module in the large module is called a block. We click on any large module to select it, and then press the space or right mouse button to see which small modules can be added.
In the spawn module, we can control the generation rate and period of particles.
In the Initialize module, we can control the upper limit of the number of particles, life cycle, initial position, initial velocity, initial gravity, etc., by adding and modifying a series of blocks to control the initial state of particle generation, which is similar to the start in the life cycle of unity. Executed only once in the vfx rendering process.
In the update module, we can dynamically update the particle's position, angle, speed, gravity, direction, etc., usually add a series of blocks and then combine some global variables defined by ourselves to dynamically modify the value of the block through scripts or dragging to achieve what we want The change, he is similar to the update in the unity life cycle, which is continuously executed in the vfx rendering process. There are several
output modules, we can right-click in the blank space - create, and then enter output to view other types of output. It determines the appearance of individual particles: shape, color, texture, shader, etc. My understanding is that it is a bit like the ongui in the unity life cycle, which can change with the particle life cycle, and mainly performs rendering work.

insert image description here

4. Production

When we know the whole process of vfx and related modules, then we can make some cool effects by ourselves, or follow some video tutorials to do some imitation, and the key point may be to be familiar with the function of each block and constantly Learn how to use the introduction in the documentation. Here, I will share with you the production process of SDF and point cache, both of which allow us to easily combine particles into the grid shape and image properties we want.

1.SDF

Take the vfx in the picture below as an example. If we want to make a vfx in the shape of a 3D human head, it must not be very realistic for us to use various mathematical operations. Of course, there are big guys, so we can use SDF. Come on, what is SDF, please Baidu yourself. Let me tell you about the production process.
insert image description here

Step 1: Go to GitHub to download the SDF production project


After downloading unity-sdf-generator, generate the SDF file according to the project instructions, and then copy it to your VFX project. Of course, there are other similar projects on GitHub, you can choose by yourself .

Step 2: Use it in vfx

First define a public variable of Texture3D type, then select the SDF made in the first step in the value, and then drag out the variable according to the previous tutorial, and add a position block in the rendering process you need, pay attention to the position block of the SDF type , Connect the two together, so it's ok, isn't it very simple.
insert image description here

2.point cache

The point cache can be generated with the tools that come with vfx. It can generate a corresponding point cache asset file according to the grid or image you selected. We can see that it can convert the normal, UV, color and sampling of the grid The number of points is included.
insert image description here

insert image description here

Step 1: Create a point cache asset file

Through the above process, we select a picture to create a point cache asset file. You can see the position information and color information of the picture I want to use through the generated file.
insert image description here

Step 2: Use it in vfx

The difference here from SDF is that it cannot be used by defining global variables. We directly create node in the blank space, then select the point cache asset file we generated in the previous step in the asset, and finally set its location, The color is copied to the corresponding block by connecting.
insert image description here

insert image description here

Guess you like

Origin blog.csdn.net/qq_41692884/article/details/127120128