a few bugfixed, re-integrated twosided
parent
4871d6793a
commit
60e0252af3
|
@ -8,6 +8,11 @@
|
|||
<!-- Test the rough diffuse model -->
|
||||
<bsdf type="roughdiffuse"/>
|
||||
|
||||
<!-- Test the two-sided model -->
|
||||
<bsdf type="twosided">
|
||||
<bsdf type="diffuse"/>
|
||||
</bsdf>
|
||||
|
||||
<!-- Test the diffuse transmission model -->
|
||||
<bsdf type="difftrans"/>
|
||||
|
||||
|
@ -110,4 +115,5 @@
|
|||
<string name="distribution" value="beckmann"/>
|
||||
<float name="alpha" value=".7"/>
|
||||
</bsdf>
|
||||
|
||||
</scene>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 172 KiB |
Binary file not shown.
After Width: | Height: | Size: 185 KiB |
Binary file not shown.
After Width: | Height: | Size: 188 KiB |
12
doc/main.bib
12
doc/main.bib
|
@ -46,3 +46,15 @@
|
|||
year = {1994},
|
||||
organization={ACM}
|
||||
}
|
||||
|
||||
@inproceedings{Weidlich2007Arbitrarily,
|
||||
author = {Weidlich, Andrea and Wilkie, Alexander},
|
||||
title = {Arbitrarily layered micro-facet surfaces},
|
||||
booktitle = {Proceedings of the 5th international conference on Computer graphics and interactive techniques in Australia and Southeast Asia},
|
||||
series = {GRAPHITE '07},
|
||||
year = {2007},
|
||||
pages = {171--178},
|
||||
publisher = {ACM},
|
||||
address = {New York, NY, USA}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,15 +12,15 @@ plugins += env.SharedLibrary('roughplastic', ['roughplastic.cpp'])
|
|||
|
||||
# Materials that act as modifiers
|
||||
#plugins += env.SharedLibrary('coating', ['coating.cpp'])
|
||||
#plugins += env.SharedLibrary('twosided', ['twosided.cpp'])
|
||||
plugins += env.SharedLibrary('twosided', ['twosided.cpp'])
|
||||
#plugins += env.SharedLibrary('mask', ['mask.cpp'])
|
||||
plugins += env.SharedLibrary('mixture', ['mixture.cpp'])
|
||||
|
||||
|
||||
# Other materials
|
||||
plugins += env.SharedLibrary('difftrans', ['difftrans.cpp'])
|
||||
plugins += env.SharedLibrary('phong', ['phong.cpp'])
|
||||
#plugins += env.SharedLibrary('ward', ['ward.cpp'])
|
||||
#plugins += env.SharedLibrary('phong', ['phong.cpp'])
|
||||
#plugins += env.SharedLibrary('irawan', ['irawan.cpp'])
|
||||
|
||||
Export('plugins')
|
||||
|
|
|
@ -27,6 +27,7 @@ MTS_NAMESPACE_BEGIN
|
|||
* \parameter{intIOR}{\Float}{Interior index of refraction \default{1.5046}}
|
||||
* \parameter{extIOR}{\Float}{Exterior index of refraction \default{1.0}}
|
||||
* }
|
||||
* This class implements a smooth dielectric coating in the style of \cite{Weidlich2007Arbitrarily}.
|
||||
*
|
||||
* XXX cancel out cosine factors?
|
||||
* XXX did I get the measure conversion terms right?
|
||||
|
|
|
@ -460,7 +460,7 @@ public:
|
|||
|
||||
nEvalsTotal += nEvals;
|
||||
}
|
||||
SLog(EInfo, "Created a " SIZE_T_FMT "-node cubic spline approximation to the rough Frensel "
|
||||
SLog(EInfo, "Created a " SIZE_T_FMT "-node cubic spline approximation to the rough Fresnel "
|
||||
"transmittance (integration took %i ms and " SIZE_T_FMT " function evaluations)",
|
||||
resolution, timer->getMilliseconds(), nEvalsTotal);
|
||||
spline->build();
|
||||
|
|
|
@ -36,6 +36,7 @@ MTS_NAMESPACE_BEGIN
|
|||
* \item \code{ggx}: New distribution proposed by
|
||||
* Walter et al. \cite{Walter07Microfacet}, which is meant to better handle
|
||||
* the long tails observed in measurements of ground surfaces.
|
||||
* Renderings with this distribution may converge slowly.
|
||||
* \item \code{phong}: Classical $\cos^p\theta$ distribution.
|
||||
* Due to the underlying microfacet theory,
|
||||
* the use of this distribution here leads to more realistic
|
||||
|
@ -67,13 +68,9 @@ MTS_NAMESPACE_BEGIN
|
|||
* factor used to modulate the reflectance component\default{1.0}}
|
||||
* }
|
||||
* This plugin implements a realistic microfacet scattering model for rendering
|
||||
* rough conducting materials, such as metals. Microfacet theory describes rough
|
||||
* surfaces as an arrangement of unresolved and ideally specular facets, whose
|
||||
* normal directions are given by a specially chosen \emph{microfacet distribution}.
|
||||
* By accounting for shadowing and masking effects between these facets, it is
|
||||
* possible to reproduce the important off-specular reflections peaks observed
|
||||
* in real-world measurements of such materials.
|
||||
|
||||
* rough conducting materials, such as metals. It can be interpreted as a fancy
|
||||
* version of the Cook-Torrance model and should be preferred over
|
||||
* empirical models like \pluginref{phong} and \pluginref{ward} when possible.
|
||||
* \renderings{
|
||||
* \rendering{Rough copper (Beckmann, $\alpha=0.1$)}
|
||||
* {bsdf_roughconductor_copper.jpg}
|
||||
|
@ -81,9 +78,16 @@ MTS_NAMESPACE_BEGIN
|
|||
* $\alpha_u=0.05,\ \alpha_v=0.3$), see
|
||||
* \lstref{roughconductor-aluminium}}
|
||||
* {bsdf_roughconductor_anisotropic_aluminium.jpg}
|
||||
* \vspace{-7mm}
|
||||
* \vspace{-8mm}
|
||||
* }
|
||||
*
|
||||
* Microfacet theory describes rough
|
||||
* surfaces as an arrangement of unresolved and ideally specular facets, whose
|
||||
* normal directions are given by a specially chosen \emph{microfacet distribution}.
|
||||
* By accounting for shadowing and masking effects between these facets, it is
|
||||
* possible to reproduce the important off-specular reflections peaks observed
|
||||
* in real-world measurements of such materials.
|
||||
*
|
||||
* This plugin is essentially the ``roughened'' equivalent of the (smooth) plugin
|
||||
* \pluginref{conductor}. For very low values of $\alpha$, the two will
|
||||
* be very similar, though scenes using this plugin will take longer to render
|
||||
|
@ -108,8 +112,8 @@ MTS_NAMESPACE_BEGIN
|
|||
* with slight imperfections on an
|
||||
* otherwise smooth surface finish, $\alpha=0.1$ is relatively rough,
|
||||
* and $\alpha=0.3-0.7$ is \emph{extremely} rough (e.g. an etched or ground
|
||||
* finish).
|
||||
* \vspace{-2mm}
|
||||
* finish). Values significantly above that are probably not too realistic.
|
||||
* \vspace{-6mm}
|
||||
* \subsubsection*{Techical details}\vspace{-2mm}
|
||||
* When rendering with the Ashikhmin-Shirley or Phong microfacet
|
||||
* distributions, a conversion is used to turn the specified
|
||||
|
@ -122,7 +126,7 @@ MTS_NAMESPACE_BEGIN
|
|||
* of two distinct roughness values along the tangent and bitangent
|
||||
* directions. This can be used to provide a material with a ``brushed''
|
||||
* appearance. The alignment of the anisotropy will follow the UV
|
||||
* parameterization of the underlying mesh in this case. This means that
|
||||
* parameterization of the underlying mesh in this case. This also means that
|
||||
* such an anisotropic material cannot be applied to triangle meshes that
|
||||
* are missing texture coordinates.
|
||||
*
|
||||
|
@ -131,7 +135,7 @@ MTS_NAMESPACE_BEGIN
|
|||
* in RGB mode, the computations will be much more approximate in this case.
|
||||
* Also note that this material is one-sided---that is, observed from the
|
||||
* back side, it will be completely black. If this is undesirable,
|
||||
* consider using the \pluginref{twosided} BRDF adapter plugin.
|
||||
* consider using the \pluginref{twosided} BRDF adapter.
|
||||
*
|
||||
* \begin{xml}[caption={A material definition for brushed aluminium}, label=lst:roughconductor-aluminium]
|
||||
* <bsdf type="roughconductor">
|
||||
|
@ -310,10 +314,11 @@ public:
|
|||
const Spectrum F = fresnelConductor(Frame::cosTheta(bRec.wi),
|
||||
m_eta, m_k);
|
||||
|
||||
Float numerator = m_distribution.G(bRec.wi, bRec.wo, m, alphaU, alphaV)
|
||||
Float numerator = m_distribution.eval(m, alphaU, alphaV)
|
||||
* m_distribution.G(bRec.wi, bRec.wo, m, alphaU, alphaV)
|
||||
* dot(bRec.wi, m);
|
||||
|
||||
Float denominator = Frame::cosTheta(m)
|
||||
Float denominator = m_distribution.pdf(m, alphaU, alphaV)
|
||||
* Frame::cosTheta(bRec.wi);
|
||||
|
||||
return m_specularReflectance->getValue(bRec.its) * F
|
||||
|
|
|
@ -135,7 +135,7 @@ MTS_NAMESPACE_BEGIN
|
|||
* of two distinct roughness values along the tangent and bitangent
|
||||
* directions. This can be used to provide a material with a ``brushed''
|
||||
* appearance. The alignment of the anisotropy will follow the UV
|
||||
* parameterization of the underlying mesh in this case. This means that
|
||||
* parameterization of the underlying mesh in this case. This also means that
|
||||
* such an anisotropic material cannot be applied to triangle meshes that
|
||||
* are missing texture coordinates.\newpage
|
||||
*
|
||||
|
|
|
@ -53,7 +53,7 @@ MTS_NAMESPACE_BEGIN
|
|||
* \default{0.1}.
|
||||
* }
|
||||
* \parameter{intIOR}{\Float\Or\String}{Interior index of refraction specified
|
||||
* numerically or using a known material name. \default{\texttt{bk7} / 1.5046}}
|
||||
* numerically or using a known material name. \default{\texttt{polypropylene} / 1.49}}
|
||||
* \parameter{extIOR}{\Float\Or\String}{Exterior index of refraction specified
|
||||
* numerically or using a known material name. \default{\texttt{air} / 1.000277}}
|
||||
* \parameter{specular\showbreak Reflectance}{\Spectrum\Or\Texture}{Optional
|
||||
|
@ -62,10 +62,73 @@ MTS_NAMESPACE_BEGIN
|
|||
* factor used to modulate the diffuse reflectance component\default{0.5}}
|
||||
* }
|
||||
* \renderings{
|
||||
* \rendering{Beckmann, $\alpha=0.1$}{bsdf_roughplastic_ggx}
|
||||
* \rendering{GGX, $\alpha=0.3$}{bsdf_roughplastic_ggx}
|
||||
* \medrendering{Beckmann, $\alpha=0.05$, \texttt{diffuse}
|
||||
* \showbreak\texttt{Reflectance=0}, \lstref{roughplastic-lacquer}}{bsdf_roughplastic_beckmann_lacquer}
|
||||
* \medrendering{Beckmann, $\alpha=0.1$}{bsdf_roughplastic_beckmann}
|
||||
* \medrendering{GGX, $\alpha=0.3$}{bsdf_roughplastic_ggx}
|
||||
* }
|
||||
*
|
||||
* This plugin implements a realistic microfacet scattering model for rendering
|
||||
* rough dielectric materials with internal scattering, such as plastic. It can
|
||||
* be interpreted as a fancy version of the Cook-Torrance model and should be
|
||||
* preferred over empirical models like \pluginref{phong} and \pluginref{ward}
|
||||
* when possible.
|
||||
*
|
||||
* Microfacet theory describes rough surfaces as an arrangement of unresolved and
|
||||
* ideally specular facets, whose normal directions are given by a specially
|
||||
* chosen \emph{microfacet distribution}.
|
||||
* By accounting for shadowing and masking effects between these facets, it is
|
||||
* possible to reproduce the important off-specular reflections peaks observed
|
||||
* in real-world measurements of such materials.
|
||||
*
|
||||
* This plugin is essentially the ``roughened'' equivalent of the (smooth) plugin
|
||||
* \pluginref{plastic}. For very low values of $\alpha$, the two will
|
||||
* be very similar, though scenes using this plugin will take longer to render
|
||||
* due to the additional computational burden of tracking surface roughness.
|
||||
*
|
||||
* The model uses the integrated specular reflectance to interpolate between the
|
||||
* specular and diffuse components (i.e. any light that is not scattered
|
||||
* specularly is assumed to contribute to the diffuse component).
|
||||
* Similar to the \pluginref{dielectric} plugin, IOR values
|
||||
* can either be specified numerically, or based on a list of known materials
|
||||
* (see \tblref{dielectric-iors} for an overview).
|
||||
*
|
||||
* The implementation is based on the paper ``Microfacet Models
|
||||
* for Refraction through Rough Surfaces'' by Walter et al.
|
||||
* \cite{Walter07Microfacet}. It supports several different types of microfacet
|
||||
* distributions. Note that the choices are a bit more restricted here---in
|
||||
* comparison to other rough scattering models in Mitsuba,
|
||||
* the roughness cannot be textured, and anisotropic microfacet
|
||||
* distributions are not allowed.
|
||||
*
|
||||
* When no parameters are given, the plugin activates the default settings,
|
||||
* which describe a white polypropylene plastic material with a light amount
|
||||
* of roughness modeled using the Beckmann distribution.
|
||||
*
|
||||
* To get an intuition about the effect of the surface roughness
|
||||
* parameter $\alpha$, consider the following approximate differentiation:
|
||||
* a value of $\alpha=0.001-0.01$ corresponds to a material
|
||||
* with slight imperfections on an
|
||||
* otherwise smooth surface finish, $\alpha=0.1$ is relatively rough,
|
||||
* and $\alpha=0.3-0.7$ is \emph{extremely} rough (e.g. an etched or ground
|
||||
* finish). Values significantly above that are probably not too realistic.
|
||||
*
|
||||
* When rendering with the Phong microfacet
|
||||
* distributions, a conversion is used to turn the specified
|
||||
* $\alpha$ roughness value into the Phong exponent.
|
||||
* This is done in a way, such that the different
|
||||
* distributions all produce a similar appearance for
|
||||
* the same value of $\alpha$.\vspace{5mm}
|
||||
*
|
||||
* \begin{xml}[caption={A material definition for rough, black laquer.}, label=lst:roughplastic-lacquer]
|
||||
* <bsdf type="roughplastic">
|
||||
* <string name="distribution" value="beckmann"/>
|
||||
* <float name="alpha" value="0.05"/>
|
||||
* <float name="intIOR" value="1.61"/>
|
||||
* <spectrum name="diffuseReflectance" value="0"/>
|
||||
* </bsdf>
|
||||
* \end{xml}
|
||||
*
|
||||
*/
|
||||
class RoughPlastic : public BSDF {
|
||||
public:
|
||||
|
@ -76,7 +139,7 @@ public:
|
|||
props.getSpectrum("diffuseReflectance", Spectrum(0.5f)));
|
||||
|
||||
/* Specifies the internal index of refraction at the interface */
|
||||
m_intIOR = lookupIOR(props, "intIOR", "bk7");
|
||||
m_intIOR = lookupIOR(props, "intIOR", "polypropylene");
|
||||
|
||||
/* Specifies the external index of refraction at the interface */
|
||||
m_extIOR = lookupIOR(props, "extIOR", "air");
|
||||
|
|
|
@ -24,7 +24,17 @@ MTS_NAMESPACE_BEGIN
|
|||
|
||||
/*! \plugin{twosided}{Two-sided BRDF adapter}
|
||||
*
|
||||
* Turns a nested one-sided BRDF onto a two-sided version that
|
||||
* By default, all non-transmissive scattering models in Mitsuba
|
||||
* are \emph{one-sided} --- in other words, they absorb all light
|
||||
* that is received on the backs-side or interior of any surfaces
|
||||
* associated with them. Holes in a mesh will thus be
|
||||
*
|
||||
* This is usually a good idea, since it will expose modeling
|
||||
* issues early on. But sometimes one is forced to deal with such
|
||||
* a bad mesh. In this case, this plugin that cannot be fixed.
|
||||
*
|
||||
*
|
||||
* This plugin turns a nested one-sided model onto a two-sided version that
|
||||
* can be used to render meshes where the back-side is visible.
|
||||
*
|
||||
* \begin{xml}
|
||||
|
@ -65,23 +75,22 @@ public:
|
|||
"a transmission component can be nested!");
|
||||
}
|
||||
|
||||
Spectrum eval(const BSDFQueryRecord &bRec) const {
|
||||
Spectrum eval(const BSDFQueryRecord &bRec, EMeasure measure) const {
|
||||
BSDFQueryRecord b(bRec);
|
||||
if (Frame::cosTheta(b.wi) < 0) {
|
||||
b.wi.z *= -1;
|
||||
b.wo.z *= -1;
|
||||
}
|
||||
return m_nestedBRDF->eval(b);
|
||||
return m_nestedBRDF->eval(b, measure);
|
||||
}
|
||||
|
||||
|
||||
Float pdf(const BSDFQueryRecord &bRec) const {
|
||||
Float pdf(const BSDFQueryRecord &bRec, EMeasure measure) const {
|
||||
BSDFQueryRecord b(bRec);
|
||||
if (b.wi.z < 0) {
|
||||
b.wi.z *= -1;
|
||||
b.wo.z *= -1;
|
||||
}
|
||||
return m_nestedBRDF->pdf(b);
|
||||
return m_nestedBRDF->pdf(b, measure);
|
||||
}
|
||||
|
||||
Spectrum sample(BSDFQueryRecord &bRec, const Point2 &sample) const {
|
||||
|
@ -112,7 +121,7 @@ public:
|
|||
|
||||
if (flipped) {
|
||||
bRec.wi.z *= -1;
|
||||
|
||||
|
||||
if (!result.isZero() && pdf != 0)
|
||||
bRec.wo.z *= -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue