Small adjustements

This commit is contained in:
Michaël Lemaire 2013-12-30 17:22:01 +01:00 committed by Michael Lemaire
parent 1131972759
commit 123e434b0a
3 changed files with 17 additions and 8 deletions

View file

@ -58,7 +58,7 @@ void OpenGLTerrain::initialize()
program->addFragmentSource("terrain"); program->addFragmentSource("terrain");
// Add terrain chunks // Add terrain chunks
int chunks = 16; int chunks = 20;
double size = 800.0; double size = 800.0;
double chunksize = size / (double) chunks; double chunksize = size / (double) chunks;
double start = -size / 2.0; double start = -size / 2.0;

View file

@ -57,12 +57,13 @@ public:
virtual double getDensity(const Vector3 &location) const override virtual double getDensity(const Vector3 &location) const override
{ {
Vector3 location_ext(location.x * 0.5, location.y, location.z * 0.5);
double ymin, ymax, thickness; double ymin, ymax, thickness;
getAltitudeRange(&ymin, &ymax); getAltitudeRange(&ymin, &ymax);
thickness = ymax - ymin; thickness = ymax - ymin;
Vector3 center(0.0, ymin + thickness * 0.5, 0.0); Vector3 center(0.0, ymin + thickness * 0.5, 0.0);
double distance = 2.0 * location.sub(center).getNorm() / thickness; double distance = 2.0 * location_ext.sub(center).getNorm() / thickness;
double fallout = 0.7; double fallout = 0.7;
if (distance > 1.0) if (distance > 1.0)
{ {
@ -75,7 +76,7 @@ public:
else else
{ {
double factor = (1.0 - distance) / fallout; double factor = (1.0 - distance) / fallout;
return real_model->getDensity(location) * (1.0 - factor) + factor; return real_model->getDensity(location_ext) * (1.0 - factor) + factor;
} }
} }
@ -120,9 +121,9 @@ Color CloudsAspectPreviewRenderer::getColor2D(double x, double y, double)
model->getAltitudeRange(&ymin, &ymax); model->getAltitudeRange(&ymin, &ymax);
thickness = ymax - ymin; thickness = ymax - ymin;
start.x = x * thickness * 0.5; start.x = x * thickness;
start.y = ymin + (1.0 - y) * thickness * 0.5; start.y = ymin + (1.0 - y) * thickness * 0.5;
start.z = thickness * 0.5; start.z = thickness;
end.x = start.x; end.x = start.x;
end.y = start.y; end.y = start.y;

View file

@ -171,13 +171,13 @@ Color CloudBasicLayerRenderer::getColor(BaseCloudsModel *model, const Vector3 &e
double ymin, ymax; double ymin, ymax;
model->getAltitudeRange(&ymin, &ymax); model->getAltitudeRange(&ymin, &ymax);
double transparency_depth = (ymax - ymin) * 0.3; double transparency_depth = (ymax - ymin) * 0.5;
segment_count = _findSegments(model, parent, start, direction, 20, transparency_depth, max_length, &inside_length, &total_length, segments); segment_count = _findSegments(model, parent, start, direction, 20, transparency_depth, max_length, &inside_length, &total_length, segments);
for (i = segment_count - 1; i >= 0; i--) for (i = segment_count - 1; i >= 0; i--)
{ {
SurfaceMaterial material; SurfaceMaterial material;
material.base = colorToHSL(Color(3.0, 3.0, 3.0)); material.base = colorToHSL(COLOR_WHITE);
material.hardness = 0.25; material.hardness = 0.25;
material.reflection = 0.0; material.reflection = 0.0;
material.shininess = 0.0; material.shininess = 0.0;
@ -185,6 +185,14 @@ Color CloudBasicLayerRenderer::getColor(BaseCloudsModel *model, const Vector3 &e
col = parent->applyLightingToSurface(segments[i].start, parent->getAtmosphereRenderer()->getSunDirection(), material); col = parent->applyLightingToSurface(segments[i].start, parent->getAtmosphereRenderer()->getSunDirection(), material);
double power = col.getPower();
if (power > 0.2)
{
col.r += (power - 0.2) * 1.5;
col.g += (power - 0.2) * 1.5;
col.b += (power - 0.2) * 1.5;
}
col.a = (segments[i].length >= transparency_depth) ? 1.0 : (segments[i].length / transparency_depth); col.a = (segments[i].length >= transparency_depth) ? 1.0 : (segments[i].length / transparency_depth);
result.mask(col); result.mask(col);
} }
@ -216,7 +224,7 @@ bool CloudBasicLayerRenderer::alterLight(BaseCloudsModel *model, LightComponent*
double ymin, ymax; double ymin, ymax;
model->getAltitudeRange(&ymin, &ymax); model->getAltitudeRange(&ymin, &ymax);
double light_traversal = (ymax - ymin) * 0.8; double light_traversal = (ymax - ymin) * 1.2;
_findSegments(model, parent, start, direction, 20, light_traversal, end.sub(start).getNorm(), &inside_depth, &total_depth, segments); _findSegments(model, parent, start, direction, 20, light_traversal, end.sub(start).getNorm(), &inside_depth, &total_depth, segments);
if (light_traversal < 0.0001) if (light_traversal < 0.0001)