MaterialX.PyMaterialXRenderGlsl Module

Inheritance diagram of MaterialX.PyMaterialXRenderGlsl

Rendering support for the OpenGL Shading Language.

class MaterialX.PyMaterialXRenderGlsl.GLTextureHandler

Bases: ImageHandler

An OpenGL texture handler class.

static create(arg0: MaterialX.PyMaterialXRender.ImageLoader) MaterialX.PyMaterialXRender.ImageHandler
acquireImage(self: MaterialX.PyMaterialXRender.ImageHandler, filePath: MaterialX.PyMaterialXFormat.FilePath, defaultColor: MaterialX.PyMaterialXCore.Color4 = <MaterialX.PyMaterialXCore.Color4 object at 0x00000251BA562170>) MaterialX.PyMaterialXRender.Image

Acquire an image from the cache or file system.

Parameters:
  • filePath – File path of the image.

  • defaultColor – Default color to use as a fallback for missing images.

Returns:

On success, a shared pointer to the acquired image.

addLoader(self: MaterialX.PyMaterialXRender.ImageHandler, arg0: MaterialX.PyMaterialXRender.ImageLoader) None

Add another image loader to the handler, which will be invoked if existing loaders cannot load a given image.

bindImage(self: MaterialX.PyMaterialXRenderGlsl.GLTextureHandler, arg0: MaterialX.PyMaterialXRender.Image, arg1: MaterialX.PyMaterialXRender.ImageSamplingProperties) bool

Bind an image.

This method will bind the texture to an active texture unit as defined by the corresponding image description. The method will fail if there are not enough available image units to bind to.

clearImageCache(self: MaterialX.PyMaterialXRender.ImageHandler) None

Clear the contents of the image cache, first releasing any render resources associated with cached images.

createRenderResources(self: MaterialX.PyMaterialXRenderGlsl.GLTextureHandler, arg0: MaterialX.PyMaterialXRender.Image, arg1: bool, arg2: bool) bool

Create rendering resources for the given image.

getFilenameResolver(self: MaterialX.PyMaterialXRender.ImageHandler) MaterialX.PyMaterialXCore.StringResolver

Return the filename resolver for images.

getReferencedImages(self: MaterialX.PyMaterialXRender.ImageHandler, arg0: MaterialX.PyMaterialXCore.Document) list[MaterialX.PyMaterialXRender.Image]

Acquire all images referenced by the given document, and return the images in a vector.

getSearchPath(self: MaterialX.PyMaterialXRender.ImageHandler) MaterialX.PyMaterialXFormat.FileSearchPath

Return the image search path.

getZeroImage(self: MaterialX.PyMaterialXRender.ImageHandler) MaterialX.PyMaterialXRender.Image

Return a fallback image with zeroes in all channels.

releaseRenderResources(self: MaterialX.PyMaterialXRenderGlsl.GLTextureHandler, image: MaterialX.PyMaterialXRender.Image = None) None

Release rendering resources for the given image, or for all cached images if no image pointer is specified.

saveImage(self: MaterialX.PyMaterialXRender.ImageHandler, filePath: MaterialX.PyMaterialXFormat.FilePath, image: MaterialX.PyMaterialXRender.Image, verticalFlip: bool = False) bool

Save image to disk.

Parameters:
  • filePath – File path to be written

  • image – The image to be saved

  • verticalFlip – Whether the image should be flipped in Y during save

Returns:

if save succeeded

setFilenameResolver(self: MaterialX.PyMaterialXRender.ImageHandler, arg0: MaterialX.PyMaterialXCore.StringResolver) None

Set the filename resolver for images.

setSearchPath(self: MaterialX.PyMaterialXRender.ImageHandler, arg0: MaterialX.PyMaterialXFormat.FileSearchPath) None

Set the search path to be used for finding images on the file system.

unbindImage(self: MaterialX.PyMaterialXRenderGlsl.GLTextureHandler, arg0: MaterialX.PyMaterialXRender.Image) bool

Unbind an image.

unbindImages(self: MaterialX.PyMaterialXRender.ImageHandler) None

Unbind all images that are currently stored in the cache.

class MaterialX.PyMaterialXRenderGlsl.GlslProgram

Bases: pybind11_object

A class representing an executable GLSL program.

There are two main interfaces which can be used. One which takes in a HwShader and one which allows for explicit setting of shader stage code.

static create() MaterialX.PyMaterialXRenderGlsl.GlslProgram

