Partially worked around atmosphere artifacts using an offset to ground
This commit is contained in:
parent
0579cc2c3c
commit
e8d91e30ac
2 changed files with 6 additions and 4 deletions
|
@ -9,6 +9,7 @@ const float HM = 1.2;
|
|||
const vec3 betaMSca = vec3(4e-3);
|
||||
const vec3 betaMEx = vec3(4e-3 / 0.9);
|
||||
const float mieG = 0.8;
|
||||
const float WORKAROUND_OFFSET = 0.2;
|
||||
const float SPHERE_SIZE = 20000.0;
|
||||
const float WORLD_SCALING = 0.05;
|
||||
const float SUN_DISTANCE = 149597870.0;
|
||||
|
@ -187,7 +188,7 @@ vec3 _getInscatterColor(inout vec3 x, inout float t, vec3 v, vec3 s, out float r
|
|||
|
||||
vec4 applyAerialPerspective(vec4 base)
|
||||
{
|
||||
vec3 x = vec3(0.0, Rg + cameraLocation.y * WORLD_SCALING, 0.0);
|
||||
vec3 x = vec3(0.0, Rg + WORKAROUND_OFFSET + cameraLocation.y * WORLD_SCALING, 0.0);
|
||||
vec3 v = normalize(unprojected - cameraLocation);
|
||||
vec3 s = normalize(sunDirection * SUN_DISTANCE_SCALED - x);
|
||||
|
||||
|
@ -230,7 +231,7 @@ vec4 applyLighting(vec3 location, vec3 normal, vec4 color, float shininess)
|
|||
float material_hardness = 0.3;
|
||||
float material_reflection = 1.0;
|
||||
|
||||
float r0 = Rg + location.y * WORLD_SCALING;
|
||||
float r0 = Rg + WORKAROUND_OFFSET + location.y * WORLD_SCALING;
|
||||
vec3 sun_position = sunDirection * SUN_DISTANCE;
|
||||
float muS = dot(vec3(0.0, 1.0, 0.0), normalize(sun_position - vec3(0.0, r0, 0.0)));
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#define SUN_DISTANCE_SCALED (SUN_DISTANCE / WORLD_SCALING)
|
||||
#define SUN_RADIUS 6.955e5
|
||||
#define SUN_RADIUS_SCALED (SUN_RADIUS / WORLD_SCALING)
|
||||
#define WORKAROUND_OFFSET 0.2
|
||||
|
||||
/*********************** Constants ***********************/
|
||||
|
||||
|
@ -1187,7 +1188,7 @@ AtmosphereResult AtmosphereModelBruneton::applyAerialPerspective(Vector3 locatio
|
|||
|
||||
Vector3 direction = location.sub(eye).scale(WORLD_SCALING);
|
||||
|
||||
Vector3 x = {0.0, Rg + eye.y * WORLD_SCALING, 0.0};
|
||||
Vector3 x = {0.0, Rg + WORKAROUND_OFFSET + eye.y * WORLD_SCALING, 0.0};
|
||||
Vector3 v = direction.normalize();
|
||||
Vector3 s = sun_position.sub(x).normalize();
|
||||
|
||||
|
@ -1222,7 +1223,7 @@ void AtmosphereModelBruneton::fillLightingStatus(LightStatus *status, const Vect
|
|||
|
||||
double altitude = status->getLocation().y * WORLD_SCALING;
|
||||
|
||||
double r0 = Rg + altitude;
|
||||
double r0 = Rg + WORKAROUND_OFFSET + altitude;
|
||||
Vector3 up = {0.0, 1.0, 0.0};
|
||||
Vector3 sun_position = parent->getAtmosphereRenderer()->getSunDirection().scale(SUN_DISTANCE);
|
||||
Vector3 x = {0.0, r0, 0.0};
|
||||
|
|
Loading…
Reference in a new issue