Asset Transformer SDK (ex Pixyz) Material Python API functions
Read time 18 minutes
Last updated 19 hours ago addUniformProperty
Add a shader uniform parameter to the given custom pattern.
material.addUniformProperty(pattern, name, type)
Parameters
areOpaques
Check if some materials are opaques. Function will return 'False' for each material if:
The 'Opacity' Coeff is not 1.0
The 'Opacity' property is a Texture
The 'Albedo' property is a Texture and at least one pixel of the texture has an alpha value.
material.areOpaques(materials) -> core.BoolList
Parameters
Type Name Description MaterialList materials Materials to check opacity.
Returns
Type Name Description BoolList opaques For each given material, returns True if opaque or False if transparent.
clearAllMaterials
Remove and delete all the materials.
material.clearAllMaterials()
configureFunctionLogger
material.configureFunctionLogger(functionName, enableFunction, enableParameters, enableExecutionTime)
Parameters
convertFloat32To8BitsImage
Returns a new image from the given converter from 32bits float to a 8Bits (e.g. depth render map).
material.convertFloat32To8BitsImage(image32F, minValue=-1, maxValue=1, inPlace=False) -> material.Image
Parameters
Type Name Description Image image32F Image to convert. Double minValue Minimal value of the floats (will be 0 in 8bits). Double maxValue Minimal value of the floats (will be 255 in 8bits). Boolean inPlace If true, the given image is modified instead of creating a new one.
Returns
Type Name Description Image image8U The new 8bits image.
convertHeightMapToNormalMap
Convert a height map to a normal map.
material.convertHeightMapToNormalMap(hmap, height=0.5) -> material.Image
Parameters
Type Name Description Image hmap Height map reference. Double height Maximum height.
Returns
Type Name Description Image nmap Normal map.
copyMaterial
Copies a material.
material.copyMaterial(toCopy, addToMaterialLibrary) -> material.Material
Parameters
Type Name Description Material toCopy Material to copy. Boolean addToMaterialLibrary Add to material library.
Returns
Type Name Description Material material The copied material.
createCustomMaterialPattern
Create a new custom material pattern.
material.createCustomMaterialPattern(name) -> material.CustomMaterialPattern
Parameters
Type Name Description String name Name of the pattern.
Returns
createImageFromData
Import an Image from only its data.
material.createImageFromData(data, name="img") -> material.Image
Parameters
Type Name Description ByteList data The raw data as input. String name If need of a name.
Returns
Type Name Description Image image The created Image.
createImageFromDefinition
Import an image from its raw data.
material.createImageFromDefinition(imageDefinition) -> material.Image
Parameters
Returns
Type Name Description Image image The created image.
createImagesFromDefinitions
Import images from their raw data.
material.createImagesFromDefinitions(imageDefinitions) -> material.ImageList
Parameters
Returns
Type Name Description ImageList images The created images.
createMaterial
Create a new material from pattern.
material.createMaterial(name, pattern, addToMaterialLibrary=True) -> material.Material
Parameters
Type Name Description String name Name of the material. String pattern Name of the pattern. Boolean addToMaterialLibrary Name of the pattern.
Returns
Type Name Description Material material The created material.
createMaterialFromDefinition
Create PBR material from a material definition.
material.createMaterialFromDefinition(materialDefinition) -> material.Material
Parameters
Type Name Description MaterialDefinition materialDefinition The structure containing all the PBR material information.
Returns
Type Name Description Material material The created material.
createMaterialsFromDefinitions
Create PBR materials from material definitions.
material.createMaterialsFromDefinitions(materialDefinitions) -> material.MaterialList
Parameters
Type Name Description MaterialDefinitionList materialDefinitions Material definitions containing properties for each given material.
Returns
Type Name Description MaterialList materials The created materials.
createMaterialsFromMaps
Automatically creates PBR materials when importing PBR texture maps from a folder.
material.createMaterialsFromMaps(directory) -> material.MaterialFromMapsReturn
Parameters
Returns
exportImage
Export an image.
material.exportImage(image, filename)
Parameters
Type Name Description Image image Identifier of the image to export. OutputFilePath filename Filename of the file to export.
fillUnusedPixels
Fill unused pixels by propagating and averaging used pixels.
material.fillUnusedPixels(image, unusedColor=core.ColorAlpha(0., 0., 0., 0.), size=-1, validityMask=0, inPlace=False) -> material.Image
Parameters
Type Name Description Image image Image to process. ColorAlpha unusedColor Color used to identify unused pixels. Int size Dilation size in pixels. Image validityMask Image describing which texels are valid (color set to white) and which ones need to be filled (color set to black). If zero, unusedColor is used instead. Boolean inPlace If True, the source image is modified. Otherwise, a new one is created.
Returns
Type Name Description Image filledImage Resulting image with filled pixels.
filterAO
Filter an AO map using ATrous method.
material.filterAO(aoMaps, normalMaps, sigmaPos=2.0, sigmaValue=0.2, sigmaNormal=0.2, levelCount=4, filterLowValues=True, lowValueThreshold=0.01) -> material.ImageList
Parameters
Type Name Description ImageList aoMaps Input AO Maps (the alpha component must be set to 0 for unused pixels). ImageList normalMaps Input Normal Maps (preferable to use World space normal maps, but Object space normal maps can be used too). Double sigmaPos ATrous Sigma pos. Double sigmaValue ATrous Sigma value. Double sigmaNormal ATrous Sigma normal. Int levelCount Atrous #Levels. Boolean filterLowValues Remove low values from the filtering (see: lowValuesThreshold parameter). Double lowValueThreshold Threshold used if filterLowValues is enabled.
Returns
Type Name Description ImageList filteredAOMaps The filtered AO Maps.
findCustomMaterialPatternByName
Returns the material pattern which has the given name.
material.findCustomMaterialPatternByName(name) -> material.CustomMaterialPattern
Parameters
Type Name Description String name The name of the material pattern.
Returns
findMaterialsByPattern
Returns all materials using the given pattern.
material.findMaterialsByPattern(pattern) -> material.MaterialList
Parameters
Type Name Description String pattern A material pattern.
Returns
Type Name Description MaterialList materials Materials using the pattern.
findMaterialsByProperty
Returns all materials which match a given property value.
material.findMaterialsByProperty(propertyName, propertyValue, caseInsensitive=False) -> material.MaterialList
Parameters
Type Name Description String propertyName Name of the property to match. Regex propertyValue Regular expression to match for the property value. Bool caseInsensitive If True, the regex will be insensitive to upper and lower cases.
Returns
Type Name Description MaterialList materials Materials matching the property value.
generateColorFromIndex
Generate a unique color from an index (only 16M differents color can be generated, if index is greater than 16777216, the color is not guaranted to be unique).
material.generateColorFromIndex(index) -> core.Color
Parameters
Type Name Description Int index Index.
Returns
Type Name Description Color color Color.
generateUniqueColors
Generate a set of unique colors (max 16M differents color can be generated, if count is greater than 16777216, the colors are not guaranted to be unique).
material.generateUniqueColors(count) -> core.ColorList
Parameters
Type Name Description Int count Number of unique colors to generate.
Returns
Type Name Description ColorList colors Count unique colors.
getAllImages
Returns all the images loaded in the current session or from a list of materials.
material.getAllImages(materials=[]) -> material.ImageList
Parameters
Type Name Description MaterialList materials Materials to retrieve the images from (returns all images loaded in the current session if empty).
Returns
Type Name Description ImageList images A list containing all images identifiers.
getAllMaterialPatterns
Returns all the material patterns in the current session.
material.getAllMaterialPatterns() -> core.StringList
Returns
Type Name Description StringList shaders A list containing all material patterns.
getAllMaterials
Retrieve the list of all the materials in the material library.
material.getAllMaterials() -> material.MaterialList
Returns
Type Name Description MaterialList materials List of materials in the material library.
getColorMaterialInfos
Get color material properties.
material.getColorMaterialInfos(material) -> material.ColorMaterialInfos
Parameters
Type Name Description Material material The material to get properties.
Returns
getCustomMaterialPattern
Returns the custom material pattern associated to the custom material.
material.getCustomMaterialPattern(material) -> material.CustomMaterialPattern
Parameters
Type Name Description Material material Custom material to get the pattern from.
Returns
getExportImageFormats
Returns image format names and extensions which can be exported in Pixyz.
material.getExportImageFormats() -> core.FormatList
Returns
Type Name Description FormatList formats Image formats that can be exported.
getImageDefinition
Returns the raw data of an image.
material.getImageDefinition(image) -> material.ImageDefinition
Parameters
Type Name Description Image image Image's definition.
Returns
getImageDefinitions
Returns the raw data of a set of images.
material.getImageDefinitions(images) -> material.ImageDefinitionList
Parameters
Type Name Description ImageList images The images.
Returns
getImagePixelColor
Returns the color of a given pixel in an image.
material.getImagePixelColor(image, x, y) -> core.ColorAlpha
Parameters
Type Name Description Image image The image to get the pixel from. Int x The x pixel coordinates. Int y The y pixel coordinates.
Returns
Type Name Description ColorAlpha color The color of the pixel at the x,y position.
getImageSize
Returns the size of an image.
material.getImageSize(image) -> core.Int, core.Int
Parameters
Type Name Description Image image The image to get the size from.
Returns
Type Name Description Int width The width of the image in pixels. Int height The height of the image in pixels.
getImagesSizes
Returns the sizes of multiple images.
material.getImagesSizes(images) -> core.IntList, core.IntList
Parameters
Type Name Description ImageList images The image to get the size from.
Returns
Type Name Description IntList widths The widths of the images in pixels. IntList heights The heights of the images in pixels.
getImportImageFormats
Returns the image format names and extensions which can be imported in Pixyz.
material.getImportImageFormats() -> core.FormatList
Returns
Type Name Description FormatList formats Image formats that can be imported.
getImpostorMaterialInfos
Get impostor texture material properties.
material.getImpostorMaterialInfos(material) -> material.ImpostorMaterialInfos
Parameters
Type Name Description Material material The material to get properties.
Returns
getMaterialDefinition
Returns the properties of a PBR Material.
material.getMaterialDefinition(material) -> material.MaterialDefinition
Parameters
Type Name Description Material material The PBR Material.
Returns
getMaterialDefinitions
Returns the properties of a set of PBR Materials.
material.getMaterialDefinitions(materials) -> material.MaterialDefinitionList
Parameters
Returns
getMaterialMainColor
Get the main color on any material pattern type.
material.getMaterialMainColor(material) -> core.ColorAlpha
Parameters
Type Name Description Material material The material.
Returns
getMaterialPattern
Gets the MaterialPattern name of the material.
material.getMaterialPattern(material) -> core.String
Parameters
Type Name Description Material material The material to find the pattern.
Returns
Type Name Description String pattern The pattern of the material.
getMaterialPatternType
Returns the MaterialPatternType name of the material.
material.getMaterialPatternType(material) -> material.MaterialPatternType
Parameters
Type Name Description Material material The material to find the pattern.
Returns
getPBRMaterialInfos
Get PBR material properties.
material.getPBRMaterialInfos(material) -> material.PBRMaterialInfos
Parameters
Type Name Description Material material The material to get properties.
Returns
getPointsAndMaterialFromText
Returns a list of 3D Points and a material from a string and a fontname.
material.getPointsAndMaterialFromText(text, fontName, fontSize, matrix, colorInput, offset=0.0, height3D=0.0) -> geom.Point3List, geom.Point2List, geom.Vector3, material.Material, core.Double
Parameters
Type Name Description String text Input text. String fontName Fontname. Int fontSize FontSize. Matrix4 matrix Input matrix for the text. Color colorInput Color of the font needed. Double offset Input offset for the text. Double height3D Input height in 3D which will be a ratio from the textSize.
Returns
getStandardMaterialInfos
Get standard material properties.
material.getStandardMaterialInfos(material) -> material.StandardMaterialInfos
Parameters
Type Name Description Material material The material to get properties.
Returns
getUniformPropertyType
Get a shader uniform shader property type.
material.getUniformPropertyType(pattern, name) -> material.ShaderUniformType
Parameters
Returns
getUnlitTextureMaterialInfos
Get unlit texture material properties.
material.getUnlitTextureMaterialInfos(material) -> material.UnlitTextureMaterialInfos
Parameters
Type Name Description Material material The material to get properties.
Returns
importImage
Import an image.
material.importImage(filename) -> material.Image
Parameters
Type Name Description FilePath filename Filename of the image to import.
Returns
Type Name Description Image image Identifier of the imported image.
isOpaque
Check if material is opaque. Function will return 'False' if:
The 'Opacity' Coeff is not 1.0
The 'Opacity' property is a Texture
The 'Albedo' property is a Texture and at least one pixel of the texture has an alpha value.
material.isOpaque(material) -> core.Boolean
Parameters
Type Name Description Material material Material to check opacity.
Returns
Type Name Description Boolean opaque Returns True if opaque or False if transparent.
makeMaterialNamesUnique
Rename materials to have a unique name for each one.
material.makeMaterialNamesUnique(materials=[])
Parameters
Type Name Description MaterialList materials Materials to rename (rename all materials if empty).
remapIndexMap
Create remapped versions of index maps.
material.remapIndexMap(maps, maxIndices=-1) -> material.ImageList, core.IntListList
Parameters
Type Name Description ImageList maps Input Images. Int maxIndices Number max of indices remapped.
Returns
Type Name Description ImageList mappedMaps Output maps remapped. IntListList newToOldMapIndices New index to old index for each map.
resizeImage
Resize an image.
material.resizeImage(image, width, height, filteringMethod=0)
Parameters
Type Name Description Image image Image to be resize. Int width New image width. Int height New image height. ResizeFilterMethod filteringMethod Filtering method for image resizing.
setCoeffOrTextureProperty
Set a CoeffOrTexture property.
material.setCoeffOrTextureProperty(material, name, coeffOrTexture)
Parameters
Type Name Description Material material The material to apply the color on. String name The property to set. CoeffOrTexture coeffOrTexture The CoeffOrTexture to apply.
setColorAlphaProperty
Set a ColorAlpha property.
material.setColorAlphaProperty(material, name, color)
Parameters
Type Name Description Material material The material to apply the color on. String name The property to set. ColorAlpha color The color to apply.
setColorOrTextureProperty
Set a ColorOrTexture property.
material.setColorOrTextureProperty(material, name, colorOrTexture)
Parameters
Type Name Description Material material The material to apply the color on. String name The property to set. ColorOrTexture colorOrTexture The ColorOrTexture to apply.
setFragmentShader
Set the fragment shader of a custom pattern.
material.setFragmentShader(pattern, code)
Parameters
setMaterialMainColor
Set the main color on any material pattern type.
material.setMaterialMainColor(material, color)
Parameters
Type Name Description Material material The material to apply the color on. ColorAlpha color The color to apply.
setMaterialPattern
Sets the MaterialPattern name of the material.
material.setMaterialPattern(material, pattern)
Parameters
Type Name Description Material material The material to find the pattern. String pattern The pattern of the material.
setPBRMaterialInfos
Set PBR material properties.
material.setPBRMaterialInfos(material, infos)
Parameters
setVertexShader
Set the vertex shader of a custom pattern.
material.setVertexShader(pattern, code)
Parameters
updateImageFromDefinition
Update an image from its raw data.
material.updateImageFromDefinition(image, imageDefinition)
Parameters
Type Name Description Image image The image to update. ImageDefinition imageDefinition The new data to apply.
updateImagesFromDefinitions
Update images from their raw data.
material.updateImagesFromDefinitions(image, imageDefinitions)
Parameters
userData
getMaterialUserData
Set or replace a userdata stored on an material.
material.getMaterialUserData(userDataId, material) -> core.Ptr
Parameters
Type Name Description MaterialUserData userDataId UserData identifier provided by subscribeToMaterialUserData. Material material Material that store the user data.
Returns
Type Name Description Ptr userData User data stored in the given material.
See also:
getMultipleMaterialUserData
Batch version of getMaterialUserData.
material.getMultipleMaterialUserData(userDataId, materials) -> core.PtrList
Parameters
Type Name Description MaterialUserData userDataId UserData identifier provided by subscribeToMaterialUserData. MaterialList materials Materials that store the user data.
Returns
Type Name Description PtrList userDataList User data stored for each given material.
See also:
hasMaterialUserData
Set or replace a userdata stored on an material.
material.hasMaterialUserData(userDataId, material) -> core.Bool
Parameters
Type Name Description MaterialUserData userDataId UserData identifier provided by subscribeToMaterialUserData. Material material Material that potentially store the user data.
Returns
Type Name Description Bool result Returns true if a userdata is stored on this material for the given userDataId.
See also:
hasMultipleMaterialUserData
Batch version of hasMaterialUserData.
material.hasMultipleMaterialUserData(userDataId, materials) -> core.BoolList
Parameters
Type Name Description MaterialUserData userDataId UserData identifier provided by subscribeToMaterialUserData. MaterialList materials Materials that potentially store the user data.
Returns
Type Name Description BoolList results Returns an array of bool that are true if a userdata is stored on the material at the same index for the given userDataId.
See also:
setMaterialUserData
Set or replace a userdata stored on an material.
material.setMaterialUserData(userDataId, material, userData)
Parameters
Type Name Description MaterialUserData userDataId UserData identifier provided by subscribeToMaterialUserData. Material material Material that will store the user data. Ptr userData User data to store in the given material.
See also:
setMultipleMaterialUserData
Batch version of setMaterialUserData.
material.setMultipleMaterialUserData(userDataId, materials, userDataList)
Parameters
Type Name Description MaterialUserData userDataId UserData identifier provided by subscribeToMaterialUserData. MaterialList materials Materials that will store the user data. PtrList userDataList User data to store on each material.
See also:
subscribeToMaterialUserData
Subscribe to material user data. multiple different userdata can be stored on the same materials if subscribeToMaterialUserData is called multiple times.
material.subscribeToMaterialUserData() -> material.MaterialUserData
Returns
Type Name Description MaterialUserData userDataId UserData identifier to pass to setUserData/getUserData functions.
See also:
unsetMaterialUserData
Unset the userdata stored on an material.
material.unsetMaterialUserData(userDataId, material)
Parameters
Type Name Description MaterialUserData userDataId UserData identifier provided by subscribeToMaterialUserData. Material material Material that will store the user data.
See also:
unsetMultipleMaterialUserData
Batch version of unsetMaterialUserData.
material.unsetMultipleMaterialUserData(userDataId, materials)
Parameters
Type Name Description MaterialUserData userDataId UserData identifier provided by subscribeToMaterialUserData. MaterialList materials Materials that will store the user data.
See also:
unsubscribeFromMaterialUserData
material.unsubscribeFromMaterialUserData(userDataId)
Parameters
Type Name Description MaterialUserData userDataId UserData identifier to unsubscribe.
See also: