paysages : WIP.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@531 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
a78fecdae7
commit
445d59a4be
9 changed files with 58 additions and 34 deletions
2
TODO
2
TODO
|
@ -23,7 +23,7 @@ Technology Preview 2 :
|
||||||
- Fix rendering when inside a cloud layer, with other upper or lower layers.
|
- Fix rendering when inside a cloud layer, with other upper or lower layers.
|
||||||
- Improve cloud rendering precision (and beware of precision discontinuity when rendering clouds in front of ground (shorter distance)).
|
- Improve cloud rendering precision (and beware of precision discontinuity when rendering clouds in front of ground (shorter distance)).
|
||||||
- Top-down previews and explorer renderings should be camera independant.
|
- Top-down previews and explorer renderings should be camera independant.
|
||||||
- Sun radius is too small.
|
- Translations.
|
||||||
|
|
||||||
Technlogy Preview 3 :
|
Technlogy Preview 3 :
|
||||||
- Fully move layer management from BaseForm to BaseFormLayer.
|
- Fully move layer management from BaseForm to BaseFormLayer.
|
||||||
|
|
|
@ -438,6 +438,10 @@ void BasePreview::updateData()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BasePreview::cameraEvent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Color BasePreview::getColor(double, double)
|
Color BasePreview::getColor(double, double)
|
||||||
{
|
{
|
||||||
return COLOR_BLACK;
|
return COLOR_BLACK;
|
||||||
|
@ -692,6 +696,7 @@ void BasePreview::updateScaling()
|
||||||
|
|
||||||
void BasePreview::updateChunks()
|
void BasePreview::updateChunks()
|
||||||
{
|
{
|
||||||
|
cameraEvent();
|
||||||
_drawing_manager->updateChunks(this);
|
_drawing_manager->updateChunks(this);
|
||||||
_revision++;
|
_revision++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void updateData();
|
virtual void updateData();
|
||||||
|
virtual void cameraEvent();
|
||||||
virtual Color getColor(double x, double y);
|
virtual Color getColor(double x, double y);
|
||||||
|
|
||||||
void configHdrToneMapping(bool active);
|
void configHdrToneMapping(bool active);
|
||||||
|
|
|
@ -69,12 +69,13 @@ public:
|
||||||
_renderer->atmosphere->getLightingStatus = _getLightingStatus;
|
_renderer->atmosphere->getLightingStatus = _getLightingStatus;
|
||||||
_renderer->rayWalking = _rayWalking;
|
_renderer->rayWalking = _rayWalking;
|
||||||
_renderer->customData[0] = this;
|
_renderer->customData[0] = this;
|
||||||
|
//cameraSetTarget(&_renderer->render_camera, 0.0, 0.0, 0.0);
|
||||||
|
|
||||||
configScaling(10.0, 1000.0, 10.0, 250.0);
|
configScaling(10.0, 1000.0, 10.0, 250.0);
|
||||||
//configScrolling(-30.0, 30.0, 0.0, -20.0, 20.0, 0.0);
|
//configScrolling(-30.0, 30.0, 0.0, -20.0, 20.0, 0.0);
|
||||||
|
|
||||||
addChoice("bg", tr("Background"), QStringList(tr("None")) << tr("Grid") << tr("Sinusoid"), 2);
|
addChoice("bg", tr("Background"), QStringList(tr("None")) << tr("Grid") << tr("Sinusoid"), 2);
|
||||||
addToggle("light", tr("Lighting"), true);
|
addToggle("light", tr("Light reflection"), true);
|
||||||
}
|
}
|
||||||
int _background;
|
int _background;
|
||||||
bool _lighting_enabled;
|
bool _lighting_enabled;
|
||||||
|
@ -84,7 +85,6 @@ protected:
|
||||||
Vector3 eye, look;
|
Vector3 eye, look;
|
||||||
double target_x, target_z;
|
double target_x, target_z;
|
||||||
|
|
||||||
// TODO Camera location
|
|
||||||
eye.x = 0.0;
|
eye.x = 0.0;
|
||||||
eye.y = scaling;
|
eye.y = scaling;
|
||||||
eye.z = -10.0 * scaling;
|
eye.z = -10.0 * scaling;
|
||||||
|
@ -108,10 +108,14 @@ protected:
|
||||||
|
|
||||||
return _renderer->water->getResult(_renderer, target_x, target_z).final;
|
return _renderer->water->getResult(_renderer, target_x, target_z).final;
|
||||||
}
|
}
|
||||||
|
void cameraEvent()
|
||||||
|
{
|
||||||
|
cameraSetLocation(&_renderer->render_camera, 0.0, scaling, -10.0 * scaling);
|
||||||
|
}
|
||||||
void updateData()
|
void updateData()
|
||||||
{
|
{
|
||||||
WaterRendererClass.bind(_renderer, _definition);
|
WaterRendererClass.bind(_renderer, _definition);
|
||||||
_water.height = 0.0;
|
_renderer->water->definition->height = 0.0;
|
||||||
}
|
}
|
||||||
void choiceChangeEvent(const QString& key, int position)
|
void choiceChangeEvent(const QString& key, int position)
|
||||||
{
|
{
|
||||||
|
@ -132,7 +136,6 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Renderer* _renderer;
|
Renderer* _renderer;
|
||||||
WaterDefinition _water;
|
|
||||||
|
|
||||||
static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector3 direction, int, int, int, int)
|
static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector3 direction, int, int, int, int)
|
||||||
{
|
{
|
||||||
|
@ -172,11 +175,11 @@ private:
|
||||||
static void _getLightingStatus(Renderer* renderer, LightStatus* status, Vector3, int)
|
static void _getLightingStatus(Renderer* renderer, LightStatus* status, Vector3, int)
|
||||||
{
|
{
|
||||||
LightDefinition light;
|
LightDefinition light;
|
||||||
PreviewWaterColor* preview = (PreviewWaterColor*)renderer->customData[2];
|
PreviewWaterColor* preview = (PreviewWaterColor*)renderer->customData[0];
|
||||||
light.color = COLOR_WHITE;
|
light.color = COLOR_WHITE;
|
||||||
light.direction.x = 0.0;
|
light.direction.x = 0.0;
|
||||||
light.direction.y = -0.4794;
|
light.direction.y = -0.4794;
|
||||||
light.direction.z = 0.8776;
|
light.direction.z = -0.8776;
|
||||||
light.altered = 0;
|
light.altered = 0;
|
||||||
if (preview->_lighting_enabled)
|
if (preview->_lighting_enabled)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
void autoGenRealisticLandscape(int seed)
|
void autoGenRealisticLandscape(int seed)
|
||||||
{
|
{
|
||||||
WaterDefinition water;
|
|
||||||
TexturesDefinition textures;
|
TexturesDefinition textures;
|
||||||
TextureLayerDefinition* texture;
|
TextureLayerDefinition* texture;
|
||||||
int layer;
|
int layer;
|
||||||
|
|
|
@ -61,7 +61,6 @@ void cameraCopyDefinition(CameraDefinition* source, CameraDefinition* destinatio
|
||||||
|
|
||||||
void cameraValidateDefinition(CameraDefinition* definition, int check_above)
|
void cameraValidateDefinition(CameraDefinition* definition, int check_above)
|
||||||
{
|
{
|
||||||
WaterDefinition water;
|
|
||||||
Renderer* renderer;
|
Renderer* renderer;
|
||||||
double water_height, terrain_height, diff;
|
double water_height, terrain_height, diff;
|
||||||
Vector3 move;
|
Vector3 move;
|
||||||
|
|
|
@ -283,11 +283,10 @@ static inline Color _getFinalPixel(RenderArea* area, int x, int y)
|
||||||
result.g += col.g / (double)(area->params.antialias * area->params.antialias);
|
result.g += col.g / (double)(area->params.antialias * area->params.antialias);
|
||||||
result.b += col.b / (double)(area->params.antialias * area->params.antialias);
|
result.b += col.b / (double)(area->params.antialias * area->params.antialias);
|
||||||
|
|
||||||
result = colorProfileApply(area->hdr_mapping, result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return colorProfileApply(area->hdr_mapping, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _processDirtyPixels(RenderArea* area)
|
static void _processDirtyPixels(RenderArea* area)
|
||||||
|
|
|
@ -158,7 +158,7 @@ Color lightingApplyOneLight(LightDefinition* light, Vector3 eye, Vector3 locatio
|
||||||
/* specular reflection */
|
/* specular reflection */
|
||||||
if (material->reflection > 0.0 && light->reflection > 0.0)
|
if (material->reflection > 0.0 && light->reflection > 0.0)
|
||||||
{
|
{
|
||||||
Vector3 view = view = v3Normalize(v3Sub(location, eye));
|
Vector3 view = v3Normalize(v3Sub(location, eye));
|
||||||
Vector3 reflect = v3Sub(direction_inv, v3Scale(normal, 2.0 * v3Dot(direction_inv, normal)));
|
Vector3 reflect = v3Sub(direction_inv, v3Scale(normal, 2.0 * v3Dot(direction_inv, normal)));
|
||||||
double specular = v3Dot(reflect, view);
|
double specular = v3Dot(reflect, view);
|
||||||
if (specular > 0.0)
|
if (specular > 0.0)
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include "../renderer.h"
|
#include "../renderer.h"
|
||||||
|
|
||||||
static HeightInfo _FAKE_HEIGHT_INFO = {0.0, 0.0, 0.0};
|
static HeightInfo _FAKE_HEIGHT_INFO = {0.0, 0.0, 0.0};
|
||||||
static WaterResult _FAKE_RESULT = {};
|
|
||||||
|
|
||||||
/******************** Fake ********************/
|
/******************** Fake ********************/
|
||||||
static HeightInfo _fakeGetHeightInfo(Renderer* renderer)
|
static HeightInfo _fakeGetHeightInfo(Renderer* renderer)
|
||||||
|
@ -27,6 +26,8 @@ static WaterResult _fakeGetResult(Renderer* renderer, double x, double z)
|
||||||
{
|
{
|
||||||
WaterResult result;
|
WaterResult result;
|
||||||
|
|
||||||
|
UNUSED(renderer);
|
||||||
|
|
||||||
result.location.x = x;
|
result.location.x = x;
|
||||||
result.location.y = 0.0;
|
result.location.y = 0.0;
|
||||||
result.location.z = z;
|
result.location.z = z;
|
||||||
|
@ -212,9 +213,8 @@ static WaterResult _realGetResult(Renderer* renderer, double x, double z)
|
||||||
WaterDefinition* definition = renderer->water->definition;
|
WaterDefinition* definition = renderer->water->definition;
|
||||||
WaterResult result;
|
WaterResult result;
|
||||||
RayCastingResult refracted;
|
RayCastingResult refracted;
|
||||||
Vector3 location, normal, look;
|
Vector3 location, normal, look_direction;
|
||||||
Color color;
|
Color color;
|
||||||
SurfaceMaterial material;
|
|
||||||
double detail, depth;
|
double detail, depth;
|
||||||
|
|
||||||
location.x = x;
|
location.x = x;
|
||||||
|
@ -229,9 +229,26 @@ static WaterResult _realGetResult(Renderer* renderer, double x, double z)
|
||||||
}
|
}
|
||||||
|
|
||||||
normal = _getNormal(definition, location, detail);
|
normal = _getNormal(definition, location, detail);
|
||||||
look = v3Normalize(renderer->getCameraDirection(renderer, location));
|
look_direction = v3Normalize(v3Sub(location, renderer->getCameraLocation(renderer, location)));
|
||||||
result.reflected = renderer->rayWalking(renderer, location, _reflectRay(look, normal), 1, 0, 1, 1).hit_color;
|
|
||||||
refracted = renderer->rayWalking(renderer, location, _refractRay(look, normal), 1, 0, 1, 1);
|
/* Reflection */
|
||||||
|
if (definition->reflection == 0.0)
|
||||||
|
{
|
||||||
|
result.reflected = COLOR_BLACK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.reflected = renderer->rayWalking(renderer, location, _reflectRay(look_direction, normal), 1, 0, 1, 1).hit_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transparency/refraction */
|
||||||
|
if (definition->transparency == 0.0)
|
||||||
|
{
|
||||||
|
result.refracted = COLOR_BLACK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
refracted = renderer->rayWalking(renderer, location, _refractRay(look_direction, normal), 1, 0, 1, 1);
|
||||||
depth = v3Norm(v3Sub(location, refracted.hit_location));
|
depth = v3Norm(v3Sub(location, refracted.hit_location));
|
||||||
if (depth > definition->transparency_depth)
|
if (depth > definition->transparency_depth)
|
||||||
{
|
{
|
||||||
|
@ -245,18 +262,19 @@ static WaterResult _realGetResult(Renderer* renderer, double x, double z)
|
||||||
result.refracted.b = refracted.hit_color.b * (1.0 - depth) + definition->depth_color.b * depth;
|
result.refracted.b = refracted.hit_color.b * (1.0 - depth) + definition->depth_color.b * depth;
|
||||||
result.refracted.a = 1.0;
|
result.refracted.a = 1.0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
color.r = definition->material.base.r * (1.0 - definition->transparency) + result.reflected.r * definition->reflection + result.refracted.r * definition->transparency;
|
/* Lighting from environment */
|
||||||
color.g = definition->material.base.g * (1.0 - definition->transparency) + result.reflected.g * definition->reflection + result.refracted.g * definition->transparency;
|
color = renderer->applyLightingToSurface(renderer, location, normal, &definition->material);
|
||||||
color.b = definition->material.base.b * (1.0 - definition->transparency) + result.reflected.b * definition->reflection + result.refracted.b * definition->transparency;
|
|
||||||
color.a = 1.0;
|
|
||||||
|
|
||||||
material = definition->material;
|
color.r += result.reflected.r * definition->reflection + result.refracted.r * definition->transparency;
|
||||||
material.base = color;
|
color.g += result.reflected.g * definition->reflection + result.refracted.g * definition->transparency;
|
||||||
|
color.b += result.reflected.b * definition->reflection + result.refracted.b * definition->transparency;
|
||||||
|
|
||||||
_applyFoam(definition, location, normal, detail, &material);
|
/* Merge with foam */
|
||||||
|
// _applyFoam(definition, location, normal, detail, &material);
|
||||||
|
|
||||||
color = renderer->applyLightingToSurface(renderer, location, normal, &material);
|
/* Bring color to the camera */
|
||||||
color = renderer->applyMediumTraversal(renderer, location, color);
|
color = renderer->applyMediumTraversal(renderer, location, color);
|
||||||
|
|
||||||
result.base = definition->material.base;
|
result.base = definition->material.base;
|
||||||
|
|
Loading…
Reference in a new issue