By Eugene Kukshinov
As I promised in my previous blog post, I will explain how I created a virtual environment (VE) in Blender and Unity for my study. It is a virtual replica of the VR studio at the Scholars Studio which can be used as a transitional space to other VEs, ensuring a more immersive virtual experience.
Because I needed to make a specific room, i.e. with specific measurements, I had to model it separately. One of the ways to do this is via Blender, an open-access 3d-modeling software. Although Blender is not the most precise tool for 3d modeling, it is useful to know how it works because it is quite multifunctional. In general, all transformations are based on moving, scaling, and rotating, not just the object itself, but its elements (or a combination of them), i.e. vertices, edges, and faces.
Image taken from Blender.org
One of the ways to recreate a room in Blender is to use blueprints or some version of it (also you will need to add a one m^2 reference square, as the red one seen below). Before you start modeling, you need to change the dimensions of the initial cube (it appears in every new project), which sides are two meters long, to make them one meter long. Pressing the [N] button (in the ‘object’ mode, which can be changed by [Tab]), the dimensions should be put down to 1x1x1 (not scaling).
After that, you can:
- Add an Image → as Reference.
- Then, using the existing reference cube, you need to scale [S] the image scrolling enough so the cube is placed above the 1m^2 square.
- Also, use [G] to move around the cube.
- All of that should be done in the object mode that can be switched to by [Tab].
Now, you can use the cube you have to make one wall but before that you need to know the height of your room to make this first wall or column. Once you shape the cube into proper dimensions (doorway or windows can be done later), you can start extruding [E] faces to make the other walls from the same object. One of the reasons why it is necessary to use Blender instead of Unity3D is because not all angles of the room I need to design are 90 degrees.
Doorway and windows
Creating a doorway and/or a window is possible via the modifier “Boolean” with “Difference” option:
- First, it is necessary to shape a new object into the shape of the hole you need to make in the room
- Place the properly shaped new object inside the relevant area in the wall
- Then, you need to choose the room in object mode, add modifier and add a new shaped object into modifier slot which will cut the hole by ‘Apply’ing the modifier.
In the end:
- Make a surface for the floor (while not creating a ceiling until Unity) with a plane
- Delete the reference blueprint.
- Also, it is essential to go to Object→ Apply → Scale to set the current model measures as default.
- After that, you can export the model as a .fbx file which can be imported to Unity.
To start, you will need to create an account and install Unity3D. The basic version is free to download and use. In general, you can get most of the objects you need (including some basic room or even entire VEs) in the asset store that also has free objects and other VE elements. The only job is to place them in a way that suits you, i.e. moving, scaling, and rotating objects.
Image taken from Unity
When you start a new project in Unity, you will see a new empty scene that only has a basic camera and a source of light. All of that can be seen in the Hierarchy window (usually on the left side), which includes all elements used in your scene. Usually on the bottom, there is a project window with all the files that you have and can use. Usually on the right side, there is an inspector window which displays all the information about a selected object.
Most of the objects (in .fbx format) I used in Unity I downloaded from cgtrader.com or other similar websites that have free 3d models. But, if you need more detailed and specific models, then you can create them in Blender with more training. To note, downloading assets in the last version of Unity is possible only through the website but uploading should be done in Unity through Package manager, i.e. it is confusing.
Once you have all the objects you need, you can:
- Put them in your scene and see how it looks.
- If you export objects outside of the Unity asset store, extract materials of the objects (can be seen in the Inspector menu on the right side), which will then allow you to manipulate them.
- Manipulate two main qualities in the materials that are smoothness and metallic features, which is basically the level of how reflective the object is.
The way your scene looks heavily depends on how you manipulate the materials’ features and how you place your lighting. Each new scene in Unity has a basic camera and a lighting source, or the directional light.
- Default directional light is basically a sun in Unity, if you rotate it, it will change the light as if the daytime changes. There are other sources of light that can be added and that will help to lighten up your space (unless it is not an outside space).
- Point light basically lights up everything around its range. Point lights with lower range and intensity (all can be changed in the Inspector) can be used in the lamps to add a glowing effect.
- Spot light is like a flashlight, it is a good option to use for many lamps and other light sources.
Images taken from Unity
If you need to include, for instance, a moving object into your VR scene, it is easy to do with animation. First, you need to add an Animation via the Window menu. Save the animation file into a separate folder as much as any other type of objects in the Project window. Once you choose the object you want to make a simple animation with (like moving back and forth):
- Select the object
- Push the Record button
- Double-click on the timeline in how many seconds you want the object to move
- Physically move the object to that position.
- In the end, you need to copy the initial keyframes of the object so it could come back to the position it was before.
To note, the timeline in the animation window is in seconds (1.00 is one second).
To use this environment with a VR headset you will need to replace the basic camera with the VR one. For that you need to go to the Build setting -> Player setting -> XR (and install XR management plugin). If you use Oculus headsets, you can install the Oculus Integration asset to get the VR camera. After that, you can replace your basic camera with the VR one, and the VE can be used.
In the end, creating a simple virtual environment can be done just in Unity with existing models and objects. Making it look and sound more realistic will take much more time and learning. At the same time, making it ‘interactive’ or creating an interface will require to learn scripting/coding in C#. It all depends on your needs. Good luck!