6 #ifndef MATERIALX_TEXTUREBAKER
7 #define MATERIALX_TEXTUREBAKER
30 template <
typename Renderer,
typename ShaderGen>
146 filenameTemplate +
".$EXTENSION" : filenameTemplate;
string _bakedGeomInfoName
void setTextureSpaceMax(const Vector2 &max)
Set the maximum texcoords used in texture baking. Defaults to 1, 1.
void setColorSpace(const string &colorSpace)
shared_ptr< Output > OutputPtr
A shared pointer to an Output.
GT_API const UT_StringHolder filename
bool getOptimizeConstants() const
Return whether uniform textures should be stored as constants.
#define MATERIALX_NAMESPACE_BEGIN
void setDistanceUnit(const string &unitSpace)
Set the distance unit to which textures are baked. Defaults to meters.
vector< string > StringVec
A vector of strings.
bool _writeDocumentPerMaterial
std::unordered_map< OutputPtr, BakedConstant > BakedConstantMap
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
void setAverageImages(bool enable)
Set whether images should be averaged to generate constants. Defaults to false.
const string & getDistanceUnit() const
Return the distance unit to which textures are baked.
void setBakedGeomInfoName(const string &name)
Set the name of the baked geometry info element.
vector< BakedImage > BakedImageVec
MATERIALX_NAMESPACE_BEGIN MX_CORE_API const string EMPTY_STRING
void setOutputImagePath(const FilePath &outputImagePath)
bool getAverageImages() const
Return whether images should be averaged to generate constants.
void setOutputStream(std::ostream *outputStream)
Set the output stream for reporting progress and warnings. Defaults to std::cout. ...
shared_ptr< const Node > ConstNodePtr
A shared pointer to a const Node.
const string & getBakedGraphName() const
Return the name of the baked graph element.
const string & getTextureFilenameTemplate() const
Get the texture filename template.
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
Vector2 getTextureSpaceMax() const
Return the maximum texcoords used in texture baking.
GLenum GLenum GLsizei void * image
bool writeBakedImage(const BakedImage &baked, ImagePtr image)
std::vector< std::pair< std::string, DocumentPtr >> BakedDocumentVec
A vector of baked documents with their associated names.
BakedImageMap _bakedImageMap
string getValueStringFromColor(const Color4 &color, const string &type)
StringMap initializeFileTemplateMap(InputPtr input, NodePtr shader, const string &udim=EMPTY_STRING)
void bakeAllMaterials(DocumentPtr doc, const FileSearchPath &searchPath, const FilePath &outputFileName)
void writeDocumentPerMaterial(bool value)
DocumentPtr _bakedTextureDoc
GLint GLsizei GLsizei height
const string & getExtension() const
Return the file extension for baked textures.
bool getHashImageNames() const
Return whether automatic baked texture resolution is set.
const string & getColorSpace() const
Return the color space in which color textures are encoded.
std::ostream * _outputStream
std::ostream * getOutputStream() const
Return the output stream for reporting progress and warnings.
void bakeGraphOutput(OutputPtr output, GenContext &context, const StringMap &filenameTemplateMap)
Bake a texture for the given graph output.
TextureBaker(unsigned int width, unsigned int height, Image::BaseType baseType, bool flipSavedImage)
void setExtension(const string &extension)
Set the file extension for baked textures.
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
void setTextureSpaceMin(const Vector2 &min)
Set the minimum texcoords used in texture baking. Defaults to 0, 0.
void optimizeBakedTextures(NodePtr shader)
Optimize baked textures before writing.
FilePath _outputImagePath
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.
GLuint const GLchar * name
ImagePtr _frameCaptureImage
std::unordered_map< string, NodePtr > _worldSpaceNodes
shared_ptr< Input > InputPtr
A shared pointer to an Input.
size_t findVarInTemplate(const string &filename, const string &var, size_t start=0)
StringSet _permittedOverrides
FilePath generateTextureFilename(const StringMap &fileTemplateMap)
Vector2 getTextureSpaceMin() const
Return the minimum texcoords used in texture baking.
void setHashImageNames(bool enable)
DocumentPtr generateNewDocumentFromShader(NodePtr shader, const StringVec &udimSet)
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
std::unordered_map< string, string > StringMap
An unordered map with strings as both keys and values.
ShaderGeneratorPtr _generator
const FilePath & getOutputImagePath()
Get the current output location for baked texture images.
void setBakedGraphName(const string &name)
Set the name of the baked graph element.
std::set< string > StringSet
A set of strings.
void bakeShaderInputs(NodePtr material, NodePtr shader, GenContext &context, const string &udim=EMPTY_STRING)
Bake textures for all graph inputs of the given shader.
void setTextureFilenameTemplate(const string &filenameTemplate)
Set the texture filename template.
#define MATERIALX_NAMESPACE_END
std::unordered_map< OutputPtr, BakedImageVec > BakedImageMap
void setOptimizeConstants(bool enable)
Set whether uniform textures should be stored as constants. Defaults to true.
void setFilenameTemplateVarOverride(const string &key, const string &value)
Set texFilenameOverrides if template variable exists.
shared_ptr< Image > ImagePtr
A shared pointer to an image.
shared_ptr< ShaderGenerator > ShaderGeneratorPtr
Shared pointer to a ShaderGenerator.
void setupUnitSystem(DocumentPtr unitDefinitions)
Set up the unit definitions to be used in baking.
BakedConstantMap _bakedConstantMap
string _textureFilenameTemplate
OIIO_UTIL_API std::string extension(string_view filepath, bool include_dot=true) noexcept
StringMap _texTemplateOverrides
const string & getBakedGeomInfoName() const
Return the name of the baked geometry info element.
shared_ptr< Node > NodePtr
A shared pointer to a Node.