Shaders¶
GpuShaderCreator¶
-
class
PyOpenColorIO.
GpuShaderCreator
¶ Inherit from the class to fully customize the implementation of a GPU shader program from a color transformation.
When no customizations are needed then the
:ref:`GpuShaderDesc`
is a better choice.To better decouple the DynamicProperties from their GPU implementation, the code provides several addUniform() methods i.e. one per access function types. For example, an ExposureContrastTransform instance owns three DynamicProperties and they are all implemented by a double. When creating the GPU fragment shader program, the addUniform() with GpuShaderCreator::DoubleGetter is called when property is dynamic, up to three times.
-
addToDeclareShaderCode
(shaderCode: str) → None¶
-
addToFunctionHeaderShaderCode
(shaderCode: str) → None¶
-
addToFunctionShaderCode
(shaderCode: str) → None¶
-
addToHelperShaderCode
(shaderCode: str) → None¶
-
begin
(uid: str) → None¶ Start to collect the shader data.
-
clone
() → PyOpenColorIO.GpuShaderCreator¶
-
createShaderText
(shaderDeclarations: str, shaderHelperMethods: str, shaderFunctionHeader: str, shaderFunctionBody: str, shaderFunctionFooter: str) → None¶ Create the OCIO shader program.
The OCIO shader program is decomposed to allow a specific implementation to change some parts. Some product integrations add the color processing within a client shader program, imposing constraints requiring this flexibility.
-
end
() → None¶ End to collect the shader data.
-
finalize
() → None¶
-
getCacheID
() → str¶
-
getDynamicProperties
() → PyOpenColorIO.GpuShaderCreator.DynamicPropertyIterator¶
-
getDynamicProperty
(type: PyOpenColorIO.DynamicPropertyType) → PyOpenColorIO.DynamicProperty¶
-
getFunctionName
() → str¶
-
getLanguage
() → PyOpenColorIO.GpuLanguage¶
-
getNextResourceIndex
() → int¶ To avoid texture/unform name clashes always append an increasing number to the resource name.
-
getPixelName
() → str¶
-
getResourcePrefix
() → str¶ Note
Some applications require that textures, uniforms, and helper methods be uniquely named because several processor instances could coexist.
-
getTextureMaxWidth
() → int¶
-
getUniqueID
() → str¶
-
hasDynamicProperty
(type: PyOpenColorIO.DynamicPropertyType) → bool¶
-
setFunctionName
(name: str) → None¶
-
setLanguage
(language: PyOpenColorIO.GpuLanguage) → None¶ Set the shader program language.
-
setPixelName
(name: str) → None¶ Set the pixel name variable holding the color values.
-
setResourcePrefix
(prefix: str) → None¶ Set a prefix to the resource name.
-
setTextureMaxWidth
(maxWidth: int) → None¶ Some graphic cards could have 1D & 2D textures with size limitations.
-
setUniqueID
(uid: str) → None¶
-
-
class
PyOpenColorIO.GpuShaderCreator.
TextureType
¶ Members:
TEXTURE_RED_CHANNEL
TEXTURE_RGB_CHANNEL
-
property
name
→ str¶
-
TEXTURE_RED_CHANNEL
= <TextureType.TEXTURE_RED_CHANNEL: 0>¶
-
TEXTURE_RGB_CHANNEL
= <TextureType.TEXTURE_RGB_CHANNEL: 1>¶
-
property
value
¶
-
property
-
class
PyOpenColorIO.GpuShaderCreator.
DynamicPropertyIterator
¶ -
self
[
arg0: int]
→ PyOpenColorIO.DynamicProperty¶
-
len
(self) → int¶
-
next
(self) → PyOpenColorIO.DynamicProperty¶
-
self
-
class
OpenColorIO_v2_0
::
GpuShaderCreator
¶ Inherit from the class to fully customize the implementation of a GPU shader program from a color transformation.
When no customizations are needed then the :cpp:class:
GpuShaderDesc
is a better choice.To better decouple the DynamicProperties from their GPU implementation, the code provides several addUniform() methods i.e. one per access function types. For example, an ExposureContrastTransform instance owns three DynamicProperties and they are all implemented by a double. When creating the GPU fragment shader program, the addUniform() with GpuShaderCreator::DoubleGetter is called when property is dynamic, up to three times.
Subclassed by GpuShaderDesc
Public Types
-
enum
TextureType
¶ Values:
-
enumerator
TEXTURE_RED_CHANNEL
¶ Only use the red channel of the texture.
-
enumerator
TEXTURE_RGB_CHANNEL
¶
-
enumerator
-
typedef std::function<double()>
DoubleGetter
¶ Function returning a double, used by uniforms. GPU converts double to float.
-
typedef std::function<bool()>
BoolGetter
¶ Function returning a bool, used by uniforms.
-
typedef std::function<const Float3&()>
Float3Getter
¶ Functions returning a Float3, used by uniforms.
-
typedef std::function<int()>
SizeGetter
¶ Function returning an int, used by uniforms.
-
typedef std::function<const float*()>
VectorFloatGetter
¶ Function returning a float *, used by uniforms.
-
typedef std::function<const int*()>
VectorIntGetter
¶ Function returning an int *, used by uniforms.
Public Functions
-
GpuShaderCreatorRcPtr
clone
() const = 0¶
-
const char *
getUniqueID
() const noexcept¶
-
void
setUniqueID
(const char *uid) noexcept¶
-
GpuLanguage
getLanguage
() const noexcept¶
-
void
setLanguage
(GpuLanguage lang) noexcept¶ Set the shader program language.
-
const char *
getFunctionName
() const noexcept¶
-
void
setFunctionName
(const char *name) noexcept¶
-
const char *
getPixelName
() const noexcept¶
-
void
setPixelName
(const char *name) noexcept¶ Set the pixel name variable holding the color values.
-
const char *
getResourcePrefix
() const noexcept¶ - Note
Some applications require that textures, uniforms, and helper methods be uniquely named because several processor instances could coexist.
-
void
setResourcePrefix
(const char *prefix) noexcept¶ Set a prefix to the resource name.
-
const char *
getCacheID
() const noexcept¶
-
void
begin
(const char *uid)¶ Start to collect the shader data.
-
void
end
()¶ End to collect the shader data.
-
void
setTextureMaxWidth
(unsigned maxWidth) = 0¶ Some graphic cards could have 1D & 2D textures with size limitations.
-
unsigned
getTextureMaxWidth
() const noexcept = 0¶
-
unsigned
getNextResourceIndex
() noexcept¶ To avoid texture/unform name clashes always append an increasing number to the resource name.
-
bool
addUniform
(const char *name, const DoubleGetter &getDouble) = 0¶
-
bool
addUniform
(const char *name, const BoolGetter &getBool) = 0¶
-
bool
addUniform
(const char *name, const Float3Getter &getFloat3) = 0¶
-
bool
addUniform
(const char *name, const SizeGetter &getSize, const VectorFloatGetter &getVectorFloat) = 0¶
-
bool
addUniform
(const char *name, const SizeGetter &getSize, const VectorIntGetter &getVectorInt) = 0¶
-
void
addDynamicProperty
(DynamicPropertyRcPtr &prop)¶ Adds the property (used internally).
-
unsigned
getNumDynamicProperties
() const noexcept¶ Dynamic Property related methods.
-
DynamicPropertyRcPtr
getDynamicProperty
(unsigned index) const¶
-
bool
hasDynamicProperty
(DynamicPropertyType type) const¶
-
DynamicPropertyRcPtr
getDynamicProperty
(DynamicPropertyType type) const¶ Dynamic properties allow changes once the fragment shader program has been created. The steps are to get the appropriate DynamicProperty instance, and then change its value.
-
void
addTexture
(const char *textureName, const char *samplerName, unsigned width, unsigned height, TextureType channel, Interpolation interpolation, const float *values) = 0¶
-
void
add3DTexture
(const char *textureName, const char *samplerName, unsigned edgelen, Interpolation interpolation, const float *values) = 0¶
-
void
addToDeclareShaderCode
(const char *shaderCode)¶
-
void
addToHelperShaderCode
(const char *shaderCode)¶
-
void
addToFunctionHeaderShaderCode
(const char *shaderCode)¶
-
void
addToFunctionShaderCode
(const char *shaderCode)¶
-
void
createShaderText
(const char *shaderDeclarations, const char *shaderHelperMethods, const char *shaderFunctionHeader, const char *shaderFunctionBody, const char *shaderFunctionFooter)¶ Create the OCIO shader program.
The OCIO shader program is decomposed to allow a specific implementation to change some parts. Some product integrations add the color processing within a client shader program, imposing constraints requiring this flexibility.
- Note
-
void
finalize
()¶
-
GpuShaderCreator
(const GpuShaderCreator&) = delete¶
-
GpuShaderCreator &
operator=
(const GpuShaderCreator&) = delete¶
-
~GpuShaderCreator
()¶ Do not use (needed only for pybind11).
-
enum
-
typedef std::shared_ptr<const GpuShaderCreator>
OpenColorIO_v2_0
::
ConstGpuShaderCreatorRcPtr
¶
-
typedef std::shared_ptr<GpuShaderCreator>
OpenColorIO_v2_0
::
GpuShaderCreatorRcPtr
¶
GpuShaderDesc¶
-
class
PyOpenColorIO.
GpuShaderDesc
¶ -
static
CreateLegacyShaderDesc
(edgeLen: int, language: PyOpenColorIO.GpuLanguage = <GpuLanguage.GPU_LANGUAGE_GLSL_1_2: 1>, functionName: str = 'OCIOMain', pixelName: str = 'outColor', resourcePrefix: str = 'ocio', uid: str = '') → PyOpenColorIO.GpuShaderDesc¶ Create the legacy shader description.
-
static
CreateShaderDesc
(language: PyOpenColorIO.GpuLanguage = <GpuLanguage.GPU_LANGUAGE_GLSL_1_2: 1>, functionName: str = 'OCIOMain', pixelName: str = 'outColor', resourcePrefix: str = 'ocio', uid: str = '') → PyOpenColorIO.GpuShaderDesc¶ Create the default shader description.
-
GpuShaderDesc
(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
add3DTexture
(textureName: str, samplerName: str, edgeLen: int, interpolation: PyOpenColorIO.Interpolation, values: buffer) → None¶
-
addTexture
(textureName: str, samplerName: str, width: int, height: int, channel: PyOpenColorIO.GpuShaderCreator.TextureType, interpolation: PyOpenColorIO.Interpolation, values: buffer) → None¶
-
addToDeclareShaderCode
(shaderCode: str) → None¶
-
addToFunctionHeaderShaderCode
(shaderCode: str) → None¶
-
addToFunctionShaderCode
(shaderCode: str) → None¶
-
addToHelperShaderCode
(shaderCode: str) → None¶
-
begin
(uid: str) → None¶ Start to collect the shader data.
-
clone
() → PyOpenColorIO.GpuShaderCreator¶
-
createShaderText
(shaderDeclarations: str, shaderHelperMethods: str, shaderFunctionHeader: str, shaderFunctionBody: str, shaderFunctionFooter: str) → None¶ Create the OCIO shader program.
The OCIO shader program is decomposed to allow a specific implementation to change some parts. Some product integrations add the color processing within a client shader program, imposing constraints requiring this flexibility.
-
end
() → None¶ End to collect the shader data.
-
finalize
() → None¶
-
get3DTextures
() → PyOpenColorIO.GpuShaderDesc.Texture3DIterator¶
-
getCacheID
() → str¶
-
getDynamicProperties
() → PyOpenColorIO.GpuShaderCreator.DynamicPropertyIterator¶
-
getDynamicProperty
(type: PyOpenColorIO.DynamicPropertyType) → PyOpenColorIO.DynamicProperty¶
-
getFunctionName
() → str¶
-
getLanguage
() → PyOpenColorIO.GpuLanguage¶
-
getNextResourceIndex
() → int¶ To avoid texture/unform name clashes always append an increasing number to the resource name.
-
getPixelName
() → str¶
-
getResourcePrefix
() → str¶ Note
Some applications require that textures, uniforms, and helper methods be uniquely named because several processor instances could coexist.
-
getShaderText
() → str¶ Get the complete OCIO shader program.
-
getTextureMaxWidth
() → int¶
-
getTextures
() → PyOpenColorIO.GpuShaderDesc.TextureIterator¶
-
getUniforms
() → PyOpenColorIO.GpuShaderDesc.UniformIterator¶
-
getUniqueID
() → str¶
-
hasDynamicProperty
(type: PyOpenColorIO.DynamicPropertyType) → bool¶
-
setFunctionName
(name: str) → None¶
-
setLanguage
(language: PyOpenColorIO.GpuLanguage) → None¶ Set the shader program language.
-
setPixelName
(name: str) → None¶ Set the pixel name variable holding the color values.
-
setResourcePrefix
(prefix: str) → None¶ Set a prefix to the resource name.
-
setTextureMaxWidth
(maxWidth: int) → None¶ Some graphic cards could have 1D & 2D textures with size limitations.
-
setUniqueID
(uid: str) → None¶
-
static
-
class
PyOpenColorIO.GpuShaderDesc.
TextureType
¶ Members:
TEXTURE_RED_CHANNEL
TEXTURE_RGB_CHANNEL
-
property
name
→ str¶
-
TEXTURE_RED_CHANNEL
= <TextureType.TEXTURE_RED_CHANNEL: 0>¶
-
TEXTURE_RGB_CHANNEL
= <TextureType.TEXTURE_RGB_CHANNEL: 1>¶
-
property
value
¶
-
property
-
class
PyOpenColorIO.GpuShaderDesc.
UniformData
¶ -
getBool
() → bool¶
-
getDouble
() → float¶
-
getFloat3
() → List[float[3]]¶
-
getVectorFloat
() → numpy.ndarray¶
-
getVectorInt
() → numpy.ndarray¶
-
property
type
¶
-
-
class
PyOpenColorIO.GpuShaderDesc.
Texture
¶ -
property
channel
¶
-
getValues
() → numpy.ndarray¶
-
property
height
¶
-
property
interpolation
¶
-
property
samplerName
¶
-
property
textureName
¶
-
property
width
¶
-
property
-
class
PyOpenColorIO.GpuShaderDesc.
Texture3D
¶ -
property
edgeLen
¶
-
getValues
() → numpy.ndarray¶
-
property
interpolation
¶
-
property
samplerName
¶
-
property
textureName
¶
-
property
-
class
PyOpenColorIO.GpuShaderDesc.
UniformIterator
¶ -
self
[
arg0: int]
→ tuple¶
-
iter
(self) → PyOpenColorIO.GpuShaderDesc.UniformIterator¶
-
len
(self) → int¶
-
next
(self) → tuple¶
-
self
-
class
PyOpenColorIO.GpuShaderDesc.
TextureIterator
¶ -
self
[
arg0: int]
→ PyOpenColorIO.GpuShaderDesc.Texture¶
-
iter
(self) → PyOpenColorIO.GpuShaderDesc.TextureIterator¶
-
len
(self) → int¶
-
next
(self) → PyOpenColorIO.GpuShaderDesc.Texture¶
-
self
-
class
PyOpenColorIO.GpuShaderDesc.
Texture3DIterator
¶ -
self
[
arg0: int]
→ PyOpenColorIO.GpuShaderDesc.Texture3D¶
-
iter
(self) → PyOpenColorIO.GpuShaderDesc.Texture3DIterator¶
-
len
(self) → int¶
-
next
(self) → PyOpenColorIO.GpuShaderDesc.Texture3D¶
-
self
-
class
PyOpenColorIO.GpuShaderDesc.
DynamicPropertyIterator
¶ -
self
[
arg0: int]
→ PyOpenColorIO.DynamicProperty¶
-
len
(self) → int¶
-
next
(self) → PyOpenColorIO.DynamicProperty¶
-
self
-
class
OpenColorIO_v2_0
::
GpuShaderDesc
: public GpuShaderCreator¶ Public Functions
-
GpuShaderCreatorRcPtr
clone
() const override¶
-
unsigned
getNumUniforms
() const noexcept = 0¶
-
const char *
getUniform
(unsigned index, UniformData &data) const = 0¶ Returns name of uniform and data as parameter.
-
unsigned
getNumTextures
() const noexcept = 0¶
-
void
getTexture
(unsigned index, const char *&textureName, const char *&samplerName, unsigned &width, unsigned &height, TextureType &channel, Interpolation &interpolation) const = 0¶
-
void
getTextureValues
(unsigned index, const float *&values) const = 0¶
-
unsigned
getNum3DTextures
() const noexcept = 0¶
-
void
get3DTexture
(unsigned index, const char *&textureName, const char *&samplerName, unsigned &edgelen, Interpolation &interpolation) const = 0¶
-
void
get3DTextureValues
(unsigned index, const float *&values) const = 0¶
-
const char *
getShaderText
() const noexcept¶ Get the complete OCIO shader program.
-
GpuShaderDesc
(const GpuShaderDesc&) = delete¶
-
GpuShaderDesc &
operator=
(const GpuShaderDesc&) = delete¶
-
~GpuShaderDesc
()¶ Do not use (needed only for pybind11).
Public Static Functions
-
GpuShaderDescRcPtr
CreateLegacyShaderDesc
(unsigned edgelen)¶ Create the legacy shader description.
-
GpuShaderDescRcPtr
CreateShaderDesc
()¶ Create the default shader description.
-
struct
UniformData
¶ Used to retrieve uniform information. UniformData m_type indicates the type of uniform and what member of the structure should be used:
UNIFORM_DOUBLE: m_getDouble.
UNIFORM_BOOL: m_getBool.
UNIFORM_FLOAT3: m_getFloat3.
UNIFORM_VECTOR_FLOAT: m_vectorFloat.
UNIFORM_VECTOR_INT: m_vectorInt.
Public Members
-
UniformDataType
m_type
= {UNIFORM_UNKNOWN}¶
-
DoubleGetter
m_getDouble
= {}¶
-
BoolGetter
m_getBool
= {}¶
-
Float3Getter
m_getFloat3
= {}¶
-
struct OpenColorIO_v2_0::GpuShaderDesc::UniformData::VectorFloat
m_vectorFloat
¶
-
struct OpenColorIO_v2_0::GpuShaderDesc::UniformData::VectorInt
m_vectorInt
¶
-
struct
VectorFloat
¶
-
struct
VectorInt
¶
-
GpuShaderCreatorRcPtr
-
typedef std::shared_ptr<const GpuShaderDesc>
OpenColorIO_v2_0
::
ConstGpuShaderDescRcPtr
¶
-
typedef std::shared_ptr<GpuShaderDesc>
OpenColorIO_v2_0
::
GpuShaderDescRcPtr
¶