MaterialX 1.39.1
Loading...
Searching...
No Matches
Harmonics.h
Go to the documentation of this file.
1//
2// Copyright Contributors to the MaterialX Project
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#ifndef MATERIALX_HARMONICS_H
7#define MATERIALX_HARMONICS_H
8
11
15
16MATERIALX_NAMESPACE_BEGIN
17
22template <class C, size_t B> class ShCoeffs
23{
24 public:
25 static const size_t NUM_BANDS = B;
26 static const size_t NUM_COEFFS = B * B;
27
28 public:
29 ShCoeffs() = default;
30 explicit ShCoeffs(const std::array<C, NUM_COEFFS>& arr) :
31 _arr(arr) { }
32
35
37 bool operator==(const ShCoeffs& rhs) const { return _arr == rhs._arr; }
38
40 bool operator!=(const ShCoeffs& rhs) const { return _arr != rhs._arr; }
41
45
47 C& operator[](size_t i) { return _arr.at(i); }
48
50 const C& operator[](size_t i) const { return _arr.at(i); }
51
53
54 protected:
55 std::array<C, NUM_COEFFS> _arr;
56};
57
60
63
70MX_RENDER_API Sh3ColorCoeffs projectEnvironment(ConstImagePtr env, bool irradiance = false);
71
77MX_RENDER_API ImagePtr normalizeEnvironment(ConstImagePtr env, float envRadiance, float maxTexelRadiance);
78
83MX_RENDER_API void computeDominantLight(ConstImagePtr env, Vector3& lightDir, Color3& lightColor);
84
90MX_RENDER_API ImagePtr renderEnvironment(const Sh3ColorCoeffs& shEnv, unsigned int width, unsigned int height);
91
98MX_RENDER_API ImagePtr renderReferenceIrradiance(ConstImagePtr env, unsigned int width, unsigned int height);
99
100MATERIALX_NAMESPACE_END
101
102#endif
MX_RENDER_API ImagePtr renderReferenceIrradiance(ConstImagePtr env, unsigned int width, unsigned int height)
Render a reference irradiance map from the given environment map, using brute-force computations for ...
MX_RENDER_API Sh3ColorCoeffs projectEnvironment(ConstImagePtr env, bool irradiance=false)
Project an environment map to third-order SH, with an optional convolution to convert radiance to irr...
MX_RENDER_API void computeDominantLight(ConstImagePtr env, Vector3 &lightDir, Color3 &lightColor)
Compute the dominant light direction and color of an environment map.
MX_RENDER_API ImagePtr renderEnvironment(const Sh3ColorCoeffs &shEnv, unsigned int width, unsigned int height)
Render the given spherical harmonic signal to an environment map.
MX_RENDER_API ImagePtr normalizeEnvironment(ConstImagePtr env, float envRadiance, float maxTexelRadiance)
Normalize an environment to the given radiance.
Image class.
shared_ptr< const Image > ConstImagePtr
A shared pointer to a const image.
Definition: Image.h:26
shared_ptr< Image > ImagePtr
A shared pointer to an image.
Definition: Image.h:23
Macros for declaring imported and exported symbols.
Data types for rendering functionality.
A three-component color value.
Definition: Types.h:342
Class template for a vector of spherical harmonic coefficients.
Definition: Harmonics.h:23
const C & operator[](size_t i) const
Return the const coefficient at the given index.
Definition: Harmonics.h:50
C & operator[](size_t i)
Return the coefficient at the given index.
Definition: Harmonics.h:47
bool operator!=(const ShCoeffs &rhs) const
Return true if the given vector differs from this one.
Definition: Harmonics.h:40
bool operator==(const ShCoeffs &rhs) const
Return true if the given vector is identical to this one.
Definition: Harmonics.h:37
A vector of three floating-point values.
Definition: Types.h:306