SourceSubstance
SourceSubstance è un tipo di origine in cui è possibile connettere una risorsa Substance.
Per ulteriori informazioni, vedere i moduli resource e colormanagement.
Esempio
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 che rappresenta un’origine procedurale.
property resource_id: ResourceID substance_painter.source.SourceSubstance.resource_id
La risorsa di sostanza corrente della sorgente.
Get: restituisce la risorsa dell’origine.
proprietà output_mapping: OutputMapping substance_painter.source.SourceSubstance.output_mapping
Proprietà di mapping dell’output in più contesti di output.
Get: restituisce la proprietà di mapping di output.
Setter: Imposta la proprietà di mapping dell’output.
proprietà active_output: str substance_painter.source.SourceSubstance.active_output
L’output attivo della sorgente nel contesto di output singolo.
Get: restituisce l’identificatore di output.
Setter: Imposta l’identificatore di output.
property mask_output: str substance_painter.source.SourceSubstance.mask_output
Identificatore di output maschera della sorgente in più contesti di output.
Get: restituisce l’identificatore di output della maschera.
Setter: imposta l’identificatore di output della maschera.
property_image_inputs: List[str] substance_painter.source.SourceSubstance.image_inputs
L’elenco degli identificatori di input dell’immagine dal grafico corrente.
Recupero: Restituisce l’elenco degli identificatori di input dell’immagine.
substance_painter.properties.Propertyimage_outputs della proprietà: List[str] substance_painter.source.SourceSubstance.image_outputs
L’elenco degli output di immagine identificatore dal grafico corrente.
Ottieni: restituisce l’elenco degli output dell’immagine in identificatore.
get_source(identificatore: str) -> SourceUniformColor | SourceBitmap | SourceVectorial | SourceSubstance | RiferimentoFonte | FontOrigine substance_painter.source.SourceSubstance.get_source
Ottiene l’origine per l’identificatore di input specificato.
Parametri: identificatore (str) - identificatore di input.
Restituisce: l’origine per l’input.
Tipo restituito: SourceUniformColor | SourceBitmap | SourceVectorial | SourceSubstance | SourceReference | SourceFont
set_source(identificatore: str, origine: ResourceID Colore | | AnchorPointEffectNode) -> SourceUniformColor | SourceBitmap | SourceVectorial | SourceSubstance | RiferimentoFonte | FontOrigine substance_painter.source.SourceSubstance.set_source
Imposta la sorgente per l’identificatore di input specificato.
Parametri:
- identificatore (str) - identificatore di input.
- source (ResourceID | Color | AnchorPointEffectNode) - Il parametro di origine.
Restituisce: L’origine dell’input.
Tipo restituito: SourceUniformColor | SourceBitmap | SourceVectorial | SourceSubstance | SourceReference | SourceFont
reset_source(identificatore: str) -> None substance_painter.source.SourceSubstance.reset_source
Reimposta la sorgente per l’identificatore di input specificato.
Parametri: identificatore (str) - identificatore di input.
Tipo restituito: Nessuno
remove_source(identificatore: str) -> Nessuno substance_painter.source.SourceSubstance.remove_source
Rimuovi l’origine per l’identificatore di input specificato.
Parametri: identificatore (str) - identificatore di input.
Tipo restituito: Nessuno
get_parameters() -> Dict[str, bool | int | Tupla[int, int] | Tupla[int, int, int] | Tupla[int, int, int, int] | flottante | Tupla[float, float] | Tupla[float, float, float] Colore | | Tupla[Colore, mobile] | Tupla[galleggiante, galleggiante, galleggiante] | str] substance_painter.source.SourceSubstance.get_parameters
Ottiene i parametri della procedurali di origine. Per ogni proprietà dell’origine, il dizionario risultante contiene una voce con il nome della proprietà come chiave e il valore della proprietà come valore.
Restituisce: I parametri procedurali dall’origine.
Tipo di valore restituito: Dict[str, bool | int | Tupla[ int, int] | Tupla[ int, int, int] | Tupla[ int, int, int, int] | flottante | Tupla[ float, float] | Tupla[ galleggiante, galleggiante, galleggiante] | Colore | Tupla[Colore, virgola mobile] | Tupla[ galleggiante, galleggiante, galleggiante] | str]
set_parameters(property_values: Dict[str, bool | int | Tupla[int, int] | Tupla[int, int, int] | Tupla[int, int, int, int] | flottante | Tupla[float, float] | Tupla[float, float, float] Colore | | Tupla[Colore, mobile] | Tupla[galleggiante, galleggiante, galleggiante] | str]) -> Nessuno substance_painter.source.SourceSubstance.set_parameters
Impostate i parametri della procedurali di origine.
Parametri: proprietà_values (Dict [ str**, bool | int | Tupla * [int,* int**] | Tupla * [int,* int , int] | Tupla [ int**, int **, int**, int*]* float | Tupla [float ,float]| Tupla [float ,float , float]* * Colore | Tupla**[*Colore *, float*]* | Tupla[ float**, float*,* float**, float* | str**]) - Numero di proprietà da impostare con i valori corrispondenti.**]
Tipo restituito: Nessuno
>>> Bad value for property ‘<property\_name>’: expected value of type <int32> but got <bool>get_properties() -> Dict[str, Proprietà] substance_painter.source.SourceSubstance.get_properties
Ottiene le proprietà della procedurali di origine.
Restituisce: Le proprietà procedurali dell’origine.
Tipo restituito: Dict[str, Proprietà]
substance_painter.properties.Propertyget_preset_list() -> Elenco[str] substance_painter.source.SourceSubstance.get_preset_list
Ottieni l’elenco di tutti i predefiniti disponibili per questa origine.
Restituisce: una matrice di tutti i nomi dei predefiniti disponibili.
Tipo restituito: Elenco[ str]
substance_painter.source.SourceSubstance.apply_preset()apply_preset(name: str) substance_painter.source.SourceSubstance.apply_preset
Applicate un predefinito dato il nome. Se non viene trovato alcun predefinito con questo nome, non viene eseguita alcuna operazione.
Parametri: name (str) - Nome del predefinito da applicare.
risoluzione proprietà: ResolutionOverride substance_painter.source.SourceSubstance.resolution
Parametri di risoluzione per questa sostanza.
Get: restituisce i parametri di risoluzione.
Setter: imposta i parametri di risoluzione.
Generazioni:
Errore valore - se l’origine è utilizzata in un substance_painter.layerstack.FilterEffectNode.
classe substance_painter.source.OutputMapping(uid) substance_painter.source.OutputMapping
Questa classe fornisce l’accesso alla mappatura dell’output di una procedurali sorgente in modo simile a dict. Vedere la proprietà output_mapping.
Esempio:
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])