MDL SDK API nvidia_logo_transpbg.gif Up
mi::neuraylib::IBaker Class Referenceabstract

Allows to bake a varying or uniform expression of a compiled material into a texture or constant. More...

#include <imdl_distiller_api.h>

Inheritance diagram for mi::neuraylib::IBaker:

Public Member Functions

virtual const char * get_pixel_type () const =0
 Returns the pixel type that matches the expression to be baked best. More...
 
virtual bool is_uniform () const =0
 Indicates whether the expression to be baked is uniform or varying. More...
 
virtual Sint32 bake_texture (ICanvas *texture, Uint32 samples=1) const =0
 Bakes the expression as texture. More...
 
virtual Sint32 bake_texture (ICanvas *texture, Float32 min_u, Float32 max_u, Float32 min_v, Float32 max_v, Float32 animation_time, Uint32 samples) const =0
 Bakes the expression as texture (supports UV ranges and animated textures). More...
 
virtual Sint32 bake_texture_with_constant_detection (ICanvas *texture, IData *constant, bool &is_constant, Uint32 samples) const =0
 Bakes the expression as texture (supports detection of constants). More...
 
virtual Sint32 bake_texture_with_constant_detection (ICanvas *texture, IData *constant, bool &is_constant, Float32 min_u, Float32 max_u, Float32 min_v, Float32 max_v, Float32 animation_time, Uint32 samples) const =0
 Bakes the expression as texture (supports detection of constants, and UV ranges and animated textures). More...
 
virtual Sint32 bake_constant (IData *constant, Uint32 samples=1) const =0
 Bakes the expression as constant. More...
 
virtual const char * get_type_name () const =0
 Returns the required type name for constants. More...
 
- Public Member Functions inherited from mi::base::IInterface
virtual Uint32 retain () const =0
 Increments the reference count. More...
 
virtual Uint32 release () const =0
 Decrements the reference count. More...
 
virtual const IInterfaceget_interface (const Uuid &interface_id) const =0
 Acquires a const interface from another. More...
 
template<class T>
const T * get_interface () const
 Acquires a const interface from another. More...
 
virtual IInterfaceget_interface (const Uuid &interface_id)=0
 Acquires a mutable interface from another. More...
 
template<class T>
T * get_interface ()
 Acquires a mutable interface from another. More...
 
virtual Uuid get_iid () const =0
 Returns the interface ID of the most derived interface. More...
 

Additional Inherited Members

- Public Types inherited from mi::base::Interface_declare< 0x4dba1b1d, ... >
using Self = Interface_declare< id1, ... >
 Own type. More...
 
using IID = Uuid_t< id1, ... >
 Declares the interface ID (IID) of this interface. More...
 
- Public Types inherited from mi::base::IInterface
using IID = Uuid_t<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>
 Declares the interface ID (IID) of this interface. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0x4dba1b1d, ... >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 
- Static Public Member Functions inherited from mi::base::IInterface
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface. More...
 

Detailed Description

Allows to bake a varying or uniform expression of a compiled material into a texture or constant.

Recommend pixel types and required type names

The following table documents the recommended pixel type for canvases and required type name for constants. These mappings are implemented by get_pixel_type() and get_type_name().

Type of baked expression Recommended pixel type for canvases Required type name for constants
mi::neuraylib::IType::TK_FLOAT "Float32" "Float32"
mi::neuraylib::IType::TK_COLOR "Rgb_fp" "Color"
mi::neuraylib::IType::TK_BOOL "Sint8" "Boolean"
mi::neuraylib::IType::TK_VECTOR with N components
of mi::neuraylib::IType::TK_FLOAT, 2 <= N <= 4
"Float32<N>" "Float32<N>"

Member Function Documentation

 bake_constant()

virtual Sint32 mi::neuraylib::IBaker::bake_constant ( IData constant,
Uint32  samples = 1 
) const
pure virtual

Bakes the expression as constant.

Parameters
constantAn instance of mi::IData of suitable type such that the baked constant can be stored in this argument. See get_type_name() for the required type name.
samplesThe (total) number of samples.
Returns
  • 0: Success.
  • -1: Invalid parameters (nullptr).
  • -2: The transaction that is bound to this baker is no longer open.
  • -3: The execution of the MDL code failed.
  • -4: The type of constant does not match the pixel type corresponding to the expression to be baked.

 bake_texture() [1/2]

virtual Sint32 mi::neuraylib::IBaker::bake_texture ( ICanvas texture,
Float32  min_u,
Float32  max_u,
Float32  min_v,
Float32  max_v,
Float32  animation_time,
Uint32  samples 
) const
pure virtual

Bakes the expression as texture (supports UV ranges and animated textures).

Parameters
textureThe baked texture will be stored in this canvas. If the pixel type of canvas does not match the pixel type of the expression to be baked (as indicated by get_pixel_type()), then the pixel data is converted as described in mi::neuraylib::IImage_api::convert().
min_uThe lower value of the U range used for baking.
max_uThe higher value of the U range used for baking.
min_vThe lower value of the V range used for baking.
max_vThe higher value of the V range used for baking.
animation_timeThe animation time used for baking.
samplesThe number of samples (per pixel).
Returns
  • 0: Success.
  • -1: Invalid parameters (nullptr).
  • -2: The transaction that is bound to this baker is no longer open.
  • -3: The execution of the MDL code failed.

 bake_texture() [2/2]

