# 3D Models for Virtual Reality

3D models, defined according to what described in the section [3D Models of Assets](/vlft/kb/instantiation/3d-models.md), are not ready to be used in a VR environment. In fact, specifications related to materials and the behavior of light for rendering are required.

Several file [formats](https://en.wikipedia.org/wiki/List_of_file_formats#3D_graphics) exist to support VR. The recommended option is [GLTF](https://en.wikipedia.org/wiki/GlTF), an  open standard developed and maintained by the [Khronos Group](https://en.wikipedia.org/wiki/Khronos_Group). It supports many features, i.e., [3D model](https://en.wikipedia.org/wiki/3D_model) geometry, appearance, [scene graph](https://en.wikipedia.org/wiki/Scene_graph) hierarchy, and animation. Many CAD environments are capable of directly export models in the GLTF format.

By default, **the unit of measure in the GLTF standard is the meter**.&#x20;

In order to be ready for the use in a VR environment, 3D models of assets must be further elaborated to define materials and properties for the rendering. Depending on the expected outcome and the level of realism to achieve, two options are possible:

1. GLTF + standard materials for basic 3D representation.
2. GLTF + PBR textures for high realism.

## GLTF + Standard Materials

Basic materials can be applied with regular rendering software such as [KeyShot ](https://www.keyshot.com/)and [Solidworks](https://www.solidworks.com/) Visualize and later exported to GLTF.&#x20;

### GLTF + Standard Materials using SolidWorks Visualize

SolidWorks Visualize is a software supporting the definition of VR-ready models. When importing a Solidworks Assembly file (SLDASM) to Solidworks Visualize, a dialog pops up to select the desired grouping method to instantiate the hierarchy of the sub-components. This hierarchy must match the specifications described in the section related to [3D models of assets](/vlft/kb/instantiation/3d-models.md), while providing the user the capability of applying different materials to the different sub-components.

For this purpose, the most efficient import setting option is by “Group/Aspect”.

![Import settings in SolidWorks Visualize](/files/-MWZ5wbikt-70aYnqZ4P)

Thus, drag and drop commands in the software environment can be used to assign materials to the components in the 3D viewer/hierarchy tree. Further information related to how assign materials can be found in the official [Solidworks Visualize Manual](http://help.solidworks.com/2019/English/Visualize/c_welcome_to_solidworks_visualize.htm?id=8d46d18b274b48a29167759289c7264d#Pg0).

It is recommendable, if possible, to use basic materials (e.g. opaque plastic materials), since more complex appearances (paint materials, translucent, etc...) may cause unwanted artifacts when the model is exported to the GLTF format.

Finally, the user can export the resulting models in either the GLTF or GLB formats.

## GLTF + PBR Textures

[Physically based rendering](https://en.wikipedia.org/wiki/Physically_based_rendering) is a technique enabling an increased level of detail by adopting high resolution textures applied to the GLTF models.&#x20;

### GLTF + PBR Textures using Blender

[**Blender**](https://en.wikipedia.org/wiki/Blender_\(software\)) is a free and open-source 3D computer graphics software tool set.&#x20;

Differently from other rendering tools, Blender does not natively include materials to be applied. Thus, materials have to be collected exploiting online sources such as [CC0 Textures](https://cc0textures.com/), providing an extensive catalog of realistic looking materials that can be freely downloaded under a Creative Commons license. Each material can be downloaded either in JPG (lighter) or PNG format, with different texture resolution (from 1K to 8K). These settings will have a huge impact on the overall size of the final GLTF model, so it is important to make a trade-off between quality and size of the models. \
As a general rule of thumb, opaque materials with overall regular textures like metals, paints, and rubber can be downloaded with minimum resolution without showing clearly visible defects once applied to the model: the JPG/1K setting is valid in most cases. \
Complex materials ready for the PBR method are composed of a multilayer array of different textures (namely images) associated to different visual properties that will be eventually embedded in the model: Color, Displacement, Metalness, Normal, Roughness.

The steps to obtain realistic VR models are the following:

1. The setup of the  material is performed through the Shader Editor interface, where each level of the texture is assigned to their specific nodes. It may be necessary to fine adjust some parameters if textures appear to be off scale.&#x20;

![Blender's interface for shader editor.](/files/-MWZ9Dtet8UmLXNNWKHJ)

The user can decide to export the resulting models in the GLTF, GLB, or GLTF with separate directories for texture resources. By right-clicking the root node of the model and choosing “Select Hierarchy” all the subcomponents downstream will be selected. The "Compression" option might be needed to reduce the size of the resulting models, though it can also create some unwanted result, so it's recommendable to check the exported models afterwards.

More details can be found in the use case [3D Modelling of a Workstation for Virtual Reality](https://virtualfactory.gitbook.io/virtual-learning-factory-toolkit/use-cases/3d-modelling/3d-modelling-of-a-workstation-for-virtual-reality).

## Further resources

Further information can be found in dedicated online resources:

[Khronos Art Pipeline for glTF](https://www.khronos.org/blog/art-pipeline-for-gltf)

[THE PBR GUIDE](https://academy.substance3d.com/courses/the-pbr-guide-part-2)

[Blender 2.8 PBR Texturing for Beginners](https://www.youtube.com/watch?v=XI-pZshRp8g)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://virtualfactory.gitbook.io/vlft/kb/instantiation/3d-models/vr.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
