paysages : Added light multi sampling (for skydome only).
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@267 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
2001e534d4
commit
c37f87b0cc
3 changed files with 41 additions and 4 deletions
1
TODO
1
TODO
|
@ -1,6 +1,5 @@
|
|||
- ColorGradation dialog.
|
||||
- All noises should use the same entropy pool (saved separately), and avoid reallocs.
|
||||
- Implement light multi-sampling (mainly for skydome).
|
||||
- Implement scaling and scrolling on previews.
|
||||
- Water and terrain LOD moves with the camera, fix it like in the wanderer.
|
||||
- Restore render progress.
|
||||
|
|
|
@ -157,6 +157,44 @@ static Color _applyLightCustom(LightDefinition* definition, Renderer* renderer,
|
|||
|
||||
light = definition->color;
|
||||
|
||||
if (definition->amplitude > 0.0)
|
||||
{
|
||||
// TODO Sampling around light direction
|
||||
int xsamples, ysamples, samples, x, y;
|
||||
double xstep, ystep, factor;
|
||||
LightDefinition sublight;
|
||||
|
||||
ysamples = renderer->render_quality / 4 + 1;
|
||||
xsamples = renderer->render_quality / 2 + 1;
|
||||
samples = xsamples * ysamples + 1;
|
||||
factor = 1.0 / (double)samples;
|
||||
|
||||
xstep = M_PI * 2.0 / (double)xsamples;
|
||||
ystep = M_PI * 0.5 / (double)(ysamples - 1);
|
||||
|
||||
sublight = *definition;
|
||||
sublight.amplitude = 0.0;
|
||||
sublight.color.r *= factor;
|
||||
sublight.color.g *= factor;
|
||||
sublight.color.b *= factor;
|
||||
|
||||
result = _applyLightCustom(&sublight, renderer, location, normal, material);
|
||||
for (x = 0; x < xsamples; x++)
|
||||
{
|
||||
for (y = 0; y < ysamples; y++)
|
||||
{
|
||||
sublight.direction.x = cos(x * xstep) * cos(y * ystep);
|
||||
sublight.direction.y = -sin(y * ystep);
|
||||
sublight.direction.z = sin(x * xstep) * cos(y * ystep);
|
||||
light = _applyLightCustom(&sublight, renderer, location, normal, material);
|
||||
result.r += light.r;
|
||||
result.g += light.g;
|
||||
result.b += light.b;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
direction_inv = v3Scale(definition->direction, -1.0);
|
||||
if (definition->masked)
|
||||
{
|
||||
|
|
|
@ -116,9 +116,9 @@ int skyGetLights(SkyDefinition* sky, LightDefinition* lights, int max_lights)
|
|||
lights[1].direction.y = -1.0;
|
||||
lights[1].direction.z = 0.0;
|
||||
lights[1].color = colorGradationGet(&sky->zenith_color, sky->daytime);
|
||||
lights[1].color.r *= 0.4;
|
||||
lights[1].color.g *= 0.4;
|
||||
lights[1].color.b *= 0.4;
|
||||
lights[1].color.r *= 0.6;
|
||||
lights[1].color.g *= 0.6;
|
||||
lights[1].color.b *= 0.6;
|
||||
lights[1].reflection = 0.0;
|
||||
lights[1].filtered = 1;
|
||||
lights[1].masked = 0;
|
||||
|
|
Loading…
Reference in a new issue