SourceSubstance
SourceSubstance est un type de source où vous pouvez connecter une ressource substance.
Pour plus d’informations, voir modules resource et colormanagement.
Exemple
import substance_painter as sp
# Get the currently displayed stack
stack = sp.textureset.get_active_stack()
# Insert a fill layer
position = sp.layerstack.InsertPosition.from_textureset_stack(stack)
fill = sp.layerstack.insert_fill(position)
# Apply "Graphic to Material" in `Material` mode
graphic_to_material = sp.resource.search("s:starterassets "
"u:substance "
'n:"graphictomaterial"')[0]
source = fill.set_material_source(graphic_to_material.identifier())
# Substances can have image inputs which are sources themselves
# In this case, we use the input identifier instead of the channel type to query and edit the source
logo = sp.resource.search("s:starterassets "
"u:alpha "
'n:"logo painter"')[0]
assert "custom_image" in source.image_inputs
input_source = source.set_source("custom_image", logo)
# `input_source` is now a BitmapSource
# see BitmapSource example for further information on its interface
# In `Material` mode, you can specify how the outputs of the substance are plugged in the fill's channels
default_mapping = {
sp.textureset.ChannelType.BaseColor: "basecolor",
sp.textureset.ChannelType.Metallic: "metallic",
sp.textureset.ChannelType.Roughness: "roughness",
sp.textureset.ChannelType.Height: "height"
}
for dst_chn, identifier in default_mapping.items():
assert identifier in source.image_outputs
source.output_mapping[dst_chn] = identifier
# If not in `Material` mode, choose which output of the substance is active
# source.active_output = "basecolor"
# Retrieve and edit the substance parameters
params = source.get_parameters()
for prop_name in params.keys():
print(prop_name)
new_params = {
"outline_color": sp.colormanagement.Color(0.9, 0.7, 0.4),
"roughness": params["roughness"] / 2,
# Boolean parameters are treated as integer, if you use `True` or `False` you will get an error message:
# >>> Bad value for property 'channel_roughness': expected value of type <int32> but got <bool>
"channel_roughness": 1,
}
source.set_parameters(new_params)
# Query embedded presets and apply the first one
presets = source.get_preset_list()
for preset_name in presets:
print(preset_name)
if presets:
source.apply_preset(presets[0])
# Select the Fill layer
sp.layerstack.set_selected_nodes([fill])
classe substance_painter.source.SourceSubstance(uid) substance_painter.source.SourceSubstance
Classe qui représente une source procédurale.
propriété resource_id : ResourceID substance_painter.source.SourceSubstance.resource_id
Ressource Substance actuelle de la source.
Accélérateur : renvoie la ressource de la source.
propriété output_mapping : OutputMapping substance_painter.source.SourceSubstance.output_mapping
Propriété de mappage de sortie dans plusieurs contextes de sortie.
Accélérateur : renvoie la propriété de mappage de sortie.
Setter: définit la propriété de mappage de sortie.
propriété active_output : str substance_painter.source.SourceSubstance.active_output
Sortie active de la source dans un contexte de sortie unique.
Accentuation : renvoie l’identifiant de sortie.
Setter: définit l’identifiant de sortie.
property mask_output : str substance_painter.source.SourceSubstance.mask_output
Identifiant de sortie du masque de la source dans plusieurs contextes de sortie.
Accentuation : renvoie l’identifiant de sortie du masque.
Setter : définit l’identifiant de sortie du masque.
propriété image_input : List[str] substance_painter.source.SourceSubstance.image_inputs
Liste des entrées d’image identifiant du graphe actif.
Accentuation : renvoie l’identifiant de la liste des entrées d’image.
substance_painter.properties.Propertypropriété image_outputs : List[str] substance_painter.source.SourceSubstance.image_outputs
Liste des images en sortie identifiant du graphe en cours.
Accentuation : renvoie l’identifiant de la liste des images en sortie.
get_source(identifiant : str) -> SourceUniformColor | SourceBitmap | SourceVectorial | SourceSubstance | SourceReference | SourceFont substance_painter.source.SourceSubstance.get_source
Obtient la source pour l’identifiant d’entrée donné.
Paramètres : identifiant (str) - identifiant d’entrée.
Renvoie : la source de l’entrée.
Type de retour : SourceUniformColor | SourceBitmap | SourceVectorial | SourceSubstance | SourceReference | SourceFont
set_source(identifiant : str, source : ResourceID | Couleur | AnchorPointEffectNode) -> SourceUniformColor | SourceBitmap | SourceVectorial | SourceSubstance | SourceReference | SourceFont substance_painter.source.SourceSubstance.set_source
Définissez la source pour l’identifiant d’entrée donné.
Paramètres :
- identifiant (str) : identifiant d’entrée.
- source (ResourceID | Color | AnchorPointEffectNode) - Paramètre source.
Renvoie : la source de l’entrée.
Type de retour : SourceUniformColor | SourceBitmap | SourceVectorial | SourceSubstance | SourceReference | SourceFont
reset_source(identifiant : str) -> None substance_painter.source.SourceSubstance.reset_source
Réinitialise la source pour l’identifiant d’entrée donné.
Paramètres : identifiant (str) - identifiant d’entrée.
Type de retour : Aucun
remove_source(identifiant : str) -> None substance_painter.source.SourceSubstance.remove_source
Supprimez la source pour l’identifiant d’entrée donné.
Paramètres : identifiant (str) - identifiant d’entrée.
Type de retour : Aucun
get_parameters() -> Dict[str, bool | int | Tuple[int, int] | Tuple[int, int, int] | Tuple[int, int, int, int] | float | Tuple[float, float] | Tuple[float, float, float] | Couleur | Tuple[Couleur, flottant] | Tuple[float, float, float, float] | str] substance_painter.source.SourceSubstance.get_parameters
Obtenez les paramètres procédural source. Pour chaque propriété de la source, le dictionnaire résultant contient une entrée avec le nom de propriété comme clé et la valeur de propriété comme valeur.
Renvoie : les paramètres procédural source.
Type de retour : Dict[str, bool | int | Tuple[ int, int] | Tuple[ int, int, int] | Tuple[ int, int, int, int] | float | Tuple[ float, float] | Tuple[ float, float, float] | Couleur | Tuple[Color, float] | Tuple[ float, float, float, float] | str]
set_parameters(property_values : Dict[str, bool | int | Tuple[int, int] | Tuple[int, int, int] | Tuple[int, int, int, int] | float | Tuple[float, float] | Tuple[float, float, float] | Couleur | Tuple[Couleur, flottant] | Tuple[float, float, float, float] | str]) -> Aucun substance_painter.source.SourceSubstance.set_parameters
Définissez les paramètres procédural source.
Paramètres : property_values (Dict [ str**, bool | int | Tuple * [int,* int**] | Tuple * [int,* int , int] | Tuple [ int**, int **, int**, int*]* | Tuple [float ,float ] | Tuple [ float ,float , float]* | Couleur | Tuple**[*Couleur *, flottant*]* | Tuple[ flottant**, flottant*,* flottant**, flottant*] | str*]) : dict de propriétés à définir avec leurs valeurs correspondantes.
Type de retour : Aucun
>>> Bad value for property ‘<property\_name>’: expected value of type <int32> but got <bool>get_properties() -> Dict[str, Property] substance_painter.source.SourceSubstance.get_properties
Obtenir les propriétés procédurales de la source.
Renvoie : les propriétés procédurales source.
Type de retour : Dict[str, Property]
substance_painter.properties.Propertyget_preset_list() -> List[str] substance_painter.source.SourceSubstance.get_preset_list
Obtenez la liste de tous les paramètres prédéfinis disponibles pour cette source.
Renvoie : un tableau de tous les noms de paramètres prédéfinis disponibles.
Type de retour : List[ str]
apply_preset(name : str) substance_painter.source.SourceSubstance.apply_preset
Appliquez un paramètre prédéfini en fonction de son nom. Si aucun paramètre prédéfini portant ce nom n’est trouvé, aucune action n’est effectuée.
Paramètres : nom (str) : nom du paramètre prédéfini à appliquer.
résolution de propriété : ResolutionOverride substance_painter.source.SourceSubstance.resolution
Paramètres de résolution de cette substance.
Accélérateur : renvoie les paramètres de résolution.
Setter : définit les paramètres de résolution.
Élévations :
ValueError - si la source est utilisée dans un substance_painter.layerstack.FilterEffectNode.
classe substance_painter.source.OutputMapping(uid) substance_painter.source.OutputMapping
Cette classe donne accès au mappage de sortie d’un procédural source de manière similaire à un dict. Voir la propriété output_mapping.
Exemple :
import substance_painter as sp
mapping = a_substance_source.output_mapping
mapping[sp.textureset.ChannelType.BaseColor] = sp.textureset.ChannelType.Specular
for channel in mapping:
print(mapping[channel])