Create a GLSL program instance.

addStage(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram, arg0: str, arg1: str) None

Set the code stages based on a list of stage strings.

Parameters:
  • stage – Name of the shader stage.

  • sourceCode – Source code of the shader stage.

bind(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram) bool

Bind the program.

Returns:

False if failed

bindAttribute(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram, arg0: collections.abc.Mapping[str, MaterialX_v1_39_5::GlslProgram::Input], arg1: MaterialX.PyMaterialXRender.Mesh) None

Bind attribute buffers to attribute inputs.

Parameters:
  • inputs – Attribute inputs to bind to

  • mesh – Mesh containing streams to bind

bindLighting(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram, arg0: MaterialX.PyMaterialXRender.LightHandler, arg1: MaterialX.PyMaterialXRender.ImageHandler) None

Bind lighting.

bindMesh(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram, arg0: MaterialX.PyMaterialXRender.Mesh) None

Bind input geometry streams.

bindPartition(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram, arg0: MaterialX.PyMaterialXRender.MeshPartition) None

Bind input geometry partition (indexing).

bindTextures(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram, arg0: MaterialX.PyMaterialXRender.ImageHandler) None

Bind any input textures.

bindTimeAndFrame(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram, time: SupportsFloat = 0.0, frame: SupportsFloat = 1.0) None

Bind time and frame.

bindUniform(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram, arg0: str, arg1: MaterialX.PyMaterialXCore.Value, arg2: bool) None

Bind a value to the uniform with the given name.

bindViewInformation(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram, arg0: MaterialX.PyMaterialXRender.Camera) None

Bind view information.

build(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram) None

Build shader program data from the source code set for each shader stage.

An exception is thrown if the program cannot be built. The exception will contain a list of compilation errors.

clearBuiltData(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram) None
findInputs(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram, arg0: str, arg1: collections.abc.Mapping[str, MaterialX_v1_39_5::GlslProgram::Input], arg2: collections.abc.Mapping[str, MaterialX_v1_39_5::GlslProgram::Input], arg3: bool) None

Find the locations in the program which starts with a given variable name.

Parameters:
  • variable – Variable to search for

  • variableList – List of program inputs to search

  • foundList – Returned list of found program inputs. Empty if none found.

  • exactMatch – Search for exact variable name match.

getAttributesList(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram) dict[str, MaterialX_v1_39_5::GlslProgram::Input]

Get list of program input attributes.

Returns:

Program attributes list.

getShader(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram) MaterialX.PyMaterialXGenShader.Shader

Return the shader, if any, used to generate this program.

getStageSourceCode(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram, arg0: str) str

Get source code string for a given stage.

Returns:

Shader stage string. String is empty if not found.

getUniformsList(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram) dict[str, MaterialX_v1_39_5::GlslProgram::Input]

Get list of program input uniforms.

Returns:

Program uniforms list.

hasActiveAttributes(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram) bool

Return true if the program has active attributes.

hasBuiltData(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram) bool

Return true if built shader program data is present.

setStages(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram, arg0: MaterialX.PyMaterialXGenShader.Shader) None

Set up code stages to validate based on an input hardware shader.

Parameters:

shader – Hardware shader to use

unbind(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram) None

Unbind the program. Equivalent to binding no program.

unbindGeometry(self: MaterialX.PyMaterialXRenderGlsl.GlslProgram) None

Unbind any bound geometry.

UNDEFINED_OPENGL_PROGRAM_LOCATION = -1
UNDEFINED_OPENGL_RESOURCE_ID = 0
class MaterialX.PyMaterialXRenderGlsl.GlslRenderer

Bases: ShaderRenderer

Helper class for rendering generated GLSL code to produce images.

There are two main interfaces which can be used. One which takes in a HwShader and one which allows for explicit setting of shader stage code.

The main services provided are: Validation: All shader stages are compiled and atteched to a GLSL shader program. Introspection: The compiled shader program is examined for uniforms and attributes. Binding: Uniforms and attributes which match the predefined variables generated the GLSL code generator will have values assigned to this. This includes matrices, attribute streams, and textures. Rendering: The program with bound inputs will be used to drawing geometry to an offscreen buffer. An interface is provided to save this offscreen buffer to disk using an externally defined image handler.

static create(arg0: SupportsInt, arg1: SupportsInt, arg2: MaterialX.PyMaterialXRender.BaseType) MaterialX.PyMaterialXRenderGlsl.GlslRenderer

