Merge branch 'master' into vegetation
This commit is contained in:
commit
bdb2a3edb8
8 changed files with 28 additions and 22 deletions
|
@ -3,6 +3,8 @@
|
|||
#include "PackStream.h"
|
||||
#include "Color.h"
|
||||
|
||||
static SurfaceMaterial DEFAULT;
|
||||
|
||||
SurfaceMaterial::SurfaceMaterial():
|
||||
SurfaceMaterial(COLOR_BLACK)
|
||||
{
|
||||
|
@ -28,6 +30,11 @@ SurfaceMaterial::~SurfaceMaterial()
|
|||
delete base;
|
||||
}
|
||||
|
||||
const SurfaceMaterial &SurfaceMaterial::getDefault()
|
||||
{
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
void SurfaceMaterial::setColor(double r, double g, double b, double a)
|
||||
{
|
||||
base->r = r;
|
||||
|
|
|
@ -14,6 +14,8 @@ public:
|
|||
SurfaceMaterial(const SurfaceMaterial &other);
|
||||
~SurfaceMaterial();
|
||||
|
||||
static const SurfaceMaterial &getDefault();
|
||||
|
||||
void setColor(double r, double g, double b, double a);
|
||||
|
||||
void save(PackStream *stream) const;
|
||||
|
|
|
@ -242,7 +242,7 @@ double OpenGLRenderer::getPrecision(const Vector3 &)
|
|||
return 0.0000001;
|
||||
}
|
||||
|
||||
Color OpenGLRenderer::applyMediumTraversal(Vector3, Color color)
|
||||
Color OpenGLRenderer::applyMediumTraversal(const Vector3&, const Color &color)
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
inline OpenGLSharedState* getSharedState() const {return shared_state;}
|
||||
|
||||
virtual double getPrecision(const Vector3 &location) override;
|
||||
virtual Color applyMediumTraversal(Vector3 location, Color color) override;
|
||||
virtual Color applyMediumTraversal(const Vector3 &location, const Color &color) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
|
|
@ -83,7 +83,7 @@ BaseAtmosphereRenderer::BaseAtmosphereRenderer(SoftwareRenderer* renderer):
|
|||
{
|
||||
}
|
||||
|
||||
AtmosphereResult BaseAtmosphereRenderer::applyAerialPerspective(Vector3, Color base)
|
||||
AtmosphereResult BaseAtmosphereRenderer::applyAerialPerspective(const Vector3 &, const Color &base)
|
||||
{
|
||||
AtmosphereResult result;
|
||||
result.base = result.final = base;
|
||||
|
@ -91,7 +91,7 @@ AtmosphereResult BaseAtmosphereRenderer::applyAerialPerspective(Vector3, Color b
|
|||
return result;
|
||||
}
|
||||
|
||||
AtmosphereResult BaseAtmosphereRenderer::getSkyColor(Vector3)
|
||||
AtmosphereResult BaseAtmosphereRenderer::getSkyColor(const Vector3 &)
|
||||
{
|
||||
AtmosphereResult result;
|
||||
result.base = result.final = COLOR_WHITE;
|
||||
|
@ -127,7 +127,7 @@ SoftwareBrunetonAtmosphereRenderer::~SoftwareBrunetonAtmosphereRenderer()
|
|||
delete model;
|
||||
}
|
||||
|
||||
AtmosphereResult SoftwareBrunetonAtmosphereRenderer::applyAerialPerspective(Vector3 location, Color base)
|
||||
AtmosphereResult SoftwareBrunetonAtmosphereRenderer::applyAerialPerspective(const Vector3 &location, const Color &base)
|
||||
{
|
||||
AtmosphereDefinition* definition = getDefinition();
|
||||
AtmosphereResult result;
|
||||
|
@ -151,7 +151,7 @@ AtmosphereResult SoftwareBrunetonAtmosphereRenderer::applyAerialPerspective(Vect
|
|||
return result;
|
||||
}
|
||||
|
||||
AtmosphereResult SoftwareBrunetonAtmosphereRenderer::getSkyColor(Vector3 direction)
|
||||
AtmosphereResult SoftwareBrunetonAtmosphereRenderer::getSkyColor(const Vector3 &direction)
|
||||
{
|
||||
AtmosphereDefinition* definition;
|
||||
Vector3 sun_direction, sun_position, camera_location;
|
||||
|
@ -161,13 +161,13 @@ AtmosphereResult SoftwareBrunetonAtmosphereRenderer::getSkyColor(Vector3 directi
|
|||
camera_location = parent->getCameraLocation(VECTOR_ZERO);
|
||||
|
||||
sun_direction = getSunDirection();
|
||||
direction = direction.normalize();
|
||||
Vector3 direction_norm = direction.normalize();
|
||||
sun_position = sun_direction.scale(SUN_DISTANCE_SCALED);
|
||||
|
||||
base = COLOR_BLACK;
|
||||
|
||||
// Get night sky
|
||||
base = base.add(parent->getNightSky()->getColor(camera_location.y, direction));
|
||||
base = base.add(parent->getNightSky()->getColor(camera_location.y, direction_norm));
|
||||
|
||||
// Get sun shape
|
||||
/*if (v3Dot(sun_direction, direction) >= 0)
|
||||
|
@ -196,11 +196,11 @@ AtmosphereResult SoftwareBrunetonAtmosphereRenderer::getSkyColor(Vector3 directi
|
|||
|
||||
// Get scattering
|
||||
AtmosphereResult result;
|
||||
Vector3 location = camera_location.add(direction.scale(6421.0));
|
||||
Vector3 location = camera_location.add(direction_norm.scale(6421.0));
|
||||
switch (definition->model)
|
||||
{
|
||||
case AtmosphereDefinition::ATMOSPHERE_MODEL_BRUNETON:
|
||||
result = model->getSkyColor(camera_location, direction, sun_position, base);
|
||||
result = model->getSkyColor(camera_location, direction_norm, sun_position, base);
|
||||
break;
|
||||
default:
|
||||
result = BaseAtmosphereRenderer::applyAerialPerspective(location, result.base);
|
||||
|
|
|
@ -14,8 +14,8 @@ public:
|
|||
BaseAtmosphereRenderer(SoftwareRenderer* parent);
|
||||
virtual ~BaseAtmosphereRenderer() {}
|
||||
|
||||
virtual AtmosphereResult applyAerialPerspective(Vector3 location, Color base);
|
||||
virtual AtmosphereResult getSkyColor(Vector3 direction);
|
||||
virtual AtmosphereResult applyAerialPerspective(const Vector3 &location, const Color &base);
|
||||
virtual AtmosphereResult getSkyColor(const Vector3 &direction);
|
||||
virtual Vector3 getSunDirection(bool cache=true) const;
|
||||
|
||||
virtual bool getLightsAt(std::vector<LightComponent> &result, const Vector3 &location) const override;
|
||||
|
@ -31,8 +31,8 @@ public:
|
|||
SoftwareBrunetonAtmosphereRenderer(SoftwareRenderer* parent);
|
||||
virtual ~SoftwareBrunetonAtmosphereRenderer();
|
||||
|
||||
virtual AtmosphereResult applyAerialPerspective(Vector3 location, Color base) override;
|
||||
virtual AtmosphereResult getSkyColor(Vector3 direction) override;
|
||||
virtual AtmosphereResult applyAerialPerspective(const Vector3 &location, const Color &base) override;
|
||||
virtual AtmosphereResult getSkyColor(const Vector3 &direction) override;
|
||||
|
||||
virtual bool getLightsAt(std::vector<LightComponent> &result, const Vector3 &location) const override;
|
||||
|
||||
|
|
|
@ -117,14 +117,11 @@ Color SoftwareRenderer::applyLightingToSurface(const Vector3 &location, const Ve
|
|||
return lighting->apply(getCameraLocation(location), location, normal, material);
|
||||
}
|
||||
|
||||
Color SoftwareRenderer::applyMediumTraversal(Vector3 location, Color color)
|
||||
Color SoftwareRenderer::applyMediumTraversal(const Vector3 &location, const Color &color)
|
||||
{
|
||||
color = atmosphere_renderer->applyAerialPerspective(location, color).final;
|
||||
color = clouds_renderer->getColor(getCameraLocation(location), location, color);
|
||||
return color;
|
||||
|
||||
/*Vector3 eye = cameraGetLocation(scenery->getCamera());
|
||||
return fluid_medium->applyTraversal(eye, location, color);*/
|
||||
Color result = atmosphere_renderer->applyAerialPerspective(location, color).final;
|
||||
result = clouds_renderer->getColor(getCameraLocation(location), location, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RayCastingResult SoftwareRenderer::rayWalking(const Vector3 &location, const Vector3 &direction, int, int, int, int)
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
inline GodRaysSampler* getGodRaysSampler() const {return godrays;}
|
||||
|
||||
virtual Color applyLightingToSurface(const Vector3 &location, const Vector3 &normal, const SurfaceMaterial &material);
|
||||
virtual Color applyMediumTraversal(Vector3 location, Color color);
|
||||
virtual Color applyMediumTraversal(const Vector3 &location, const Color &color);
|
||||
virtual RayCastingResult rayWalking(const Vector3 &location, const Vector3 &direction, int terrain, int water, int sky, int clouds);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue