Subversion Repositories gelsvn

Rev

Rev 353 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 353 Rev 373
Line 126... Line 126...
126
 
126
 
127
//helper function, clamps v to range [i; a]
127
//helper function, clamps v to range [i; a]
128
template <class T>
128
template <class T>
129
T clamp(const T& v, const T& i, const T& a)
129
T clamp(const T& v, const T& i, const T& a)
130
{
130
{
131
    return std::min(std::max(v, i), a);
131
    return CGLA::s_min(CGLA::s_max(v, i), a);
132
}
132
}
133
 
133
 
134
//mersenne twister
134
//mersenne twister
135
double genrand_real2(void);
135
double genrand_real2(void);
136
inline float mt_random(void)
136
inline float mt_random(void)
Line 175... Line 175...
175
    if (same_hemisphere)
175
    if (same_hemisphere)
176
    {
176
    {
177
        //glossy contribution
177
        //glossy contribution
178
        if (intensity(hi.glossy) > 0.f)
178
        if (intensity(hi.glossy) > 0.f)
179
        {
179
        {
180
            float cost = std::max(dot(reflect(hi.shading_normal, wi), wo),
180
            float cost = CGLA::s_max(dot(reflect(hi.shading_normal, wi), wo), 0.f);
181
                0.f);
-
 
182
            float cosn = std::pow(cost, hi.shininess);
181
            float cosn = std::pow(cost, hi.shininess);
183
            return hi.glossy * (hi.shininess+2.f)/(2.f * float(M_PI))*cosn;
182
            return hi.glossy * (hi.shininess+2.f)/(2.f * float(M_PI))*cosn;
184
        }
183
        }
185
    }
184
    }
186
    return CGLA::Vec3f(0.f);
185
    return CGLA::Vec3f(0.f);