virtual Sint32 mi::neuraylib::IBaker::bake_texture ( ICanvas texture,
Uint32  samples = 1 
) const
pure virtual

Bakes the expression as texture.

Parameters
textureThe baked texture will be stored in this canvas. If the pixel type of canvas does not match the pixel type of the expression to be baked (as indicated by get_pixel_type()), then the pixel data is converted as described in mi::neuraylib::IImage_api::convert().
samplesThe number of samples (per pixel).
Returns
  • 0: Success.
  • -1: Invalid parameters (nullptr).
  • -2: The transaction that is bound to this baker is no longer open.
  • -3: The execution of the MDL code failed.

 bake_texture_with_constant_detection() [1/2]

virtual Sint32 mi::neuraylib::IBaker::bake_texture_with_constant_detection ( ICanvas texture,
IData constant,
bool &  is_constant,
Float32  min_u,
Float32  max_u,
Float32  min_v,
Float32  max_v,
Float32  animation_time,
Uint32  samples 
) const
pure virtual

Bakes the expression as texture (supports detection of constants, and UV ranges and animated textures).

This method is an improved version of bake_texture(ICanvas*,Float32,Float32,Float32,Float32,Float32,Uint32)constthat detects constant textures.

This method also includes a fast path for uniform expressions, and thus can also be used as a replacement for user-written case distinctions involving is_uniform(), bake_constant(), and bake_texture(ICanvas*,Float32,Float32,Float32,Float32,Float32,Uint32)const. The replacement is not less efficient than the user-written case distinction (ignoring a potentially required allocation of a canvas that is not used for uniform expressions).

Parameters
textureThe baked texture will be stored in this canvas. If the pixel type of canvas does not match the pixel type of the expression to be baked (as indicated by get_pixel_type()), then the pixel data is converted as described in mi::neuraylib::IImage_api::convert().
constantAn instance of mi::IData of suitable type such that the baked constant can be stored in this argument. See get_type_name() for the required type name.
is_constantIndicates (on success) whether texture or constant contains the baked data. No guarantees are given about the contents of the other parameter.
min_uThe lower value of the U range used for baking.
max_uThe higher value of the U range used for baking.
min_vThe lower value of the V range used for baking.
max_vThe higher value of the V range used for baking.
animation_timeThe animation time used for baking.
samplesThe number of samples (per pixel for textures, or total number for constants).
Returns
  • 0: Success.
  • -1: Invalid parameters (nullptr).
  • -2: The transaction that is bound to this baker is no longer open.
  • -3: The execution of the MDL code failed.
  • -4: The type of constant does not match the pixel type corresponding to the expression to be baked.

 bake_texture_with_constant_detection() [2/2]

virtual Sint32 mi::neuraylib::IBaker::bake_texture_with_constant_detection ( ICanvas texture,
IData constant,
bool &  is_constant,
Uint32  samples 
) const
pure virtual

Bakes the expression as texture (supports detection of constants).

This method is an improved version of bake_texture(ICanvas*,Uint32)constthat detects constant textures.

This method also includes a fast path for uniform expressions, and thus can also be used as a replacement for user-written case distinctions involving is_uniform(), bake_constant(), and bake_texture(ICanvas*,Uint32)const. The replacement is not less efficient than the user-written case distinction (ignoring a potentially required allocation of a canvas that is not used for uniform expressions).

Parameters
textureThe baked texture will be stored in this canvas. If the pixel type of canvas does not match the pixel type of the expression to be baked (as indicated by get_pixel_type()), then the pixel data is converted as described in mi::neuraylib::IImage_api::convert().
constantAn instance of mi::IData of suitable type such that the baked constant can be stored in this argument. See get_type_name() for the required type name.
is_constantIndicates (on success) whether texture or constant contains the baked data. No guarantees are given about the contents of the other parameter.
samplesThe number of samples (per pixel for textures, or total number for constants).
Returns
  • 0: Success.
  • -1: Invalid parameters (nullptr).
  • -2: The transaction that is bound to this baker is no longer open.
  • -3: The execution of the MDL code failed.
  • -4: The type of constant does not match the pixel type corresponding to the expression to be baked.

 get_pixel_type()

virtual const char * mi::neuraylib::IBaker::get_pixel_type ( ) const
pure virtual

Returns the pixel type that matches the expression to be baked best.

This pixel type can be used with mi::neuraylib::IImage_api::create_canvas() to create an instance of mi::neuraylib::ICanvas that matches the expression to be baked best.

See also
Recommend pixel types and required type names

 get_type_name()

virtual const char * mi::neuraylib::IBaker::get_type_name ( ) const
pure virtual

Returns the required type name for constants.

This type name can be used with mi::neuraylib::IFactory::create() or mi::neuraylib::ITransaction::create() to create the instance of mi::IData.

See also
Recommend pixel types and required type names

 is_uniform()

virtual bool mi::neuraylib::IBaker::is_uniform ( ) const
pure virtual

Indicates whether the expression to be baked is uniform or varying.

Typically, varying expressions are baked into textures (see bake_texture()), and uniform expressions into constants (see bake_constant()).

Note that it is possible that expressions cannot be proven to be uniform, but still result in a constant texture. The overloads of bake_texture_with_constant_detection() are an improved version of bake_texture() that detect this case.