MCPcopy Create free account
hub / github.com/TheRealMJP/BakingLab / SampleSunLight

Function SampleSunLight

BakingLab/PathTracer.cpp:192–204  ·  view source on GitHub ↗

Computes the difuse and specular contribution from the sun, given a 2D random sample point representing a location on the surface of the light

Source from the content-addressed store, hash-verified

190// Computes the difuse and specular contribution from the sun, given a 2D random sample point
191// representing a location on the surface of the light
192static Float3 SampleSunLight(const Float3& position, const Float3& normal, RTCScene scene,
193 const Float3& diffuseAlbedo, const Float3& cameraPos,
194 bool includeSpecular, Float3 specAlbedo, float roughness,
195 float u1, float u2, Float3& irradiance)
196{
197 // Treat the sun as a spherical area light that's very far away from the surface
198 const float sunDistance = 1000.0f;
199 const float radius = std::tan(DegToRad(AppSettings::SunSize)) * sunDistance;
200 Float3 sunLuminance = AppSettings::SunLuminance();
201 Float3 sunPos = position + AppSettings::SunDirection.Value() * sunDistance;
202 return SampleSphericalAreaLight(position, normal, scene, diffuseAlbedo, cameraPos, includeSpecular,
203 specAlbedo, roughness, u1, u2, radius, sunPos, sunLuminance, irradiance);
204}
205
206// Generates a full list of sample points for all integration types
207void GenerateIntegrationSamples(IntegrationSamples& samples, uint64 sqrtNumSamples, uint64 tileSizeX, uint64 tileSizeY,

Callers 1

PathTraceFunction · 0.85

Calls 5

tanFunction · 0.85
DegToRadFunction · 0.85
SunLuminanceFunction · 0.85
SampleSphericalAreaLightFunction · 0.85
ValueMethod · 0.80

Tested by

no test coverage detected