Skip to content

renderer_settings

RendererSettings

Controller for all renderer settings.

Source code in renderer_settings/renderer_settings.py
@singleton
class RendererSettings:
    """
    Controller for all renderer settings.
    """

    def __init__(self):
        self._carb_settings = carb.settings.get_settings()
        self.common_settings = CommonSettings()
        self.path_tracing_settings = PathTracingSettings()
        self.post_processing_settings = PostProcessingSettings()
        self.real_time_settings = RealTimeSettings()

    def set_setting(self, path, value):
        """
        Sets setting @path with value @value.

        Args:
            path (str): Path of the setting to set.
            value (any): Value to set for for setting @path.
        """
        if path not in self.settings:
            raise NotImplementedError(f"Setting {path} is not supported.")
        self.settings[path].set(value)

    def reset_setting(self, path):
        """
        Resets setting @path to default value.

        Args:
            path (str): Path of the setting to reset.
        """
        if path not in self.settings:
            raise NotImplementedError(f"Setting {path} is not supported.")
        self.settings[path].reset()

    def get_setting_from_path(self, path):
        """
        Get the value of setting @path.

        Args:
            path (str): Path of the setting to get.

        Returns:
            any: Value of the requested setting @path.
        """
        return self._carb_settings.get(path)

    def get_current_renderer(self):
        """
        Get the current renderer.

        Args:
            path (str): Path of the setting to get.

        Returns:
            str: the current renderer.
        """
        return RendererSettingsFactory.get_current_renderer()

    def set_current_renderer(self, renderer):
        """
        Set the current renderer to @renderer.

        Args:
            renderer (str): The renderer to set as current (e.g. Real-Time, Path-Traced).
        """
        assert (
            renderer in RendererSettingsFactory.get_registered_renderers()
        ), f"renderer must be one of {RendererSettingsFactory.get_registered_renderers()}"
        print(f"Set current renderer to {renderer}.")
        RendererSettingsFactory.set_current_renderer(renderer)

    @property
    def settings(self):
        """
        Get all available settings.

        Returns:
            dict: A dictionary of all available settings.
                Keys are setting paths and values are setting item objects. 
        """
        settings = {}
        settings.update(self.common_settings.settings)
        settings.update(self.path_tracing_settings.settings)
        settings.update(self.post_processing_settings.settings)
        settings.update(self.real_time_settings.settings)
        return settings

settings property

Get all available settings.

Returns:

Name Type Description
dict

A dictionary of all available settings. Keys are setting paths and values are setting item objects.

get_current_renderer()

Get the current renderer.

Parameters:

Name Type Description Default
path str

Path of the setting to get.

required

Returns:

Name Type Description
str

the current renderer.

Source code in renderer_settings/renderer_settings.py
def get_current_renderer(self):
    """
    Get the current renderer.

    Args:
        path (str): Path of the setting to get.

    Returns:
        str: the current renderer.
    """
    return RendererSettingsFactory.get_current_renderer()

get_setting_from_path(path)

Get the value of setting @path.

Parameters:

Name Type Description Default
path str

Path of the setting to get.

required

Returns:

Name Type Description
any

Value of the requested setting @path.

Source code in renderer_settings/renderer_settings.py
def get_setting_from_path(self, path):
    """
    Get the value of setting @path.

    Args:
        path (str): Path of the setting to get.

    Returns:
        any: Value of the requested setting @path.
    """
    return self._carb_settings.get(path)

reset_setting(path)

Resets setting @path to default value.

Parameters:

Name Type Description Default
path str

Path of the setting to reset.

required
Source code in renderer_settings/renderer_settings.py
def reset_setting(self, path):
    """
    Resets setting @path to default value.

    Args:
        path (str): Path of the setting to reset.
    """
    if path not in self.settings:
        raise NotImplementedError(f"Setting {path} is not supported.")
    self.settings[path].reset()

set_current_renderer(renderer)

Set the current renderer to @renderer.

Parameters:

Name Type Description Default
renderer str

The renderer to set as current (e.g. Real-Time, Path-Traced).

required
Source code in renderer_settings/renderer_settings.py
def set_current_renderer(self, renderer):
    """
    Set the current renderer to @renderer.

    Args:
        renderer (str): The renderer to set as current (e.g. Real-Time, Path-Traced).
    """
    assert (
        renderer in RendererSettingsFactory.get_registered_renderers()
    ), f"renderer must be one of {RendererSettingsFactory.get_registered_renderers()}"
    print(f"Set current renderer to {renderer}.")
    RendererSettingsFactory.set_current_renderer(renderer)

set_setting(path, value)

Sets setting @path with value @value.

Parameters:

Name Type Description Default
path str

Path of the setting to set.

required
value any

Value to set for for setting @path.

required
Source code in renderer_settings/renderer_settings.py
def set_setting(self, path, value):
    """
    Sets setting @path with value @value.

    Args:
        path (str): Path of the setting to set.
        value (any): Value to set for for setting @path.
    """
    if path not in self.settings:
        raise NotImplementedError(f"Setting {path} is not supported.")
    self.settings[path].set(value)