Stars optimization and small tweaks

This commit is contained in:
Michaël Lemaire 2013-12-29 18:44:12 +01:00
parent 9c79ff51f9
commit 134158c33a
6 changed files with 30 additions and 22 deletions

View file

@ -154,7 +154,7 @@ void AtmosphereDefinition::applyPreset(AtmospherePreset preset)
; ;
} }
generateStars(5000); generateStars(2000);
validate(); validate();
} }
@ -167,7 +167,7 @@ void AtmosphereDefinition::generateStars(int count)
{ {
Star star; Star star;
star.location = Vector3((RandomGenerator::random() - 0.5) * 100000.0, (RandomGenerator::random() - 0.5) * 100000.0, (RandomGenerator::random() - 0.5) * 100000.0); star.location = Vector3((RandomGenerator::random() - 0.5) * 100000.0, (RandomGenerator::random() * 0.5) * 100000.0, (RandomGenerator::random() - 0.5) * 100000.0);
if (star.location.getNorm() < 30000.0) if (star.location.getNorm() < 30000.0)
{ {
i--; i--;

View file

@ -13,6 +13,8 @@ WaterAspectPreviewRenderer::WaterAspectPreviewRenderer(WaterDefinition* definiti
lighting = true; lighting = true;
background = 2; background = 2;
render_quality = 3;
customData[0] = &lighting; customData[0] = &lighting;
customData[1] = &background; customData[1] = &background;
} }

View file

@ -6,6 +6,7 @@
#include "SoftwareRenderer.h" #include "SoftwareRenderer.h"
#include "Scenery.h" #include "Scenery.h"
#include "AtmosphereDefinition.h" #include "AtmosphereDefinition.h"
#include "AtmosphereRenderer.h"
#include "SurfaceMaterial.h" #include "SurfaceMaterial.h"
#include "LightComponent.h" #include "LightComponent.h"
#include "LightStatus.h" #include "LightStatus.h"
@ -37,6 +38,10 @@ const Color NightSky::getColor(double altitude, const Vector3 &direction)
Vector3 location(0.0, altitude, 0.0); Vector3 location(0.0, altitude, 0.0);
// Get stars // Get stars
Vector3 sun_direction = renderer->getAtmosphereRenderer()->getSunDirection();
if (sun_direction.y < 0.1)
{
double factor = (sun_direction.y < 0.0) ? 1.0 : 1.0 - (sun_direction.y * 10.0);
for (const auto &star: atmosphere->stars) for (const auto &star: atmosphere->stars)
{ {
if (star.location.dotProduct(direction) >= 0) if (star.location.dotProduct(direction) >= 0)
@ -51,12 +56,13 @@ const Color NightSky::getColor(double altitude, const Vector3 &direction)
Color color = star.col; Color color = star.col;
if (dist <= 0.5) if (dist <= 0.5)
{ {
color.a *= 1.0 - dist / 0.5; color.a *= (1.0 - dist / 0.5) * factor;
} }
result.mask(color); result.mask(color);
} }
} }
} }
}
// Get moon // Get moon
VectorSpherical moon_location_s = {MOON_DISTANCE_SCALED, atmosphere->moon_theta, -atmosphere->moon_phi}; VectorSpherical moon_location_s = {MOON_DISTANCE_SCALED, atmosphere->moon_theta, -atmosphere->moon_phi};

View file

@ -141,9 +141,9 @@ void SoftwareRenderer::disableAtmosphere()
light.reflection = 0.0; light.reflection = 0.0;
lights.push_back(light); lights.push_back(light);
light.color.r = 0.2; light.color.r = 0.25;
light.color.g = 0.2; light.color.g = 0.25;
light.color.b = 0.21; light.color.b = 0.265;
light.direction.x = 1.0; light.direction.x = 1.0;
light.direction.y = -0.5; light.direction.y = -0.5;
light.direction.z = -1.0; light.direction.z = -1.0;

View file

@ -117,7 +117,7 @@ static void _getChunk(SoftwareRenderer* renderer, TerrainRasterizer::TerrainChun
int coverage = renderer->render_camera->isUnprojectedBoxInView(box); int coverage = renderer->render_camera->isUnprojectedBoxInView(box);
if (coverage > 0) if (coverage > 0)
{ {
chunk->detail_hint = (int)ceil(sqrt((double)coverage) / (double)(25 - 2 * renderer->render_quality)); chunk->detail_hint = (int)ceil(sqrt((double)coverage) / (double)(25 - renderer->render_quality));
if (chunk->detail_hint > 5 * renderer->render_quality) if (chunk->detail_hint > 5 * renderer->render_quality)
{ {
chunk->detail_hint = 5 * renderer->render_quality; chunk->detail_hint = 5 * renderer->render_quality;
@ -139,7 +139,7 @@ void TerrainRasterizer::getTessellationInfo(int displaced)
double radius_int, radius_ext; double radius_int, radius_ext;
double base_chunk_size, chunk_size; double base_chunk_size, chunk_size;
base_chunk_size = 5.0 / (double)renderer->render_quality; base_chunk_size = 8.0 / (double)(renderer->render_quality * renderer->render_quality);
chunk_factor = 1; chunk_factor = 1;
chunk_count = 2; chunk_count = 2;

View file

@ -37,7 +37,7 @@ void CloudModelStratoCumulus::update()
void CloudModelStratoCumulus::getAltitudeRange(double *min_altitude, double *max_altitude) const void CloudModelStratoCumulus::getAltitudeRange(double *min_altitude, double *max_altitude) const
{ {
*min_altitude = 4.0 + 14.0 * layer->altitude; *min_altitude = 10.0 + 10.0 * layer->altitude;
*max_altitude = *min_altitude + 11.0 * layer->scaling; *max_altitude = *min_altitude + 11.0 * layer->scaling;
} }
@ -55,9 +55,9 @@ double CloudModelStratoCumulus::getDensity(const Vector3 &location) const
} }
else else
{ {
double x = location.x / noise_scaling; double x = 0.3 * location.x / noise_scaling;
double y = (location.y - min_altitude) / noise_scaling; double y = (location.y - min_altitude) / noise_scaling;
double z = location.z / noise_scaling; double z = 0.3 * location.z / noise_scaling;
//double coverage = layer->coverage * layer->_coverage_by_altitude->getValue((position.y - layer->altitude) / layer->scaling); //double coverage = layer->coverage * layer->_coverage_by_altitude->getValue((position.y - layer->altitude) / layer->scaling);
double coverage = layer->coverage; double coverage = layer->coverage;