display module
This module exposes functions that change how the model of a project is presented
in the viewports. They correspond to settings available in the “Display
Settings” window.
The Environment Map used to light the scene can be retrieved withget_environment_resource(), or set with set_environment_resource().
The look up table (LUT) used as a Color Profile can be retrieved withget_color_lut_resource(), or set with set_color_lut_resource().
Example
import substance_painter.display
# Show the currently used color profile:
color_lut = substance_painter.display.get_color_lut_resource()
if (color_lut != None):
print(color_lut.url())
else:
print("No color profile is used.")
# Set a different color profile:
new_color_lut = substance_painter.resource.ResourceID(context="starter_assets",
name="sepia")
substance_painter.display.set_color_lut_resource(new_color_lut)
# Show the currently used environment map:
envmap = substance_painter.display.get_environment_resource()
print(envmap.url())
# Set a different environment map:
new_envmap = substance_painter.resource.ResourceID(context="starter_assets",
name="Bonifacio Street")
substance_painter.display.set_environment_resource(new_envmap)
# Show the currently active tone mapping operator:
try:
tone_mapping = substance_painter.display.get_tone_mapping()
print(tone_mapping)
except RuntimeError:
print("The project is color managed; tone mapping is not available")
# Set a different tone mapping:
try:
new_tone_mapping = substance_painter.display.ToneMappingFunction.ACES
substance_painter.display.set_tone_mapping(new_tone_mapping)
except RuntimeError:
print("The project is color managed; tone mapping is not available")
class substance_painter.display.ToneMappingFunction(value) substance_painter.display.ToneMappingFunction
Tone mapping function used in display.
This corresponds to the “Tone mapping” list in the “Camera settings” section
of the “Display settings” view.
Members:
LinearACESsubstance_painter.display.get_environment_resource() -> ResourceID | None substance_painter.display.get_environment_resource
Get the environment map resource of the active project.
Returns: The environment map resource or None.
Return type: ResourceID
Raises:
- ProjectError – If no project is opened.
- ServiceNotFoundError – If Substance 3D Painter has not started all its
services yet.
substance_painter.display.set_environment_resource(new_env_map: ResourceID) -> None substance_painter.display.set_environment_resource
Set the environment map resource of the active project.
Parameters: new_env_map (ResourceID) – The new environment map resource.
Raises:
- ProjectError – If no project is opened.
- TypeError – If
new_env_mapis not a ResourceID. - ResourceNotFoundError – If the environment map
new_env_mapis not found. - ServiceNotFoundError – If Substance 3D Painter has not started all its
services yet.
Return type: None
substance_painter.display.get_color_lut_resource() -> ResourceID | None substance_painter.display.get_color_lut_resource
Get the color profile LUT resource of the active project.
Returns: The color profile LUT resource or None.
Return type: ResourceID
Raises:
- ProjectError – If no project is opened.
- ServiceNotFoundError – If Substance 3D Painter has not started all its
services yet.
substance_painter.display.set_color_lut_resource(new_color_lut: ResourceID) -> None substance_painter.display.set_color_lut_resource
Set the color profile LUT resource of the active project.
Parameters: new_color_lut (ResourceID) – The new color profile LUT.
Raises:
- ProjectError – If no project is opened.
- TypeError – If
new_color_lutis not a ResourceID. - ResourceNotFoundError – If the color profile
new_color_lutis not found. - ServiceNotFoundError – If Substance 3D Painter has not started all its
services yet.
Return type: None
substance_painter.display.get_tone_mapping() -> ToneMappingFunction substance_painter.display.get_tone_mapping
Get the tone mapping operator used to display the current project.
In that case trying to call get_tone_mapping will throw a RuntimeError.
Returns:
-
The tone mapping function currently used by
the project.
Return type: ToneMappingFunction
Raises:
- RuntimeError – If the project is color managed.
- ProjectError – If no project is opened.
- ServiceNotFoundError – If Substance 3D Painter has not started all its
services yet.
substance_painter.display.set_tone_mapping(new_tone_mapping: ToneMappingFunction) -> None substance_painter.display.set_tone_mapping
Set the tone mapping operator to display the current project.
In that case trying to call set_tone_mapping will throw a RuntimeError.
Parameters:
new_tone_mapping (ToneMappingFunction) – The new tone mapping function
to use in the project.
Raises:
- TypeError – If
new_tone_mappingis not a ToneMappingFunction. - RuntimeError – If the project is color managed.
- ProjectError – If no project is opened.
- ServiceNotFoundError – If Substance 3D Painter has not started all its
services yet.
Return type: None
class substance_painter.display.CameraProjectionType(value) substance_painter.display.CameraProjectionType
Camera projection type.
Members:
PerspectiveOrthographicclass substance_painter.display.Camera(_camera_id: int) substance_painter.display.Camera
Allows the manipulation of the properties of an existing Camera.
Coordinates of the camera are defined in the scene space.
Example
import substance_painter.display
import substance_painter.project
substance_painter.project.open("C:/projects/MeetMat.spp")
# Get the dimensions of the scene
bounding_box = substance_painter.project.get_scene_bounding_box()
# Get the main camera
camera = substance_painter.display.Camera.get_default_camera()
# Update camera properties
camera.projection_type = substance_painter.display.CameraProjectionType.Perspective
# Move the camera away from the center of the scene
camera.position = [
bounding_box.center[0] + 15,
bounding_box.center[1],
bounding_box.center[2] + 15]
# Rotate the camera (45° of Y-axis)
camera.rotation = [0, 45, 0]
# Update the camera field of view (in degrees)
camera.field_of_view = 50
Parameters: _camera_id (int)
static get_default_camera() -> Camera substance_painter.display.Camera.get_default_camera
Get the default camera.
Returns: The default (main) camera.
Return type: Camera
Raises:
- ProjectError – If no project is opened.
- RuntimeError – If no camera has been found.
property position: List[float] substance_painter.display.Camera.position
The position (x,y,z) of the camera.
Getter: Returns the position of the camera.
Setter: Sets the position of the camera.
Type: List[float]
Raises: ProjectError – If no project is opened.
property rotation: List[float] substance_painter.display.Camera.rotation
The rotation (x,y,z) of the camera as Euler angles in degrees.
Getter: Returns the rotation of the camera.
Setter: Sets the rotation of the camera.
Type: List[float]
Raises: ProjectError – If no project is opened.
property field_of_view: float substance_painter.display.Camera.field_of_view
The field of view of the camera in degrees.
This value is only used if the CameraProjectionType is Perspective.
Getter: Returns the field of view of the camera.
Setter: Sets the field of view of the camera. Value is clamped between 3 and 179.
Type: float
Raises: ProjectError – If no project is opened.
property focal_length: float substance_painter.display.Camera.focal_length
The focal length of the camera in mm.
This value is only used if the CameraProjectionType is Perspective.
Getter: Returns the focal length of the camera.
Setter: Sets the focal length of the camera. Value is clamped between 1 and 500.
Type: float
Raises: ProjectError – If no project is opened.
property focus_distance: float substance_painter.display.Camera.focus_distance
The focus distance of the camera.
Defines the distance at which the focus point is located.
Getter: Returns the focus distance of the camera.
Setter:
Sets the focus distance of the camera.
Value is clamped between 0 and 10 * scene radius.
Type: float
Raises: ProjectError – If no project is opened.
property aperture: float substance_painter.display.Camera.aperture
The aperture of the camera. Defines how wide the Depth of Field will be.
Getter: Returns the lens radius.
Setter: Sets the lens radius. Value is clamped between 0 and 1 * scene radius.
Type: float
Raises: ProjectError – If no project is opened.
property orthographic_height: float substance_painter.display.Camera.orthographic_height
The orthographic height of the camera.
This value is only used if the CameraProjectionType is Orthographic.
Getter: Returns the orthographic height of the camera.
Setter: Sets the orthographic height of the camera.
Type: float
Raises: ProjectError – If no project is opened.
property projection_type: CameraProjectionType substance_painter.display.Camera.projection_type
The projection type (perspective or orthographic) of the camera.
Getter: Returns the projection type of the camera.
Setter: Sets the projection type of the camera.
Type: CameraProjectionType
Raises: ProjectError – If no project is opened.