| 38 | } |
| 39 | |
| 40 | Vec2f Distribution2D::sample(const Vec2f& u) const |
| 41 | { |
| 42 | /*! use u.y to sample a row */ |
| 43 | float sy = yDist.sample(u.y); |
| 44 | int idx = clamp(int(sy),0,int(height)-1); |
| 45 | |
| 46 | /*! use u.x to sample inside the row */ |
| 47 | float sx = xDists[idx].sample(u.x); |
| 48 | return Vec2f(sx,sy); |
| 49 | } |
| 50 | |
| 51 | float Distribution2D::pdf(const Vec2f& p) const { |
| 52 | int idx = clamp(int(p.y*height),0,int(height)-1); |