Create a GLSL renderer instance.

captureImage(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer, arg0: MaterialX.PyMaterialXRender.Image) MaterialX.PyMaterialXRender.Image

Capture the current contents of the off-screen hardware buffer as an image.

createProgram(*args, **kwargs)

Overloaded function.

  1. createProgram(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer, arg0: MaterialX.PyMaterialXGenShader.Shader) -> None

  2. createProgram(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer, arg0: collections.abc.Mapping[str, str]) -> None

getCamera(self: MaterialX.PyMaterialXRender.ShaderRenderer) MaterialX.PyMaterialXRender.Camera

Return the camera.

getGeometryHandler(self: MaterialX.PyMaterialXRender.ShaderRenderer) MaterialX.PyMaterialXRender.GeometryHandler

Return the geometry handler.

getImageHandler(self: MaterialX.PyMaterialXRender.ShaderRenderer) MaterialX.PyMaterialXRender.ImageHandler

Return the image handler.

getLightHandler(self: MaterialX.PyMaterialXRender.ShaderRenderer) MaterialX.PyMaterialXRender.LightHandler

Return the light handler.

getProgram(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer) MaterialX.PyMaterialXRenderGlsl.GlslProgram

Return the GLSL program.

initialize(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer, renderContextHandle: typing_extensions.CapsuleType = None) None

Internal initialization of stages and OpenGL constructs required for program validation and rendering.

Parameters:

renderContextHandle – allows initializing the GlslRenderer with a Shared OpenGL Context

render(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer) None

Render the current program to an offscreen buffer.

renderTextureSpace(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer, arg0: MaterialX.PyMaterialXCore.Vector2, arg1: MaterialX.PyMaterialXCore.Vector2) None

Render the current program in texture space to an off-screen buffer.

setCamera(self: MaterialX.PyMaterialXRender.ShaderRenderer, arg0: MaterialX.PyMaterialXRender.Camera) None

Set the camera.

setGeometryHandler(self: MaterialX.PyMaterialXRender.ShaderRenderer, arg0: MaterialX.PyMaterialXRender.GeometryHandler) None

Set the geometry handler.

setImageHandler(self: MaterialX.PyMaterialXRender.ShaderRenderer, arg0: MaterialX.PyMaterialXRender.ImageHandler) None

Set the image handler used by this renderer for image I/O.

setLightHandler(self: MaterialX.PyMaterialXRender.ShaderRenderer, arg0: MaterialX.PyMaterialXRender.LightHandler) None

Set the light handler used by this renderer for light bindings.

setSize(self: MaterialX.PyMaterialXRender.ShaderRenderer, arg0: SupportsInt, arg1: SupportsInt) None

Set the size of the rendered image.

updateUniform(self: MaterialX.PyMaterialXRender.ShaderRenderer, arg0: str, arg1: MaterialX.PyMaterialXCore.Value) None

Update the program with value of the uniform.

validateInputs(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer) None

Validate inputs for the program.

class MaterialX.PyMaterialXRenderGlsl.Input(self: MaterialX.PyMaterialXRenderGlsl.Input, arg0: SupportsInt, arg1: SupportsInt, arg2: SupportsInt, arg3: str)

Bases: pybind11_object

An input element within a Node or NodeDef.

An Input holds either a uniform value or a connection to a spatially-varying Output, either of which may be modified within the scope of a Material.

INVALID_OPENGL_TYPE = -1
property gltype
property isConstant
property location
property path
property size
property typeString
property value
class MaterialX.PyMaterialXRenderGlsl.TextureBaker

Bases: GlslRenderer

A helper class for baking procedural material content to textures.

TODO: Add support for graphs containing geometric nodes such as position and normal.

static create(arg0: SupportsInt, arg1: SupportsInt, arg2: MaterialX.PyMaterialXRender.BaseType) MaterialX.PyMaterialXRenderGlsl.TextureBaker
bakeAllMaterials(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: MaterialX.PyMaterialXCore.Document, arg1: MaterialX.PyMaterialXFormat.FileSearchPath, arg2: MaterialX.PyMaterialXFormat.FilePath) None
bakeMaterialToDoc(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: MaterialX.PyMaterialXCore.Document, arg1: MaterialX.PyMaterialXFormat.FileSearchPath, arg2: str, arg3: collections.abc.Sequence[str], arg4: str) MaterialX.PyMaterialXCore.Document
captureImage(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer, arg0: MaterialX.PyMaterialXRender.Image) MaterialX.PyMaterialXRender.Image

