Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::ShapeInvariantMicrofacet Class Referenceabstract

#include <ShapeInvariantMicrofacet.h>

Inheritance diagram for ph::ShapeInvariantMicrofacet:
ph::Microfacet ph::IsoBeckmann ph::TrowbridgeReitz ph::AnisoTrowbridgeReitz ph::IsoTrowbridgeReitz ph::IsoTrowbridgeReitzConstant ph::IsoTrowbridgeReitzTextured

Public Member Functions

 ShapeInvariantMicrofacet (EMaskingShadowing maskingShadowingType)
 
virtual std::array< real, 2 > getAlphas (const SurfaceHit &X) const =0
 
virtual real lambda (const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H, const math::Vector3R &unitDir, const std::array< real, 2 > &alphas) const =0
 The \( \Lambda \left( a \right) \) function that appears in the masking-shadowing term. For isotropic distributions, the variable \( a \) is normally calculated as \( a = \frac{1}{\alpha \tan \left( \theta \right)} \), where \( \frac{1}{\tan \left( \theta \right)} \) is the slope of the unit direction unitDir (with respect to the macrosurface normal N. For anisotropic distributions, see the implementation of AnisoTrowbridgeReitz as an example for calculating \( a \) from the parameters.
 
real distribution (const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H) const override=0
 Distribution of the microfacet normal. The \( D \) term. Also commonly knwon as the NDF (normal distribution function). This term is defined in the half-angle/microfacet space (the angle between N and H) unless otherwise noted.
 
void sampleH (const SurfaceHit &X, const math::Vector3R &N, const std::array< real, 2 > &sample, math::Vector3R *out_H) const override=0
 Generate a microfacet normal H for the distribution. This samples all possible H vectors for the distribution.
 
real geometry (const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H, const math::Vector3R &L, const math::Vector3R &V) const override
 Masking and shadowing due to nearby microfacets. The \( G \) term.
 
lta::PDF pdfSampleH (const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H) const override
 
- Public Member Functions inherited from ph::Microfacet
virtual ~Microfacet ()=default
 
virtual void sampleVisibleH (const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &V, const std::array< real, 2 > &sample, math::Vector3R *out_H) const
 Same as sampleH(), but tries to take geometry term into consideration. This samples only potentially visible H vectors for the distribution. If unable to fully or partly incorporate visibility information from the geometry term, this method will fallback to sampleH().
 
virtual lta::PDF pdfSampleVisibleH (const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H, const math::Vector3R &V) const
 

Protected Member Functions

real smithG1 (real lambdaValue) const
 
real empiricalPhiCorrelation (const SurfaceHit &X, const math::Vector3R &L, const math::Vector3R &V) const
 
real projectedDistribution (const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H) const
 
real visibleDistribution (const SurfaceHit &X, const math::Vector3R &N, const math::Vector3R &H, const math::Vector3R &V) const
 

Protected Attributes

EMaskingShadowing m_maskingShadowingType
 

Additional Inherited Members

- Static Protected Member Functions inherited from ph::Microfacet
static bool isSidednessAgreed (real NoD, real HoD)
 
static bool isSidednessAgreed (real NoL, real NoV, real HoL, real HoV)
 

Detailed Description

A microfacet distribution that always has the same shape. The alpha (mapped from roughness) parameter will only stretch and scale the shape.

Constructor & Destructor Documentation

◆ ShapeInvariantMicrofacet()

ph::ShapeInvariantMicrofacet::ShapeInvariantMicrofacet ( EMaskingShadowing maskingShadowingType)
explicit

Member Function Documentation

◆ distribution()

real ph::ShapeInvariantMicrofacet::distribution ( const SurfaceHit & X,
const math::Vector3R & N,
const math::Vector3R & H ) const
overridepure virtual

Distribution of the microfacet normal. The \( D \) term. Also commonly knwon as the NDF (normal distribution function). This term is defined in the half-angle/microfacet space (the angle between N and H) unless otherwise noted.

Parameters
HThe microfacet normal.
Remarks
Do not treat this term as the probability density of microfacet normal over solid angle.

Implements ph::Microfacet.

Implemented in ph::AnisoTrowbridgeReitz, ph::IsoBeckmann, ph::IsoTrowbridgeReitz, and ph::TrowbridgeReitz.

◆ empiricalPhiCorrelation()

real ph::ShapeInvariantMicrofacet::empiricalPhiCorrelation ( const SurfaceHit & X,
const math::Vector3R & L,
const math::Vector3R & V ) const
protected

The \( \lambda \) term for directional correlation. Note that the function is defined in a way that 0 corresponds to full correlation and 1 corresponds to no correlation.

◆ geometry()

real ph::ShapeInvariantMicrofacet::geometry ( const SurfaceHit & X,
const math::Vector3R & N,
const math::Vector3R & H,
const math::Vector3R & L,
const math::Vector3R & V ) const
overridevirtual

Masking and shadowing due to nearby microfacets. The \( G \) term.

Implements ph::Microfacet.

◆ getAlphas()

virtual std::array< real, 2 > ph::ShapeInvariantMicrofacet::getAlphas ( const SurfaceHit & X) const
pure virtual
Returns
\( \left( \alpha_u, \alpha_v \right) \) in the U and V directions of the macrosirface parametrization. Guaranteed to have \( \alpha_u = \alpha_v \) for an isotropic distribution.

Implemented in ph::AnisoTrowbridgeReitz, ph::IsoBeckmann, ph::IsoTrowbridgeReitz, ph::IsoTrowbridgeReitzConstant, ph::IsoTrowbridgeReitzTextured, and ph::TrowbridgeReitz.

◆ lambda()

virtual real ph::ShapeInvariantMicrofacet::lambda ( const SurfaceHit & X,
const math::Vector3R & N,
const math::Vector3R & H,
const math::Vector3R & unitDir,
const std::array< real, 2 > & alphas ) const
pure virtual

The \( \Lambda \left( a \right) \) function that appears in the masking-shadowing term. For isotropic distributions, the variable \( a \) is normally calculated as \( a = \frac{1}{\alpha \tan \left( \theta \right)} \), where \( \frac{1}{\tan \left( \theta \right)} \) is the slope of the unit direction unitDir (with respect to the macrosurface normal N. For anisotropic distributions, see the implementation of AnisoTrowbridgeReitz as an example for calculating \( a \) from the parameters.

Note
This method does not handle sidedness agreement.

Implemented in ph::AnisoTrowbridgeReitz, ph::IsoBeckmann, ph::IsoTrowbridgeReitz, and ph::TrowbridgeReitz.

◆ pdfSampleH()

lta::PDF ph::ShapeInvariantMicrofacet::pdfSampleH ( const SurfaceHit & X,
const math::Vector3R & N,
const math::Vector3R & H ) const
inlineoverridevirtual
Returns
PDF of generating the specific microfacet normal H using sampleH().

Implements ph::Microfacet.

◆ projectedDistribution()

real ph::ShapeInvariantMicrofacet::projectedDistribution ( const SurfaceHit & X,
const math::Vector3R & N,
const math::Vector3R & H ) const
inlineprotected
Returns
Assuming distribution() is defined in the half-angle/microfacet space, return the value after projecting it onto the macrosurface. This is the normalized form of distribution() and can be a potential sampling PDF for microfacet normals.

◆ sampleH()

void ph::ShapeInvariantMicrofacet::sampleH ( const SurfaceHit & X,
const math::Vector3R & N,
const std::array< real, 2 > & sample,
math::Vector3R * out_H ) const
overridepure virtual

Generate a microfacet normal H for the distribution. This samples all possible H vectors for the distribution.

Parameters
out_HThe generated microfacet normal.
Remarks
Use pdfSampleH() for the probability density of sampling the generated H. distribution() is not a probability density of microfacet normal.

Implements ph::Microfacet.

Implemented in ph::AnisoTrowbridgeReitz, ph::IsoBeckmann, ph::IsoTrowbridgeReitz, and ph::TrowbridgeReitz.

◆ smithG1()

real ph::ShapeInvariantMicrofacet::smithG1 ( real lambdaValue) const
inlineprotected

The \( G_1 \) term of Smith's masking-shadowing function.

◆ visibleDistribution()

real ph::ShapeInvariantMicrofacet::visibleDistribution ( const SurfaceHit & X,
const math::Vector3R & N,
const math::Vector3R & H,
const math::Vector3R & V ) const
inlineprotected

Member Data Documentation

◆ m_maskingShadowingType

EMaskingShadowing ph::ShapeInvariantMicrofacet::m_maskingShadowingType
protected

The documentation for this class was generated from the following files: