HDK
|
#include <TextureBaker.h>
Classes | |
class | BakedConstant |
class | BakedImage |
Public Member Functions | |
void | setExtension (const string &extension) |
Set the file extension for baked textures. More... | |
const string & | getExtension () const |
Return the file extension for baked textures. More... | |
void | setColorSpace (const string &colorSpace) |
const string & | getColorSpace () const |
Return the color space in which color textures are encoded. More... | |
void | setDistanceUnit (const string &unitSpace) |
Set the distance unit to which textures are baked. Defaults to meters. More... | |
const string & | getDistanceUnit () const |
Return the distance unit to which textures are baked. More... | |
void | setAverageImages (bool enable) |
Set whether images should be averaged to generate constants. Defaults to false. More... | |
bool | getAverageImages () const |
Return whether images should be averaged to generate constants. More... | |
void | setOptimizeConstants (bool enable) |
Set whether uniform textures should be stored as constants. Defaults to true. More... | |
bool | getOptimizeConstants () const |
Return whether uniform textures should be stored as constants. More... | |
void | setOutputImagePath (const FilePath &outputImagePath) |
const FilePath & | getOutputImagePath () |
Get the current output location for baked texture images. More... | |
void | setBakedGraphName (const string &name) |
Set the name of the baked graph element. More... | |
const string & | getBakedGraphName () const |
Return the name of the baked graph element. More... | |
void | setBakedGeomInfoName (const string &name) |
Set the name of the baked geometry info element. More... | |
const string & | getBakedGeomInfoName () const |
Return the name of the baked geometry info element. More... | |
const string & | getTextureFilenameTemplate () const |
Get the texture filename template. More... | |
void | setTextureFilenameTemplate (const string &filenameTemplate) |
Set the texture filename template. More... | |
void | setFilenameTemplateVarOverride (const string &key, const string &value) |
Set texFilenameOverrides if template variable exists. More... | |
void | setOutputStream (std::ostream *outputStream) |
Set the output stream for reporting progress and warnings. Defaults to std::cout. More... | |
std::ostream * | getOutputStream () const |
Return the output stream for reporting progress and warnings. More... | |
void | setHashImageNames (bool enable) |
bool | getHashImageNames () const |
Return whether automatic baked texture resolution is set. More... | |
void | setTextureSpaceMin (const Vector2 &min) |
Set the minimum texcoords used in texture baking. Defaults to 0, 0. More... | |
Vector2 | getTextureSpaceMin () const |
Return the minimum texcoords used in texture baking. More... | |
void | setTextureSpaceMax (const Vector2 &max) |
Set the maximum texcoords used in texture baking. Defaults to 1, 1. More... | |
Vector2 | getTextureSpaceMax () const |
Return the maximum texcoords used in texture baking. More... | |
void | setupUnitSystem (DocumentPtr unitDefinitions) |
Set up the unit definitions to be used in baking. More... | |
void | bakeShaderInputs (NodePtr material, NodePtr shader, GenContext &context, const string &udim=EMPTY_STRING) |
Bake textures for all graph inputs of the given shader. More... | |
void | bakeGraphOutput (OutputPtr output, GenContext &context, const StringMap &filenameTemplateMap) |
Bake a texture for the given graph output. More... | |
void | optimizeBakedTextures (NodePtr shader) |
Optimize baked textures before writing. More... | |
DocumentPtr | bakeMaterialToDoc (DocumentPtr doc, const FileSearchPath &searchPath, const string &materialPath, const StringVec udimSet, std::string &documentName) |
Bake material to document in memory and write baked textures to disk. More... | |
void | bakeAllMaterials (DocumentPtr doc, const FileSearchPath &searchPath, const FilePath &outputFileName) |
![]() | |
virtual | ~GlslRenderer () |
Destructor. More... | |
void | initialize () override |
void | createProgram (ShaderPtr shader) override |
void | createProgram (const StageMap &stages) override |
void | validateInputs () override |
Validate inputs for the program. More... | |
void | setSize (unsigned int width, unsigned int height) override |
Set the size of the rendered image. More... | |
void | render () override |
Render the current program to an offscreen buffer. More... | |
void | renderTextureSpace (const Vector2 &uvMin, const Vector2 &uvMax) |
Render the current program in texture space to an off-screen buffer. More... | |
ImagePtr | captureImage (ImagePtr image=nullptr) override |
Capture the current contents of the off-screen hardware buffer as an image. More... | |
GLFramebufferPtr | getFramebuffer () const |
Return the GL frame buffer. More... | |
GlslProgramPtr | getProgram () |
Return the GLSL program. More... | |
void | drawScreenSpaceQuad (const Vector2 &uvMin=Vector2(0.0f), const Vector2 &uvMax=Vector2(1.0f)) |
Submit geometry for a screen-space quad. More... | |
void | setClearColor (const Color4 &clearColor) |
Sets the clear color. More... | |
![]() | |
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... | |
Static Public Member Functions | |
static TextureBakerPtr | create (unsigned int width=1024, unsigned int height=1024, Image::BaseType baseType=Image::BaseType::UINT8) |
![]() | |
static GlslRendererPtr | create (unsigned int width=512, unsigned int height=512, Image::BaseType baseType=Image::BaseType::UINT8) |
Create a GLSL renderer instance. More... | |
Protected Types | |
using | BakedImageVec = vector< BakedImage > |
using | BakedImageMap = std::unordered_map< OutputPtr, BakedImageVec > |
using | BakedConstantMap = std::unordered_map< OutputPtr, BakedConstant > |
Protected Member Functions | |
TextureBaker (unsigned int width, unsigned int height, Image::BaseType baseType) | |
StringMap | initializeFileTemplateMap (InputPtr input, NodePtr shader, const string &udim=EMPTY_STRING) |
size_t | findVarInTemplate (const string &filename, const string &var, size_t start=0) |
FilePath | generateTextureFilename (const StringMap &fileTemplateMap) |
DocumentPtr | generateNewDocumentFromShader (NodePtr shader, const StringVec &udimSet) |
bool | writeBakedImage (const BakedImage &baked, ImagePtr image) |
![]() | |
GlslRenderer (unsigned int width, unsigned int height, Image::BaseType baseType) | |
virtual void | updateViewInformation () |
virtual void | updateWorldInformation () |
![]() | |
ShaderRenderer () | |
ShaderRenderer (unsigned int width, unsigned int height, Image::BaseType baseType) | |
Protected Attributes | |
string | _extension |
string | _colorSpace |
string | _distanceUnit |
bool | _averageImages |
bool | _optimizeConstants |
FilePath | _outputImagePath |
string | _bakedGraphName |
string | _bakedGeomInfoName |
string | _textureFilenameTemplate |
std::ostream * | _outputStream |
bool | _hashImageNames |
Vector2 | _textureSpaceMin |
Vector2 | _textureSpaceMax |
ShaderGeneratorPtr | _generator |
ConstNodePtr | _material |
ImagePtr | _frameCaptureImage |
BakedImageMap | _bakedImageMap |
BakedConstantMap | _bakedConstantMap |
StringSet | _permittedOverrides |
StringMap | _texTemplateOverrides |
StringMap | _bakedInputMap |
std::unordered_map< string, NodePtr > | _worldSpaceNodes |
![]() | |
unsigned int | _width |
unsigned int | _height |
Image::BaseType | _baseType |
CameraPtr | _camera |
ImageHandlerPtr | _imageHandler |
GeometryHandlerPtr | _geometryHandler |
LightHandlerPtr | _lightHandler |
Additional Inherited Members | |
![]() | |
using | StageMap = StringMap |
A map with name and source code for each shader stage. More... | |
A helper class for baking procedural material content to textures. TODO: Add support for graphs containing geometric nodes such as position and normal.
Definition at line 35 of file TextureBaker.h.
|
protected |
Definition at line 253 of file TextureBaker.h.
|
protected |
Definition at line 252 of file TextureBaker.h.
|
protected |
Definition at line 251 of file TextureBaker.h.
|
protected |
void TextureBaker::bakeAllMaterials | ( | DocumentPtr | doc, |
const FileSearchPath & | searchPath, | ||
const FilePath & | outputFileName | ||
) |
Bake materials in the given document and write them to disk. If multiple documents are written, then the given output filename will be used as a template.
void TextureBaker::bakeGraphOutput | ( | OutputPtr | output, |
GenContext & | context, | ||
const StringMap & | filenameTemplateMap | ||
) |
Bake a texture for the given graph output.
DocumentPtr TextureBaker::bakeMaterialToDoc | ( | DocumentPtr | doc, |
const FileSearchPath & | searchPath, | ||
const string & | materialPath, | ||
const StringVec | udimSet, | ||
std::string & | documentName | ||
) |
Bake material to document in memory and write baked textures to disk.
void TextureBaker::bakeShaderInputs | ( | NodePtr | material, |
NodePtr | shader, | ||
GenContext & | context, | ||
const string & | udim = EMPTY_STRING |
||
) |
Bake textures for all graph inputs of the given shader.
|
inlinestatic |
Definition at line 38 of file TextureBaker.h.
|
protected |
|
protected |
|
inline |
Return whether images should be averaged to generate constants.
Definition at line 91 of file TextureBaker.h.
Return the name of the baked geometry info element.
Definition at line 140 of file TextureBaker.h.
Return the name of the baked graph element.
Definition at line 128 of file TextureBaker.h.
Return the color space in which color textures are encoded.
Definition at line 67 of file TextureBaker.h.
Return the distance unit to which textures are baked.
Definition at line 79 of file TextureBaker.h.
Return the file extension for baked textures.
Definition at line 50 of file TextureBaker.h.
|
inline |
Return whether automatic baked texture resolution is set.
Definition at line 188 of file TextureBaker.h.
|
inline |
Return whether uniform textures should be stored as constants.
Definition at line 103 of file TextureBaker.h.
Get the current output location for baked texture images.
Definition at line 116 of file TextureBaker.h.
|
inline |
Return the output stream for reporting progress and warnings.
Definition at line 174 of file TextureBaker.h.
Get the texture filename template.
Definition at line 146 of file TextureBaker.h.
|
inline |
Return the maximum texcoords used in texture baking.
Definition at line 212 of file TextureBaker.h.
|
inline |
Return the minimum texcoords used in texture baking.
Definition at line 200 of file TextureBaker.h.
|
protected |
|
inline |
Set whether images should be averaged to generate constants. Defaults to false.
Definition at line 85 of file TextureBaker.h.
Set the name of the baked geometry info element.
Definition at line 134 of file TextureBaker.h.
Set the name of the baked graph element.
Definition at line 122 of file TextureBaker.h.
Set the color space in which color textures are encoded.
By default, this color space is srgb_texture, and color inputs are automatically transformed to this space by the baker. If another color space is set, then the input graph is responsible for transforming colors to this space.
Definition at line 61 of file TextureBaker.h.
Set the distance unit to which textures are baked. Defaults to meters.
Definition at line 73 of file TextureBaker.h.
Set the file extension for baked textures.
Definition at line 44 of file TextureBaker.h.
|
inline |
Set texFilenameOverrides if template variable exists.
Definition at line 159 of file TextureBaker.h.
|
inline |
Set whether to create a short name for baked images by hashing the baked image filenames This is useful for file systems which may have a maximum limit on filename size. By default names are not hashed.
Definition at line 182 of file TextureBaker.h.
|
inline |
Set whether uniform textures should be stored as constants. Defaults to true.
Definition at line 97 of file TextureBaker.h.
Set the output location for baked texture images. Defaults to the root folder of the destination material.
Definition at line 110 of file TextureBaker.h.
|
inline |
Set the output stream for reporting progress and warnings. Defaults to std::cout.
Definition at line 168 of file TextureBaker.h.
Set the texture filename template.
Definition at line 152 of file TextureBaker.h.
Set the maximum texcoords used in texture baking. Defaults to 1, 1.
Definition at line 206 of file TextureBaker.h.
Set the minimum texcoords used in texture baking. Defaults to 0, 0.
Definition at line 194 of file TextureBaker.h.
void TextureBaker::setupUnitSystem | ( | DocumentPtr | unitDefinitions | ) |
Set up the unit definitions to be used in baking.
|
protected |
|
protected |
Definition at line 277 of file TextureBaker.h.
|
protected |
Definition at line 292 of file TextureBaker.h.
|
protected |
Definition at line 281 of file TextureBaker.h.
|
protected |
Definition at line 280 of file TextureBaker.h.
|
protected |
Definition at line 291 of file TextureBaker.h.
|
protected |
Definition at line 295 of file TextureBaker.h.
|
protected |
Definition at line 275 of file TextureBaker.h.
|
protected |
Definition at line 276 of file TextureBaker.h.
|
protected |
Definition at line 274 of file TextureBaker.h.
|
protected |
Definition at line 290 of file TextureBaker.h.
|
protected |
Definition at line 288 of file TextureBaker.h.
|
protected |
Definition at line 284 of file TextureBaker.h.
|
protected |
Definition at line 289 of file TextureBaker.h.
|
protected |
Definition at line 278 of file TextureBaker.h.
|
protected |
Definition at line 279 of file TextureBaker.h.
|
protected |
Definition at line 283 of file TextureBaker.h.
|
protected |
Definition at line 293 of file TextureBaker.h.
|
protected |
Definition at line 294 of file TextureBaker.h.
|
protected |
Definition at line 282 of file TextureBaker.h.
|
protected |
Definition at line 286 of file TextureBaker.h.
|
protected |
Definition at line 285 of file TextureBaker.h.
Definition at line 297 of file TextureBaker.h.