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