paysages : Fixed artifacts of bruneton near horizon line.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@537 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2013-03-10 19:55:24 +00:00 committed by ThunderK
parent 7fe0f04128
commit 1dc8917a4b
4 changed files with 14 additions and 12 deletions

3
TODO
View file

@ -5,8 +5,6 @@ Technology Preview 2 :
=> Add map preview with editor area. => Add map preview with editor area.
=> Allow camera move and zoom. => Allow camera move and zoom.
- Get rid of noise dialogs, for simpler settings. - Get rid of noise dialogs, for simpler settings.
- Finalize Bruneton's model
=> Fix artifacts on aerial perspective (mostly when sun is near horizon)
- Finalize lighting refactoring - Finalize lighting refactoring
=> Restore cloud lighting => Restore cloud lighting
- Hide Preetham's model. - Hide Preetham's model.
@ -16,6 +14,7 @@ Technology Preview 2 :
=> Covering texture height should inpact terrain height. => Covering texture height should inpact terrain height.
=> Add texture shadowing. => Add texture shadowing.
- Clouds should keep distance to ground. - Clouds should keep distance to ground.
- Apply depth filtering to water preview.
- Fix rendering when inside a cloud layer, with other upper or lower layers. - Fix rendering when inside a cloud layer, with other upper or lower layers.
- Improve cloud rendering precision (and beware of precision discontinuity when rendering clouds in front of ground (shorter distance)). - Improve cloud rendering precision (and beware of precision discontinuity when rendering clouds in front of ground (shorter distance)).
- Translations. - Translations.

View file

@ -26,7 +26,7 @@ static const double exposure = 0.4;
static const double ISun = 100.0; static const double ISun = 100.0;
static const double AVERAGE_GROUND_REFLECTANCE = 0.1; static const double AVERAGE_GROUND_REFLECTANCE = 0.1;
#if 0 #if 1
#define RES_MU 128 #define RES_MU 128
#define RES_MU_S 32 #define RES_MU_S 32
#define RES_R 32 #define RES_R 32
@ -863,14 +863,14 @@ static Color _getInscatterColor(Vector3* _x, double* _t, Vector3 v, Vector3 s, d
double muS0 = v3Dot(x0, s) / r0; double muS0 = v3Dot(x0, s) / r0;
/* avoids imprecision problems in transmittance computations based on textures */ /* avoids imprecision problems in transmittance computations based on textures */
*attenuation = _analyticTransmittance(r, mu, t); *attenuation = _analyticTransmittance(r, mu, t);
if (r0 > Rg + 0.01) if (r0 > Rg + 0.001)
{ {
/* computes S[L]-T(x,x0)S[L]|x0 */ /* computes S[L]-T(x,x0)S[L]|x0 */
Color attmod = {attenuation->x, attenuation->y, attenuation->z, attenuation->x}; Color attmod = {attenuation->x, attenuation->y, attenuation->z, attenuation->x};
Color samp = _texture4D(_inscatterTexture, r0, mu0, muS0, nu); Color samp = _texture4D(_inscatterTexture, r0, mu0, muS0, nu);
inscatter = _applyInscatter(inscatter, attmod, samp); inscatter = _applyInscatter(inscatter, attmod, samp);
/* avoids imprecision problems near horizon by interpolating between two points above and below horizon */ /* avoids imprecision problems near horizon by interpolating between two points above and below horizon */
const double EPS = 0.004; const double EPS = 0.02;
double muHoriz = -sqrt(1.0 - (Rg / r) * (Rg / r)); double muHoriz = -sqrt(1.0 - (Rg / r) * (Rg / r));
if (fabs(mu - muHoriz) < EPS) if (fabs(mu - muHoriz) < EPS)
{ {
@ -1151,12 +1151,15 @@ void brunetonInit()
texture4DDelete(_deltaJTexture); texture4DDelete(_deltaJTexture);
} }
Color brunetonGetSkyColor(AtmosphereDefinition* definition, Vector3 eye, Vector3 direction, Vector3 sun_position) Color brunetonGetSkyColor(Renderer* renderer, Vector3 eye, Vector3 direction, Vector3 sun_position)
{ {
UNUSED(definition); double yoffset = GROUND_OFFSET - renderer->water->getHeightInfo(renderer).base_height;
eye.y += yoffset;
/* TODO Water height ? */ if (eye.y < 0.0)
Vector3 x = {0.0, Rg + (max(eye.y, 0.0) + GROUND_OFFSET) * WORLD_SCALING, 0.0}; {
eye.y = 0.0;
}
Vector3 x = {0.0, Rg + eye.y * WORLD_SCALING, 0.0};
Vector3 v = v3Normalize(direction); Vector3 v = v3Normalize(direction);
Vector3 s = v3Normalize(v3Sub(sun_position, x)); Vector3 s = v3Normalize(v3Sub(sun_position, x));

View file

@ -134,7 +134,7 @@ static Color _getSkyColor(Renderer* renderer, Vector3 direction)
switch (definition->model) switch (definition->model)
{ {
case ATMOSPHERE_MODEL_BRUNETON: case ATMOSPHERE_MODEL_BRUNETON:
sky_color = brunetonGetSkyColor(definition, camera_location, direction, sun_position); sky_color = brunetonGetSkyColor(renderer, camera_location, direction, sun_position);
break; break;
case ATMOSPHERE_MODEL_PREETHAM: case ATMOSPHERE_MODEL_PREETHAM:
sky_color = preethamGetSkyColor(definition, camera_location, direction, sun_position); sky_color = preethamGetSkyColor(definition, camera_location, direction, sun_position);

View file

@ -16,7 +16,7 @@ Color basicApplyAerialPerspective(Renderer* renderer, Vector3 location, Color ba
void basicGetLightingStatus(Renderer* renderer, LightStatus* status, Vector3 normal, int opaque); void basicGetLightingStatus(Renderer* renderer, LightStatus* status, Vector3 normal, int opaque);
void brunetonInit(); void brunetonInit();
Color brunetonGetSkyColor(AtmosphereDefinition* definition, Vector3 eye, Vector3 direction, Vector3 sun_position); Color brunetonGetSkyColor(Renderer* renderer, Vector3 eye, Vector3 direction, Vector3 sun_position);
Color brunetonApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base); Color brunetonApplyAerialPerspective(Renderer* renderer, Vector3 location, Color base);
void brunetonGetLightingStatus(Renderer* renderer, LightStatus* status, Vector3 normal, int opaque); void brunetonGetLightingStatus(Renderer* renderer, LightStatus* status, Vector3 normal, int opaque);