Subversion Repositories gelsvn

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
688 khor 1
#include "metal.h"
2
 
3
using namespace CGLA;
4
 
5
metal::metal(const CGLA::Vec3f& c, float s, float ior, float ext)
6
: material(ior, ext), color_(c), shininess_(s)
7
{
8
}
9
 
10
void metal::sample(const ray& r, hit_info& hi) const
11
{
12
    //compute fresnel
13
    float cosi = dot(-r.direction, hi.shading_normal);
14
 
15
    if (cosi <= 0.f)
16
        return;
17
 
18
    float f = fresnel_conductor(cosi, ior_, extinction_);
19
 
20
    if (f < 0.f || f > 1.f)
21
        return;
22
 
23
    if (shininess_ < 1000.f)
24
    {
25
        hi.glossy = f * color_;
26
        hi.shininess = shininess_;
27
    }
28
    else
29
    {
30
        hi.reflection = f * color_;
31
    }
32
 
33
    hi.ior = ior_;
34
    hi.extinction = extinction_;
35
}
36
 
37
//02566 framework, Anders Wang Kristensen, awk@imm.dtu.dk, 2007