Customize Non-PBR to PBR Materials Conversion before Saving 3D Scenes to GLTF 2.0 Format
Contents
[
Hide
]
The
Scene
class of the Aspose.3D API represents a 3D scene. Developers can already build a 3D scene by adding various entities. GLTF 2.0 only supports PBR (Physically Based Rendering) materials, Aspose.3D API internally converts non-PBR materials into PBR materials before exporting into GLTF 2.0 (the materials in the scene will remain unchanged during the export), and the developers can provide custom convert function to override the default behavior.
Non-PBR to PBR Material Conversion
This code example demonstrates how to convert material to PBR material, and then saves 3D scene in the GLTF format:
C#
import aspose.threed as a3d
# initialize a new 3D scene
s = a3d.Scene()
box = a3d.Box()
mat = a3d.shading.PhongMaterial()
mat.diffuse_color = Vector3(1, 0, 1)
s.root_node.create_child_node("box1", box).material = mat
opt = a3d.formats.GLTFSaveOptions(FileFormat.GLTF2);
# save in GLTF 2.0 format
s.save("test.gltf", opt);