createMaterial¶
snippets/createMaterial.py¶
1# © 2024 Autodesk, Inc. All rights reserved.
2
3# example for creating and editing a material with API v2
4
5# create a plastic material
6mat = vrMaterialService.createMaterial("My plastic material", vrMaterialTypes.Plastic)
7
8# set the diffuse color to a beige tone. Colors need to be in linear space (gamma = 1)
9mat.setDiffuseColor(QVector3D(0.79, 0.6, 0.328))
10
11# set the roughness to 0.2 for a more shiny look. Values range from 0.0001 to 1.0
12mat.setRoughness(0.2)
13
14# load a texture and use it as diffuse map
15examplesDir = vrFileIOService.getVREDExamplesDir()
16diffuseImage = vrImageService.loadImage(examplesDir + "/textures/wood.png")
17diffuseTex = mat.getDiffuseTexture()
18diffuseTex.setImage(diffuseImage)
19diffuseTex.setUseTexture(True)
20
21# load a texture and use it as bump map
22bumpImage = vrImageService.loadImage(examplesDir + "/textures/wood2.png", vrImageTypes.LoadType.Bump)
23bumpTex = mat.getBumpTexture()
24bumpTex.setImage(bumpImage)
25bumpTex.setUseTexture(True)
26bumpTex.setBumpIntensity(5.0)