vrdSubstanceMaterial¶
-
class
vrdSubstanceMaterial
¶
(Inherits vrdBRDFMaterial
)
This class is used to handle all substance archive based material properties.
See vrdSubstanceProperties for a snippet on how to query all properties including the exposed substance input parameters contained in the substance archive, and VRED built-in properties (names start with __vred_ prefix) of the material like texture mapping settings.
Snippet for accessing the built-in texture settings of a substance material:
def getSubstanceProperty(substance_mat, propertyName):
properties = substance_mat.getProperties()
obj = PySide6.QtCore.QObject()
properties.update(obj, 0)
return obj.property(propertyName)
mat = vrMaterialService.findMaterial("MaterialName")
# Change the texture mapping type to UVMapping and set the UV repeat:
ts = getSubstanceProperty(mat, "__vred_textureSettings")
# ts is a vrdTexture object
ts.setMappingType(vrTextureTypes.MappingType.UVMapping)
ts.setRepeat(QVector2D(2,3))
print("UV Repeat:", ts.getRepeat())
# Change the displacement height:
dtex = getSubstanceProperty(mat, "__vred_displacementTexture")
# dtex is a vrdDisplacementTexture object or None if the material does not have a displacement
if dtex:
dtex.setDisplacementHeight(2.0)
# Change the bump intensity:
btex = getSubstanceProperty(mat, "__vred_bumpTexture")
# btex is a vrdBumpTexture object or None if the material does not have a normal map
if btex:
btex.setBumpIntensity(0.5)
To change an input parameter of a substance material, use the vrdSubstanceMaterial.setProperty(graphName, parameterId, value) method.
Summary¶
- Functions:
- applyPreset(index, applyMode, setDefaultOutputSize)
- clearPresets()
- createPreset(name) → vrdSubstancePreset
- exportPresets(indexes, path) → bool
- getActiveAttributeGroups() → List[vrdAttributeGroup]
- getActiveGraphIndex() → integer
- getActiveGraphName() → string
- getActiveGraphProperty(parameterId) → QVariant
- getArchivePath() → string
- getGraphCount() → integer
- getGraphName(index) → string
- getPreset(index) → vrdSubstancePreset
- getPresetCount() → integer
- getPresets() → List[vrdSubstancePreset]
- getProperties() → vrdSubstanceProperties
- getProperty(graphName, parameterId) → QVariant
- getSyncOutputSize() → bool
- hasArchiveData() → bool
- hasImage(name) → bool
- importPresets(pathList, importForOtherGraphs) → bool
- isArchiveValid() → bool
- isInputVisible(dependency) → bool
- loadArchive(path) → bool
- recapturePreset(index)
- removePresets(indexes) → bool
- reorderPresets(indexes)
- resetGraph()
- setActiveGraphIndex(index)
- setActiveGraphProperty(parameterId, value)
- setProperty(graphName, parameterId, value)
- setSyncOutputSize(syncOutputSize)
Functions¶
-
vrdSubstanceMaterial.
applyPreset
(index, applyMode=vrSubstanceTypes.PresetApplyMode.UsePreference, setDefaultOutputSize=False)¶ Applies a preset.
Parameters: - index (integer) – The index of the preset. The valid range is from 0 to vrdSubstanceMaterial.getPresetCount() - 1.
- applyMode (vrSubstanceTypes.PresetApplyMode) – Specifies the mode which is used for applying the preset.
- setDefaultOutputSize (bool) – If set to true, the output size is set to the values stored in the preferences
-
vrdSubstanceMaterial.
clearPresets
()¶ Remove all presets from material.
-
vrdSubstanceMaterial.
createPreset
(name)¶ Creates a preset from material.
Parameters: name (string) – Name for the new created preset Returns: The created preset Return type: vrdSubstancePreset
-
vrdSubstanceMaterial.
exportPresets
(indexes, path)¶ Export presets from material.
Parameters: - indexes (List[integer]) – List of indexes
- path (string) – The path to export to
Returns: True, if presets could be exported
Return type: bool
-
vrdSubstanceMaterial.
getActiveAttributeGroups
()¶ Gets access to all vrdAttributeGroup objects.
Returns: All vrdAttributeGroup objects Return type: List[vrdAttributeGroup]
-
vrdSubstanceMaterial.
getActiveGraphIndex
()¶ Gets the index of the active graph.
Returns: The index of the active graph. Return type: integer
-
vrdSubstanceMaterial.
getActiveGraphName
()¶ Gets the name of the active graph.
Returns: The name of the graph. Return type: string
-
vrdSubstanceMaterial.
getActiveGraphProperty
(parameterId)¶ Query the value of a substance property in the active graph.
Parameters: parameterId (string) – Property ID Returns: The value for this property Return type: QVariant
-
vrdSubstanceMaterial.
getArchivePath
()¶ Get the path of the underlying substance archive file.
Returns: The path of the underlying substance archive file. Return type: string
-
vrdSubstanceMaterial.
getGraphCount
()¶ Gets the number of graphs in this material.
Returns: The number of graphs. Return type: integer
-
vrdSubstanceMaterial.
getGraphName
(index)¶ Gets the name of a graph.
Parameters: index (integer) – The index of the graph. Returns: The name of the graph. Return type: string
-
vrdSubstanceMaterial.
getPreset
(index)¶ Gets a preset by index.
Parameters: index (integer) – The index of the preset. The valid range is from 0 to vrdSubstanceMaterial.getPresetCount() - 1. Returns: The preset. Return type: vrdSubstancePreset
-
vrdSubstanceMaterial.
getPresetCount
()¶ Get the number of presets.
Returns: The number presets. Return type: integer
-
vrdSubstanceMaterial.
getPresets
()¶ Returns a list of all child nodes.
Returns: The list of child nodes. Return type: List[vrdSubstancePreset]
-
vrdSubstanceMaterial.
getProperties
()¶ Returns a list of all properties.
Returns: The list of all properties. Return type: vrdSubstanceProperties
-
vrdSubstanceMaterial.
getProperty
(graphName, parameterId)¶ Query the value of a substance property.
Parameters: - graphName (string) – Name of a substance graph
- parameterId (string) – Property ID
Returns: The value for this property
Return type: QVariant
-
vrdSubstanceMaterial.
getSyncOutputSize
()¶ Returns the GUI hint, if the output size (width and height) should be synchronized.
Returns: True, if output size should be synchronized Return type: bool
-
vrdSubstanceMaterial.
hasArchiveData
()¶ Check if a substance archive file was successfully loaded.
Returns: True, if substance archive data are available. Return type: bool
-
vrdSubstanceMaterial.
hasImage
(name)¶ Check if a substance archive contain an image with a given name.
Parameters: name (string) – Name of the image Returns: True, if an image with the given name exists Return type: bool
-
vrdSubstanceMaterial.
importPresets
(pathList, importForOtherGraphs)¶ Add presets for the given material.
Parameters: - pathList (List[string]) – Preset files to import
- importForOtherGraphs (bool) – If True, all presets are imported. If False, only presets for existing graphs are imported.
Returns: True, if imported successfully
Return type: bool
-
vrdSubstanceMaterial.
isArchiveValid
()¶ Check if a substance archive file is valid.
Returns: True, if substance archive data is valid. Return type: bool
-
vrdSubstanceMaterial.
isInputVisible
(dependency)¶ Check if input is visible.
Parameters: dependency (string) – Dependency Returns: visible state Return type: bool
-
vrdSubstanceMaterial.
loadArchive
(path)¶ Load a substance archive to this material.
Parameters: path (string) – The path for the substance archive file. Returns: True, if the substance archive was successfully loaded. Return type: bool
-
vrdSubstanceMaterial.
recapturePreset
(index)¶ Recaptures the preset.
Parameters: index (integer) – Index of the preset to recapture
-
vrdSubstanceMaterial.
removePresets
(indexes)¶ Remove presets from material.
Parameters: indexes (List[integer]) – List of indexes Returns: True, if presets could be removed Return type: bool
-
vrdSubstanceMaterial.
reorderPresets
(indexes)¶ Reorders the presets of a material.
Parameters: indexes (List[integer]) – The list of new index, e.g. [1,2,3,0] to move the first preset to the end
-
vrdSubstanceMaterial.
resetGraph
()¶ Resets a graph to its default state.
-
vrdSubstanceMaterial.
setActiveGraphIndex
(index)¶ Sets the index of the active graph.
Parameters: index (integer) –
-
vrdSubstanceMaterial.
setActiveGraphProperty
(parameterId, value)¶ Sets a substance property for the active graph.
Parameters: - parameterId (string) – Property ID
- value (QVariant) – New value for the property
-
vrdSubstanceMaterial.
setProperty
(graphName, parameterId, value)¶ Sets a substance property.
Parameters: - graphName (string) – Name of the graph
- parameterId (string) – Property ID
- value (QVariant) – New value for the property
-
vrdSubstanceMaterial.
setSyncOutputSize
(syncOutputSize)¶ Sets the GUI hint, if the output size (width and height) should be synchronized.
Parameters: syncOutputSize (bool) – Defines if output size should be synchronized