Capture the current contents of the off-screen hardware buffer as an image.

createProgram(*args, **kwargs)

Overloaded function.

  1. createProgram(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer, arg0: MaterialX.PyMaterialXGenShader.Shader) -> None

  2. createProgram(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer, arg0: collections.abc.Mapping[str, str]) -> None

getAverageImages(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker) bool
getBakedGeomInfoName(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker) str
getBakedGraphName(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker) str
getCamera(self: MaterialX.PyMaterialXRender.ShaderRenderer) MaterialX.PyMaterialXRender.Camera

Return the camera.

getColorSpace(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker) str
getDistanceUnit(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker) str
getExtension(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker) str
getGeometryHandler(self: MaterialX.PyMaterialXRender.ShaderRenderer) MaterialX.PyMaterialXRender.GeometryHandler

Return the geometry handler.

getHashImageNames(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker) bool
getImageHandler(self: MaterialX.PyMaterialXRender.ShaderRenderer) MaterialX.PyMaterialXRender.ImageHandler

Return the image handler.

getLightHandler(self: MaterialX.PyMaterialXRender.ShaderRenderer) MaterialX.PyMaterialXRender.LightHandler

Return the light handler.

getOptimizeConstants(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker) bool
getOutputImagePath(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker) MaterialX.PyMaterialXFormat.FilePath
getProgram(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer) MaterialX.PyMaterialXRenderGlsl.GlslProgram

Return the GLSL program.

getTextureFilenameTemplate(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker) str
getTextureSpaceMax(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker) MaterialX.PyMaterialXCore.Vector2
getTextureSpaceMin(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker) MaterialX.PyMaterialXCore.Vector2
initialize(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer, renderContextHandle: typing_extensions.CapsuleType = None) None

Internal initialization of stages and OpenGL constructs required for program validation and rendering.

Parameters:

renderContextHandle – allows initializing the GlslRenderer with a Shared OpenGL Context

render(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer) None

Render the current program to an offscreen buffer.

renderTextureSpace(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer, arg0: MaterialX.PyMaterialXCore.Vector2, arg1: MaterialX.PyMaterialXCore.Vector2) None

Render the current program in texture space to an off-screen buffer.

setAverageImages(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: bool) None
setBakedGeomInfoName(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: str) None
setBakedGraphName(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: str) None
setCamera(self: MaterialX.PyMaterialXRender.ShaderRenderer, arg0: MaterialX.PyMaterialXRender.Camera) None

Set the camera.

setColorSpace(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: str) None
setDistanceUnit(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: str) None
setExtension(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: str) None
setFilenameTemplateVarOverride(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: str, arg1: str) None
setGeometryHandler(self: MaterialX.PyMaterialXRender.ShaderRenderer, arg0: MaterialX.PyMaterialXRender.GeometryHandler) None

Set the geometry handler.

setHashImageNames(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: bool) None
setImageHandler(self: MaterialX.PyMaterialXRender.ShaderRenderer, arg0: MaterialX.PyMaterialXRender.ImageHandler) None

Set the image handler used by this renderer for image I/O.

setLightHandler(self: MaterialX.PyMaterialXRender.ShaderRenderer, arg0: MaterialX.PyMaterialXRender.LightHandler) None

Set the light handler used by this renderer for light bindings.

setOptimizeConstants(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: bool) None
setOutputImagePath(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: MaterialX.PyMaterialXFormat.FilePath) None
setSize(self: MaterialX.PyMaterialXRender.ShaderRenderer, arg0: SupportsInt, arg1: SupportsInt) None

Set the size of the rendered image.

setTextureFilenameTemplate(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: str) None
setTextureSpaceMax(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: MaterialX.PyMaterialXCore.Vector2) None
setTextureSpaceMin(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: MaterialX.PyMaterialXCore.Vector2) None
setupUnitSystem(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: MaterialX.PyMaterialXCore.Document) None
updateUniform(self: MaterialX.PyMaterialXRender.ShaderRenderer, arg0: str, arg1: MaterialX.PyMaterialXCore.Value) None

Update the program with value of the uniform.

validateInputs(self: MaterialX.PyMaterialXRenderGlsl.GlslRenderer) None

Validate inputs for the program.

writeDocumentPerMaterial(self: MaterialX.PyMaterialXRenderGlsl.TextureBaker, arg0: bool) None