microfacet.h: roughness clamping
parent
a5c574f98d
commit
80cf245b68
|
@ -114,7 +114,7 @@ inline int roundToInt(float value) {
|
||||||
/// Integer round function (double precision)
|
/// Integer round function (double precision)
|
||||||
inline int roundToInt(double value) {
|
inline int roundToInt(double value) {
|
||||||
#if defined(__MSVC__)
|
#if defined(__MSVC__)
|
||||||
return (int) (value < 0.0f ? std::ceil(value - 0.5f) : std::floor(value + 0.5f));
|
return (int) (value < 0.0 ? std::ceil(value - 0.5) : std::floor(value + 0.5));
|
||||||
#else
|
#else
|
||||||
return (int) ::round(value);
|
return (int) ::round(value);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -67,6 +67,8 @@ public:
|
||||||
inline MicrofacetDistribution(EType type, Float alpha, bool sampleVisible = true)
|
inline MicrofacetDistribution(EType type, Float alpha, bool sampleVisible = true)
|
||||||
: m_type(type), m_alphaU(alpha), m_alphaV(alpha), m_sampleVisible(sampleVisible),
|
: m_type(type), m_alphaU(alpha), m_alphaV(alpha), m_sampleVisible(sampleVisible),
|
||||||
m_exponentU(0.0f), m_exponentV(0.0f) {
|
m_exponentU(0.0f), m_exponentV(0.0f) {
|
||||||
|
m_alphaU = std::max(m_alphaU, (Float) 1e-4f);
|
||||||
|
m_alphaV = std::max(m_alphaV, (Float) 1e-4f);
|
||||||
if (m_type == EPhong)
|
if (m_type == EPhong)
|
||||||
computePhongExponent();
|
computePhongExponent();
|
||||||
}
|
}
|
||||||
|
@ -84,6 +86,8 @@ public:
|
||||||
inline MicrofacetDistribution(EType type, Float alphaU, Float alphaV, bool sampleVisible = true)
|
inline MicrofacetDistribution(EType type, Float alphaU, Float alphaV, bool sampleVisible = true)
|
||||||
: m_type(type), m_alphaU(alphaU), m_alphaV(alphaV), m_sampleVisible(sampleVisible),
|
: m_type(type), m_alphaU(alphaU), m_alphaV(alphaV), m_sampleVisible(sampleVisible),
|
||||||
m_exponentU(0.0f), m_exponentV(0.0f) {
|
m_exponentU(0.0f), m_exponentV(0.0f) {
|
||||||
|
m_alphaU = std::max(m_alphaU, (Float) 1e-4f);
|
||||||
|
m_alphaV = std::max(m_alphaV, (Float) 1e-4f);
|
||||||
if (m_type == EPhong)
|
if (m_type == EPhong)
|
||||||
computePhongExponent();
|
computePhongExponent();
|
||||||
}
|
}
|
||||||
|
@ -123,6 +127,14 @@ public:
|
||||||
m_alphaV = props.getFloat("alphaV");
|
m_alphaV = props.getFloat("alphaV");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_alphaU == 0 || m_alphaV == 0) {
|
||||||
|
SLog(EWarn, "Cannot create a microfacet distribution with alphaU/alphaV=0 (clamped to 0.0001)."
|
||||||
|
"Please use the corresponding smooth reflectance model to get zero roughness.");
|
||||||
|
}
|
||||||
|
|
||||||
|
m_alphaU = std::max(m_alphaU, (Float) 1e-4f);
|
||||||
|
m_alphaV = std::max(m_alphaV, (Float) 1e-4f);
|
||||||
|
|
||||||
m_sampleVisible = props.getBoolean("sampleVisible", sampleVisible);
|
m_sampleVisible = props.getBoolean("sampleVisible", sampleVisible);
|
||||||
|
|
||||||
/* Visible normal sampling is not supported for the Phong / Ashikhmin-Shirley distribution */
|
/* Visible normal sampling is not supported for the Phong / Ashikhmin-Shirley distribution */
|
||||||
|
|
Loading…
Reference in New Issue