6#ifndef MATERIALX_LIGHTHANDLER_H 
    7#define MATERIALX_LIGHTHANDLER_H 
   18MATERIALX_NAMESPACE_BEGIN
 
   20extern MX_RENDER_API 
const int DEFAULT_ENV_SAMPLE_COUNT;
 
   28using LightIdMap = std::unordered_map<string, unsigned int>;
 
   33class MX_RENDER_API LightHandler
 
   37        _lightTransform(Matrix44::IDENTITY),
 
   38        _directLighting(
true),
 
   39        _indirectLighting(
true),
 
   40        _usePrefilteredMap(
false),
 
   41        _envLightIntensity(1.0f),
 
   42        _envSampleCount(DEFAULT_ENV_SAMPLE_COUNT),
 
   43        _refractionTwoSided(
false)
 
   46    virtual ~LightHandler() { }
 
   57        _lightTransform = mat;
 
 
   63        return _lightTransform;
 
 
   69        _directLighting = enable;
 
 
   75        return _directLighting;
 
 
   81        _indirectLighting = enable;
 
 
   87        return _indirectLighting;
 
 
   97        _envRadianceMap = map;
 
 
  103        return _envRadianceMap;
 
 
  109        _envPrefilteredMap = map;
 
 
  115        return _envPrefilteredMap;
 
 
  121        _usePrefilteredMap = val;
 
 
  127        return _usePrefilteredMap;
 
 
  133        _envIrradianceMap = map;
 
 
  139        return _envIrradianceMap;
 
 
  145        _envSampleCount = count;
 
 
  151        return _envSampleCount;
 
 
  157        _envLightIntensity = intensity;
 
 
  163        return _envLightIntensity;
 
 
  169        _refractionTwoSided = enable;
 
 
  175        return _refractionTwoSided;
 
 
  185        _albedoTable = table;
 
 
  204        _lightSources = lights;
 
 
  210        return _lightSources;
 
 
  216        for (
NodePtr light : _lightSources)
 
  218            if (light->getCategory() == category)
 
 
  255    bool _directLighting;
 
  256    bool _indirectLighting;
 
  257    bool _usePrefilteredMap;
 
  262    float _envLightIntensity;
 
  265    bool _refractionTwoSided;
 
  269    vector<NodePtr> _lightSources;
 
  270    std::unordered_map<string, unsigned int> _lightIdMap;
 
 
  273MATERIALX_NAMESPACE_END
 
The top-level Document class.
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
Definition Document.h:22
shared_ptr< Image > ImagePtr
A shared pointer to an image.
Definition Image.h:23
std::shared_ptr< class LightHandler > LightHandlerPtr
Shared pointer to a LightHandler.
Definition LightHandler.h:25
std::unordered_map< string, unsigned int > LightIdMap
An unordered map from light names to light indices.
Definition LightHandler.h:28
Macros for declaring imported and exported symbols.
Rendering utility methods.
shared_ptr< Node > NodePtr
A shared pointer to a Node.
Definition Node.h:24
A context class for shader generation.
Definition GenContext.h:30
bool getUsePrefilteredMap()
Return whether to use the prefiltered environment lighting model.
Definition LightHandler.h:125
void setDirectLighting(bool enable)
Set whether direct lighting is enabled.
Definition LightHandler.h:67
LightIdMap computeLightIdMap(const vector< NodePtr > &nodes)
From a set of nodes, create a mapping of corresponding nodedef identifiers to numbers.
void setEnvIrradianceMap(ImagePtr map)
Set the environment irradiance map.
Definition LightHandler.h:131
void setEnvPrefilteredMap(ImagePtr map)
Set the environment radiance map for the prefiltered environment lighting model.
Definition LightHandler.h:107
void setUsePrefilteredMap(bool val)
Set whether to use the prefiltered environment lighting model.
Definition LightHandler.h:119
float getEnvLightIntensity()
Return the environment light intensity.
Definition LightHandler.h:161
void findLights(DocumentPtr doc, vector< NodePtr > &lights)
Find lights to use based on an input document.
ImagePtr getEnvPrefilteredMap() const
Return the environment radiance map for the prefiltered environment lighting model.
Definition LightHandler.h:113
NodePtr getFirstLightOfCategory(const string &category)
Return the first light source, if any, of the given category.
Definition LightHandler.h:214
bool getDirectLighting() const
Return whether direct lighting is enabled.
Definition LightHandler.h:73
const vector< NodePtr > & getLightSources() const
Return the vector of light sources.
Definition LightHandler.h:208
static LightHandlerPtr create()
Create a new light handler.
Definition LightHandler.h:49
void setEnvSampleCount(int count)
Set the environment lighting sample count.
Definition LightHandler.h:143
Matrix44 getLightTransform() const
Return the light transform.
Definition LightHandler.h:61
int getEnvSampleCount() const
Return the environment lighting sample count.
Definition LightHandler.h:149
void registerLights(DocumentPtr doc, const vector< NodePtr > &lights, GenContext &context)
Register light node definitions and light count with a given generation context.
void setLightTransform(const Matrix44 &mat)
Set the light transform.
Definition LightHandler.h:55
void setLightSources(const vector< NodePtr > &lights)
Set the vector of light sources.
Definition LightHandler.h:202
void setAlbedoTable(ImagePtr table)
Set the directional albedo table.
Definition LightHandler.h:183
ImagePtr getEnvRadianceMap() const
Return the environment radiance map.
Definition LightHandler.h:101
void setIndirectLighting(bool enable)
Set whether indirect lighting is enabled.
Definition LightHandler.h:79
ImagePtr getEnvIrradianceMap() const
Return the environment irradiance map.
Definition LightHandler.h:137
void addLightSource(NodePtr node)
Add a light source.
const std::unordered_map< string, unsigned int > & getLightIdMap() const
Get a list of identifiers associated with a given light nodedef.
Definition LightHandler.h:231
void setEnvLightIntensity(const float intensity)
Set the environment light intensity.
Definition LightHandler.h:155
ImagePtr getAlbedoTable() const
Return the directional albedo table.
Definition LightHandler.h:189
void setRefractionTwoSided(bool enable)
Set the two-sided refraction property.
Definition LightHandler.h:167
bool getIndirectLighting() const
Return whether indirect lighting is enabled.
Definition LightHandler.h:85
int getRefractionTwoSided() const
Return the two-sided refraction property.
Definition LightHandler.h:173
void setEnvRadianceMap(ImagePtr map)
Set the environment radiance map.
Definition LightHandler.h:95
A 4x4 matrix of floating-point values.
Definition Types.h:656