Hey everyone, welcome to Introduction to Bifrost Visual Programming
In this tutorial series, you'll learn to manipulate geometry using visual programming
and use that for Bifrost simulations.
We'll start with creating a landscape and then add different effects such as fog and fire.
Here are some examples of the final scenes you'll be able to generate
if you follow all the tutorials.
Without further due, let's get started
In this first tutorial, we are going to create a terrain from a simple plane.
And here are the steps:
Starting from a plane, we get all the mesh points
Then we move the points along their normal directions based on a noise function
With the new point positions, we construct a mesh, which, in this case,
features an undulating surface
Then we increase the resolution to make the surface smoother
And we add another function to modify the shape.
The adjustments in peaks, valleys and slopes will make it look like a landscape.
As we see, here's the graph that generates this geometry.
Visual programming lets users create processes through connecting nodes.
This way you create a procedure instead of a fixed geometry,
which allows easy adjustment of parameters at any time to modify the form or effect,
everything downstream will update automatically.
For example, in this case, we can modify the shape, density and height of the mountains
without changing the structure of the graph, and without any manual adjustment.
With visual programming, you'll be able to create complex geometries and effects
with great speed and accuracy.
Now let's see how to build it from scratch.
To launch Bifrost, go to "Windows", select "Bifrost Graph Editor".
Click "Create Graph" to create a new graph.
This "input" node takes a starting geometry.
If you want to use an existing geometry, you can type in the path here.
The "output" node allows you to both visualize the results and use them in other graphs.
In this exercise, we are going to delete this input and create our own input geometry.
Our starting geometry is a plane, so let's create a plane here.
To bring it into Bifrost, hold the middle button of your mouse
and drag it into the Bifrost Graph Editor
To create a new node in Bifrost, just hit "tab",
this brings up a list of nodes organized by namespace category.
We can either select one, or type in the name of the node.
Our first step, as shown in the diagram, is to get the positions of all the mesh points.
And we can use "get_point_position" to achieve that.
This node takes a geometry and returns the coordinates of all its vertices.
Let's also get the normal vector of each point for later use.
To do that, we can use the node "get_point_normal" and connect the mesh to it.
You may notice the different shapes and colors of the ports here,
and they represent different data types.
If you hover your mouse over the port, you'll see a description of the data type.
Here the purple-ish blue color means it is an object, such as a mesh geometry,
and the square shape indicates it is a single object.
Here the green color stands for "float3", in this case, the x, y and z coordinates,
and the hat shape indicates it is an array instead of a single element.
You can click the link in the description to access the docs where you can find all the
port colors and shapes and their corresponding data types.
The next thing we are going to do is to change the point positions based on a noise function.
If we hit "tab" and type in "noise",
there are a few different types of noises we can choose from.
In this case, let's use "fractal noise".
This node takes the point positions and returns a fractal noise value for each position.
To find out what each node does, we can click the node and go to the info panel
to access the In-app docs, which provides a detailed description of its function
and the information of all the input and output parameters.
And the "parameters" panel here allows us the change the settings, which we'll play with later.
Now we have the noise values, we'll use them as the moving distances to shift the points
along their normal vectors.
To assign the noise values as magnitudes to the normal vectors,
we can use the node "multiply",
and connect both the noise values and vectors to it.
This gives us the vectors we use to move the points.
Then all we need to do is to get the "add" node,
plug in the moving vectors and the original positions.
This gives us the new positions of the points.
To modify the mesh with the new point positions, we use the node "set_point_position".
Connect the original mesh to geometry
and the new positions to positions. The out geometry is the new mesh.
To visualize the new points, we can use the nodes "point_scope" and "terminal".
Connect the new mesh to "point_geo", and the output to "diagnostic",
make sure "D" is turned on for the diagnostic view,
and now we can see all the points in the viewport.
We can change the size of the displayed points.
We can also visualize the normal vectors of the points by selecting "Enable Arrows"
and change the arrow property to "point_normal".
And we can adjust the length scale.
Now, do you notice a problem here?
All the vectors are still pointing towards the y direction like the original plane.
If we connect the out geometry to the output node,
we see that the new mesh doesn't have any shading,
that's because the normal directions aren't updated for this new mesh.
And we need to correct that.
First, let's disconnect the out geometry from the output for a moment.
To correct the normals, we need to use "update_mesh_normals",
this returns the same mesh geometry, but with correct normals.
Now if we connect the out geometry to "point_scope", we see the updated vectors.
If we set the color mode to be "normalVectors",
we'll see a color gradient based on the angles of the vectors.
If we connect the mesh to the output,
now we see this undulating geometry with correct shading in the viewport.
What if we want to change the scale and resolution? Say, making it larger and smoother.
What we can do is to select the original plane,
increase its size and resolution, say, 5 by 5, and subdivision 200 by 200,
by doing this, everything downstream updates accordingly,
and we get a larger and smoother geometry.
Let's hide the original plane to better visualize it.
If we want to change the steepness and density of the mountains,
we can go back to "fractal_noise" and adjust the frequency.
From here, we can take one step further and make a stylized landscape.
To further modify this shape, let's use "evaluate_fcurve",
which remaps the input numbers based on an editable function curve.
Connect the noise values to "x", and the output to "multiply",
and we see some changes.
If we click on the graph here, it opens a window where we can adjust the shape of the curve.
For example, we can make the mountains higher,
change their slopes,
and make the valleys lower.
We can also add points to the curve to create a plateau.
You can play with the curve and other parameters to get a landscape to your liking.
This is just one way of generating a landscape.
In the next tutorial, we'll show how to use field to create a similar landscape with more details
and complexity.
Thanks for watching. Stay tuned and see you next time!