Stars optimization and small tweaks
This commit is contained in:
parent
9c79ff51f9
commit
134158c33a
6 changed files with 30 additions and 22 deletions
|
@ -154,7 +154,7 @@ void AtmosphereDefinition::applyPreset(AtmospherePreset preset)
|
|||
;
|
||||
}
|
||||
|
||||
generateStars(5000);
|
||||
generateStars(2000);
|
||||
|
||||
validate();
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ void AtmosphereDefinition::generateStars(int count)
|
|||
{
|
||||
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)
|
||||
{
|
||||
i--;
|
||||
|
|
|
@ -13,6 +13,8 @@ WaterAspectPreviewRenderer::WaterAspectPreviewRenderer(WaterDefinition* definiti
|
|||
lighting = true;
|
||||
background = 2;
|
||||
|
||||
render_quality = 3;
|
||||
|
||||
customData[0] = &lighting;
|
||||
customData[1] = &background;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "SoftwareRenderer.h"
|
||||
#include "Scenery.h"
|
||||
#include "AtmosphereDefinition.h"
|
||||
#include "AtmosphereRenderer.h"
|
||||
#include "SurfaceMaterial.h"
|
||||
#include "LightComponent.h"
|
||||
#include "LightStatus.h"
|
||||
|
@ -37,23 +38,28 @@ const Color NightSky::getColor(double altitude, const Vector3 &direction)
|
|||
Vector3 location(0.0, altitude, 0.0);
|
||||
|
||||
// Get stars
|
||||
for (const auto &star: atmosphere->stars)
|
||||
Vector3 sun_direction = renderer->getAtmosphereRenderer()->getSunDirection();
|
||||
if (sun_direction.y < 0.1)
|
||||
{
|
||||
if (star.location.dotProduct(direction) >= 0)
|
||||
double factor = (sun_direction.y < 0.0) ? 1.0 : 1.0 - (sun_direction.y * 10.0);
|
||||
for (const auto &star: atmosphere->stars)
|
||||
{
|
||||
double radius = star.radius;
|
||||
Vector3 hit1, hit2;
|
||||
int hits = Geometry::rayIntersectSphere(location, direction, star.location, radius, &hit1, &hit2);
|
||||
if (hits > 1)
|
||||
if (star.location.dotProduct(direction) >= 0)
|
||||
{
|
||||
double dist = hit2.sub(hit1).getNorm() / radius; // distance between intersection points (relative to radius)
|
||||
|
||||
Color color = star.col;
|
||||
if (dist <= 0.5)
|
||||
double radius = star.radius;
|
||||
Vector3 hit1, hit2;
|
||||
int hits = Geometry::rayIntersectSphere(location, direction, star.location, radius, &hit1, &hit2);
|
||||
if (hits > 1)
|
||||
{
|
||||
color.a *= 1.0 - dist / 0.5;
|
||||
double dist = hit2.sub(hit1).getNorm() / radius; // distance between intersection points (relative to radius)
|
||||
|
||||
Color color = star.col;
|
||||
if (dist <= 0.5)
|
||||
{
|
||||
color.a *= (1.0 - dist / 0.5) * factor;
|
||||
}
|
||||
result.mask(color);
|
||||
}
|
||||
result.mask(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,9 +141,9 @@ void SoftwareRenderer::disableAtmosphere()
|
|||
light.reflection = 0.0;
|
||||
lights.push_back(light);
|
||||
|
||||
light.color.r = 0.2;
|
||||
light.color.g = 0.2;
|
||||
light.color.b = 0.21;
|
||||
light.color.r = 0.25;
|
||||
light.color.g = 0.25;
|
||||
light.color.b = 0.265;
|
||||
light.direction.x = 1.0;
|
||||
light.direction.y = -0.5;
|
||||
light.direction.z = -1.0;
|
||||
|
|
|
@ -117,7 +117,7 @@ static void _getChunk(SoftwareRenderer* renderer, TerrainRasterizer::TerrainChun
|
|||
int coverage = renderer->render_camera->isUnprojectedBoxInView(box);
|
||||
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)
|
||||
{
|
||||
chunk->detail_hint = 5 * renderer->render_quality;
|
||||
|
@ -139,7 +139,7 @@ void TerrainRasterizer::getTessellationInfo(int displaced)
|
|||
double radius_int, radius_ext;
|
||||
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_count = 2;
|
||||
|
|
|
@ -37,7 +37,7 @@ void CloudModelStratoCumulus::update()
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -55,9 +55,9 @@ double CloudModelStratoCumulus::getDensity(const Vector3 &location) const
|
|||
}
|
||||
else
|
||||
{
|
||||
double x = location.x / noise_scaling;
|
||||
double x = 0.3 * location.x / 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;
|
||||
|
|
Loading…
Reference in a new issue