Subversion Repositories gelsvn

Rev

Rev 346 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 346 Rev 349
1
#include "metal.hpp"
1
#include "metal.hpp"
2
 
2
 
3
using namespace CGLA;
3
using namespace CGLA;
4
 
4
 
5
metal::metal(const CGLA::Vec3f& c, float s, float ior, float ext)
5
metal::metal(const CGLA::Vec3f& c, float s, float ior, float ext)
6
: material(ior, ext), color_(c), shininess_(s)
6
: material(ior, ext), color_(c), shininess_(s)
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
	
-
 
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
 
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_;
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
38
 
38
 
39
 
39
 
40

Generated by GNU Enscript 1.6.6.
40

Generated by GNU Enscript 1.6.6.
41
 
41
 
42
 
42
 
43
 
43