HDK
|
#include <OslRenderer.h>
Public Member Functions | |
virtual | ~OslRenderer () |
Destructor. More... | |
Setup | |
void | initialize (RenderContextHandle renderContextHandle=nullptr) override |
Rendering | |
void | createProgram (ShaderPtr shader) override |
void | createProgram (const StageMap &stages) override |
void | validateInputs () override |
void | setSize (unsigned int width, unsigned int height) override |
Set the size for rendered image. More... | |
void | render () override |
Utilities | |
ImagePtr | captureImage (ImagePtr image=nullptr) override |
Capture the current rendered output as an image. More... | |
Compilation settings | |
void | setOslCompilerExecutable (const FilePath &executableFilePath) |
void | setOslIncludePath (const FileSearchPath &dirPath) |
void | setOslOutputFilePath (const FilePath &dirPath) |
void | setShaderParameterOverrides (const StringVec ¶meterOverrides) |
void | setEnvShaderParameterOverrides (const StringVec ¶meterOverrides) |
void | setOslShaderOutput (const string &outputName, const string &outputType) |
void | setOslTestShadeExecutable (const FilePath &executableFilePath) |
void | setOslTestRenderExecutable (const FilePath &executableFilePath) |
void | setOslTestRenderSceneTemplateFile (const FilePath &templateFilePath) |
void | setOslShaderName (const string &shaderName) |
void | setOslUtilityOSOPath (const FilePath &dirPath) |
void | useTestRender (bool useTestRender) |
void | setRaysPerPixelLit (int rays) |
Set the number of rays per pixel to be used for lit surfaces. More... | |
void | setRaysPerPixelUnlit (int rays) |
Set the number of rays per pixel to be used for unlit surfaces. More... | |
void | compileOSL (const FilePath &oslFilePath) |
Public Member Functions inherited from ShaderRenderer | |
virtual | ~ShaderRenderer () |
void | setCamera (CameraPtr camera) |
Set the camera. More... | |
CameraPtr | getCamera () const |
Return the camera. More... | |
void | setImageHandler (ImageHandlerPtr imageHandler) |
Set the image handler used by this renderer for image I/O. More... | |
ImageHandlerPtr | getImageHandler () const |
Return the image handler. More... | |
void | setLightHandler (LightHandlerPtr lightHandler) |
Set the light handler used by this renderer for light bindings. More... | |
LightHandlerPtr | getLightHandler () const |
Return the light handler. More... | |
void | setGeometryHandler (GeometryHandlerPtr geometryHandler) |
Set the geometry handler. More... | |
GeometryHandlerPtr | getGeometryHandler () const |
Return the geometry handler. More... | |
virtual void | updateUniform (const string &name, ConstValuePtr value) |
Update the program with value of the uniform. More... | |
Static Public Member Functions | |
static OslRendererPtr | create (unsigned int width=512, unsigned int height=512, Image::BaseType baseType=Image::BaseType::UINT8) |
Create an OSL renderer instance. More... | |
Static Public Attributes | |
static string | OSL_CLOSURE_COLOR_STRING |
Color closure OSL string. More... | |
Protected Member Functions | |
void | shadeOSL (const FilePath &dirPath, const string &shaderName, const string &outputName) |
void | renderOSL (const FilePath &dirPath, const string &shaderName, const string &outputName) |
OslRenderer (unsigned int width, unsigned int height, Image::BaseType baseType) | |
Constructor. More... | |
Protected Member Functions inherited from ShaderRenderer | |
ShaderRenderer (unsigned int width, unsigned int height, Image::BaseType baseType, MatrixConvention matrixConvention=MatrixConvention::OpenGL) | |
Additional Inherited Members | |
Public Types inherited from ShaderRenderer | |
enum | MatrixConvention { MatrixConvention::OpenGL = 0, MatrixConvention::Metal = 1 } |
Viewing API matrix conventions designation (default to OpenGL). More... | |
using | StageMap = StringMap |
A map with name and source code for each shader stage. More... | |
Protected Attributes inherited from ShaderRenderer | |
unsigned int | _width |
unsigned int | _height |
Image::BaseType | _baseType |
MatrixConvention | _matrixConvention |
CameraPtr | _camera |
ImageHandlerPtr | _imageHandler |
GeometryHandlerPtr | _geometryHandler |
LightHandlerPtr | _lightHandler |
Helper class for rendering generated OSL code to produce images.
The main services provided are:
Definition at line 32 of file OslRenderer.h.
|
virtual |
Destructor.
|
protected |
Constructor.
Capture the current rendered output as an image.
Reimplemented from ShaderRenderer.
|
static |
Create an OSL renderer instance.
Create OSL program based on an input shader
A valid executable and include path must be specified before calling this method. setOslCompilerExecutable(), and setOslIncludePath().
Additionally setOslOutputFilePath() should be set to allow for output of .osl and .oso files to the appropriate path location to be used as input for render validation.
If render validation is not required, then the same temporary name will be used for all shaders validated using this method.
shader | Input shader |
Reimplemented from ShaderRenderer.
Create OSL program based on shader stage source code.
stages | Map of name and source code for the shader stages. |
Reimplemented from ShaderRenderer.
|
overridevirtual |
Internal initialization required for program validation and rendering. An exception is thrown on failure. The exception will contain a list of initialization errors.
Reimplemented from ShaderRenderer.
|
overridevirtual |
Render OSL program to disk. This is done by using either "testshade" or "testrender". Currently only "testshade" is supported.
Usage of both executables requires compiled source (.oso) files as input. A shader output must be set before running this test via the setOslOutputName() method to ensure that the appropriate .oso files can be located.
Reimplemented from ShaderRenderer.
Set shader parameter strings to be added to the scene XML file. These strings will set parameter overrides for the shader.
Definition at line 132 of file OslRenderer.h.
Set the path to the OSL executable. Note that it is assumed that this references the location of the oslc executable.
executableFilePath | Path to OSL compiler executable |
Definition at line 103 of file OslRenderer.h.
|
inline |
Set the search locations for OSL include files.
dirPath | Include path(s) for the OSL compiler. This should include the path to stdosl.h. |
Definition at line 111 of file OslRenderer.h.
Set the location where compiled OSL files will reside.
dirPath | Path to output location |
Definition at line 118 of file OslRenderer.h.
Set the name of the shader to be used for the input XML scene file. The value is used to replace the shader% token in the file.
shaderName | Name of shader |
Definition at line 178 of file OslRenderer.h.
|
inline |
Set the OSL shader output. This is used during render validation if "testshade" or "testrender" is executed. For testrender this value is used to replace the shader_output% token in the input scene file.
outputName | Name of shader output |
outputType | The MaterialX type of the output |
Definition at line 143 of file OslRenderer.h.
Set the path to the OSL rendering tester. Note that it is assumed that this references the location of the "testrender" executable.
executableFilePath | Path to OSL "testrender" executable |
Definition at line 160 of file OslRenderer.h.
Set the XML scene file to use for testrender. This is a template file with the following tokens for replacement:
templateFilePath | Scene file name |
Definition at line 170 of file OslRenderer.h.
Set the path to the OSL shading tester. Note that it is assumed that this references the location of the "testshade" executable.
executableFilePath | Path to OSL "testshade" executable |
Definition at line 152 of file OslRenderer.h.
Set the search path for dependent shaders (.oso files) which are used when rendering with testrender.
dirPath | Path to location containing .oso files. |
Definition at line 186 of file OslRenderer.h.
Set the number of rays per pixel to be used for lit surfaces.
Definition at line 200 of file OslRenderer.h.
Set the number of rays per pixel to be used for unlit surfaces.
Definition at line 206 of file OslRenderer.h.
Set shader parameter strings to be added to the scene XML file. These strings will set parameter overrides for the shader.
Definition at line 125 of file OslRenderer.h.
Set the size for rendered image.
Reimplemented from ShaderRenderer.
|
inline |
Used to toggle to either use testrender or testshade during render validation By default testshade is used.
useTestRender | Indicate whether to use testrender. |
Definition at line 194 of file OslRenderer.h.
|
overridevirtual |
Validate inputs for the compiled OSL program. Note: Currently no validation has been implemented.
Reimplemented from ShaderRenderer.
|
static |
Color closure OSL string.
Definition at line 42 of file OslRenderer.h.