Subversion Repositories gelsvn

Rev

Rev 346 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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