#include <CookTorranceShader.h>
Inherits Shader.
Inheritance diagram for CookTorranceShader:
Public Member Functions | |
CookTorranceShader (Scene *scene, RGBAColor color, float ka, float kd, float ks, float slope=0.12f, float lambda=0.2f) | |
virtual RGBAColor | shade (const Ray &ray) const |
Private Member Functions | |
const float | distribution (const Vec3f &normal, const Vec3f &Halfway) const |
const float | geometry (const Vec3f &normal, const Vec3f &Halfway, const Vec3f &LightDir, const Vec3f &ViewDir) const |
const float | fresnel (const Vec3f &Halfway, const Vec3f &LightDir) const |
Private Attributes | |
RGBAColor | mColor |
float | mKa |
float | mKd |
float | mKs |
float | mSlope |
float | mLambda |
Definition at line 9 of file CookTorranceShader.h.
CookTorranceShader::CookTorranceShader | ( | Scene * | scene, | |
RGBAColor | color, | |||
float | ka, | |||
float | kd, | |||
float | ks, | |||
float | slope = 0.12f , |
|||
float | lambda = 0.2f | |||
) | [inline] |
Constructor
scene | Pointer to the scene | |
color | Base color | |
ka | Ambient coefficient | |
kd | Diffuse reflection coefficients | |
ks | Specular refelection coefficients | |
slope | The slope of the microfasets (if m is small more directed reflection) | |
lambda | Complex index of refraction |
Definition at line 22 of file CookTorranceShader.h.
Calculate color and shadows
Implements Shader.
Definition at line 41 of file CookTorranceShader.h.
References Ray::dir(), distribution(), Vec3f::dot(), fresnel(), geometry(), Scene::getLight(), Ray::hit(), Light::illuminate(), Scene::lightsCount(), LOG, mColor, mKa, mKd, mKs, Shader::mScene, Shader::mTextures, Shader::normal(), Light::numberOfRays(), Ray::org(), RGBAColor::rgb(), RGBAColor::scale(), Vec3f::scaled(), Ray::t(), and Primitive::texCoord().
const float CookTorranceShader::distribution | ( | const Vec3f & | normal, | |
const Vec3f & | Halfway | |||
) | const [inline, private] |
Calculate the distribution part of the formula
Definition at line 108 of file CookTorranceShader.h.
References Vec3f::dot(), mSlope, and Shader::normal().
Referenced by shade().
const float CookTorranceShader::geometry | ( | const Vec3f & | normal, | |
const Vec3f & | Halfway, | |||
const Vec3f & | LightDir, | |||
const Vec3f & | ViewDir | |||
) | const [inline, private] |
Calculate the geometry term
Definition at line 118 of file CookTorranceShader.h.
References Vec3f::dot(), min(), and Shader::normal().
Referenced by shade().
const float CookTorranceShader::fresnel | ( | const Vec3f & | Halfway, | |
const Vec3f & | LightDir | |||
) | const [inline, private] |
Calculate the fresnel term
Definition at line 127 of file CookTorranceShader.h.
References Vec3f::dot(), and mLambda.
Referenced by shade().
RGBAColor CookTorranceShader::mColor [private] |
float CookTorranceShader::mKa [private] |
float CookTorranceShader::mKd [private] |
float CookTorranceShader::mKs [private] |
float CookTorranceShader::mSlope [private] |
float CookTorranceShader::mLambda [private] |