MCPcopy Create free account
hub / github.com/TheRealMJP/DeferredTexturing / SampleSphere

Function SampleSphere

SampleFramework12/v1.00/Graphics/Sampling.cpp:232–237  ·  view source on GitHub ↗

Returns a point inside of a unit sphere

Source from the content-addressed store, hash-verified

230
231// Returns a point inside of a unit sphere
232Float3 SampleSphere(float x1, float x2, float x3, float u1)
233{
234 Float3 xyz = Float3(x1, x2, x3) * 2.0f - 1.0f;
235 float scale = std::pow(u1, 1.0f / 3.0f) / Float3::Length(xyz);
236 return xyz * scale;
237}
238
239// Returns a random direction on the unit sphere
240Float3 SampleDirectionSphere(float u1, float u2)

Callers

nothing calls this directly

Calls 1

Float3Class · 0.85

Tested by

no test coverage detected