MaterialX 1.39.1
Loading...
Searching...
No Matches
ShaderRenderer Class Reference

Base class for renderers that generate shader code to produce images. More...

#include <ShaderRenderer.h>

Inheritance diagram for ShaderRenderer:
GlslRenderer OslRenderer TextureBaker< GlslRenderer, GlslShaderGenerator > TextureBakerGlsl

Public Types

enum class  MatrixConvention { OpenGL = 0 , Metal = 1 }
 Viewing API matrix conventions designation (default to OpenGL).
 
using StageMap = StringMap
 A map with name and source code for each shader stage.
 

Public Member Functions

Setup
virtual void initialize (RenderContextHandle=nullptr)
 Initialize the renderer. More...
 
void setCamera (CameraPtr camera)
 Set the camera.
 
CameraPtr getCamera () const
 Return the camera.
 
void setImageHandler (ImageHandlerPtr imageHandler)
 Set the image handler used by this renderer for image I/O.
 
ImageHandlerPtr getImageHandler () const
 Return the image handler.
 
void setLightHandler (LightHandlerPtr lightHandler)
 Set the light handler used by this renderer for light bindings.
 
LightHandlerPtr getLightHandler () const
 Return the light handler.
 
void setGeometryHandler (GeometryHandlerPtr geometryHandler)
 Set the geometry handler.
 
GeometryHandlerPtr getGeometryHandler () const
 Return the geometry handler.
 
Rendering
virtual void createProgram (ShaderPtr shader)
 Create program based on an input shader. More...
 
virtual void createProgram (const StageMap &stages)
 Create program based on shader stage source code. More...
 
virtual void validateInputs ()
 Validate inputs for the program. More...
 
virtual void updateUniform (const string &name, ConstValuePtr value)
 Update the program with value of the uniform. More...
 
virtual void setSize (unsigned int width, unsigned int height)
 Set the size of the rendered image. More...
 
virtual void render ()
 Render the current program to produce an image. More...
 
Utilities
virtual ImagePtr captureImage (ImagePtr image=nullptr)
 Capture the current rendered output as an image. More...
 

Protected Member Functions

 ShaderRenderer (unsigned int width, unsigned int height, Image::BaseType baseType, MatrixConvention matrixConvention=MatrixConvention::OpenGL)
 

Protected Attributes

unsigned int _width
 
unsigned int _height
 
Image::BaseType _baseType
 
MatrixConvention _matrixConvention
 
CameraPtr _camera
 
ImageHandlerPtr _imageHandler
 
GeometryHandlerPtr _geometryHandler
 
LightHandlerPtr _lightHandler
 

Detailed Description

Base class for renderers that generate shader code to produce images.

Member Function Documentation

◆ captureImage()

virtual ImagePtr captureImage ( ImagePtr  image = nullptr)
inlinevirtual

Capture the current rendered output as an image.

Reimplemented in GlslRenderer, and OslRenderer.

◆ createProgram() [1/2]

virtual void createProgram ( const StageMap stages)
virtual

Create program based on shader stage source code.

Parameters
stagesMap of name and source code for the shader stages.

Reimplemented in GlslRenderer, and OslRenderer.

◆ createProgram() [2/2]

virtual void createProgram ( ShaderPtr  shader)
virtual

Create program based on an input shader.

Reimplemented in GlslRenderer, and OslRenderer.

◆ initialize()

virtual void initialize ( RenderContextHandle  = nullptr)
inlinevirtual

Initialize the renderer.

Reimplemented in GlslRenderer, and OslRenderer.

◆ render()

virtual void render ( )
inlinevirtual

Render the current program to produce an image.

Reimplemented in GlslRenderer, and OslRenderer.

◆ setSize()

virtual void setSize ( unsigned int  width,
unsigned int  height 
)
virtual

Set the size of the rendered image.

Reimplemented in GlslRenderer, and OslRenderer.

◆ updateUniform()

virtual void updateUniform ( const string &  name,
ConstValuePtr  value 
)
virtual

Update the program with value of the uniform.

Reimplemented in GlslRenderer.

◆ validateInputs()

virtual void validateInputs ( )
inlinevirtual

Validate inputs for the program.

Reimplemented in GlslRenderer, and OslRenderer.


The documentation for this class was generated from the following file: