Skip to content

Commit 37d8d84

Browse files
committed
Add sampleHemisphereCosine()
1 parent 104a0ff commit 37d8d84

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

include/math/brdf.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ static f32x4 importanceSamplingNdfDggx(float2 u, float linearRoughness) noexcept
127127
auto sinTheta = std::sqrt(1.0f - cosTheta2);
128128
return f32x4(std::cos(phi) * sinTheta, std::sin(phi) * sinTheta, cosTheta);
129129
}
130+
static f32x4 sampleHemisphereCosine(float2 u) noexcept
131+
{
132+
auto phi = u.x * float(M_PI * 2.0);
133+
auto cosTheta = std::sqrt(u.y), sinTheta = std::sqrt(1.0f - u.y);
134+
return f32x4(std::cos(phi) * sinTheta, std::sin(phi) * sinTheta, cosTheta);
135+
}
130136

131137
/**
132138
* @brief Computes diffuse irradiance from spherical harmonics (SH) using a 3rd-order.

0 commit comments

Comments
 (0)