This is the second part of the tutorial series about world position offset
Part 1: Transform position
Part 2: Scaling objects
If we want to scale our cube model instead of applying a position transform, we can do it too using world position offset. In this second part of the tutorial we are going to learn how to do it.
To able to do that we need to find a solution to send different information to each vertex. If we send the same position offset to all the vertices the cube will only change their position, but if each vertex has a different position offset then the model will obtain a deformation.
We can say it is a direction vector of the vertex. We can use the magnitude to the vector to increase or reduce the distance of the displacement, and the direction to control the movement direction.
To store this information in the vertices of the model we are going to use the technique of vertex painting.
We can open our model in Blender and enable the Vertex painting view using the view selector
To select only a vertex we can enable the vertex option right to the view selector, and with the Select Box select the vertex in the 3D view using left mouse click. We can hold shift key to select multiple vertices at the same time.
To select the color just right mouse click on the screen and a color picker appear.
Now we can paint all the selected vertices using the menu Paint > Set Vertex Colors
Using this steps we are going to paint the superior vertices of our model using white color and the bottom vertices using black color
We are using the color like a mask. Black vertices will not move from their position using the world position offset, but white vertices will do. As we are going to define an only vertical world position offset then the cubes will obtain a deformation equals to a scale effect of their vertical axis.
Now we can use this parameter in our UE4 Materials to apply this “mask”.
When a model with Vertex Color info is added to our project we need to check that the option of Vertex Color is set to Replace to import this info from the model.
In our material we can use the Vertex Color node to retrieve this information.
Now we can modify our previous material to use the vertex color information.
Using this material our model cubes will be scaled instead of moved from the original position
Tutorial files
You may also like:
Support this blog!
For the past year I've been dedicating more of my time to the creation of tutorials, mainly about game development. If you think these posts have either helped or inspired you, please consider supporting this blog. Thank you so much for your contribution!