Added /water/reflection property
This commit is contained in:
parent
3cb287dfeb
commit
982af74c2d
11 changed files with 79 additions and 24 deletions
|
@ -14,7 +14,7 @@
|
||||||
height="297mm"
|
height="297mm"
|
||||||
id="svg2"
|
id="svg2"
|
||||||
version="1.1"
|
version="1.1"
|
||||||
inkscape:version="0.48.4 r9939"
|
inkscape:version="0.91 r13725"
|
||||||
sodipodi:docname="icons.svg"
|
sodipodi:docname="icons.svg"
|
||||||
inkscape:export-filename="/home/michael/workspace/paysages3d/graphics/icons.png"
|
inkscape:export-filename="/home/michael/workspace/paysages3d/graphics/icons.png"
|
||||||
inkscape:export-xdpi="154.89854"
|
inkscape:export-xdpi="154.89854"
|
||||||
|
@ -28,19 +28,21 @@
|
||||||
borderopacity="1.0"
|
borderopacity="1.0"
|
||||||
inkscape:pageopacity="0.0"
|
inkscape:pageopacity="0.0"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:zoom="1.979899"
|
inkscape:zoom="2.8"
|
||||||
inkscape:cx="468.77289"
|
inkscape:cx="274.84974"
|
||||||
inkscape:cy="831.55692"
|
inkscape:cy="462.35469"
|
||||||
inkscape:document-units="px"
|
inkscape:document-units="px"
|
||||||
inkscape:current-layer="g3986"
|
inkscape:current-layer="g3986"
|
||||||
showgrid="true"
|
showgrid="true"
|
||||||
inkscape:window-width="1920"
|
inkscape:window-width="1920"
|
||||||
inkscape:window-height="1030"
|
inkscape:window-height="1037"
|
||||||
inkscape:window-x="1440"
|
inkscape:window-x="1440"
|
||||||
inkscape:window-y="25"
|
inkscape:window-y="20"
|
||||||
inkscape:window-maximized="1"
|
inkscape:window-maximized="0"
|
||||||
showguides="true"
|
showguides="true"
|
||||||
inkscape:snap-object-midpoints="false">
|
inkscape:snap-object-midpoints="false"
|
||||||
|
inkscape:object-nodes="false"
|
||||||
|
inkscape:snap-grids="true">
|
||||||
<inkscape:grid
|
<inkscape:grid
|
||||||
type="xygrid"
|
type="xygrid"
|
||||||
id="grid3004" />
|
id="grid3004" />
|
||||||
|
@ -99,6 +101,13 @@
|
||||||
sodipodi:nodetypes="ccccccccccc" />
|
sodipodi:nodetypes="ccccccccccc" />
|
||||||
<g
|
<g
|
||||||
id="g3986">
|
id="g3986">
|
||||||
|
<rect
|
||||||
|
style="opacity:1;fill:#656565;fill-opacity:1;stroke:none;stroke-width:3.4000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||||
|
id="rect4171-0"
|
||||||
|
width="50"
|
||||||
|
height="30.000034"
|
||||||
|
x="180"
|
||||||
|
y="567.36218" />
|
||||||
<g
|
<g
|
||||||
id="g3969">
|
id="g3969">
|
||||||
<path
|
<path
|
||||||
|
@ -109,7 +118,7 @@
|
||||||
sodipodi:cy="187.36218"
|
sodipodi:cy="187.36218"
|
||||||
sodipodi:rx="35"
|
sodipodi:rx="35"
|
||||||
sodipodi:ry="35"
|
sodipodi:ry="35"
|
||||||
d="m 105,187.36218 c 0,19.32997 -15.670034,35 -35,35 -19.329966,0 -35,-15.67003 -35,-35 0,-19.32996 15.670034,-35 35,-35 19.329966,0 35,15.67004 35,35 z"
|
d="m 105,187.36218 a 35,35 0 0 1 -35,35 35,35 0 0 1 -35,-35 35,35 0 0 1 35,-35 35,35 0 0 1 35,35 z"
|
||||||
transform="translate(5.3571428,58.571429)" />
|
transform="translate(5.3571428,58.571429)" />
|
||||||
<g
|
<g
|
||||||
id="g3961">
|
id="g3961">
|
||||||
|
@ -191,6 +200,18 @@
|
||||||
d="m 440,292.36218 65,95 70,-95"
|
d="m 440,292.36218 65,95 70,-95"
|
||||||
id="path4025"
|
id="path4025"
|
||||||
inkscape:connector-curvature="0" />
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.80700541;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 104.66045,597.62168 200.67929,0 -22.85304,-57.73976 -152.74134,0 z"
|
||||||
|
id="path4169"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<rect
|
||||||
|
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:3.4000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||||
|
id="rect4171"
|
||||||
|
width="50"
|
||||||
|
height="75"
|
||||||
|
x="180"
|
||||||
|
y="492.36221" />
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 11 KiB |
|
@ -4,10 +4,13 @@
|
||||||
#include "NoiseState.h"
|
#include "NoiseState.h"
|
||||||
#include "Color.h"
|
#include "Color.h"
|
||||||
#include "SurfaceMaterial.h"
|
#include "SurfaceMaterial.h"
|
||||||
|
#include "FloatNode.h"
|
||||||
|
|
||||||
WaterDefinition::WaterDefinition(DefinitionNode* parent):
|
WaterDefinition::WaterDefinition(DefinitionNode* parent):
|
||||||
DefinitionNode(parent, "water", "water")
|
DefinitionNode(parent, "water", "water")
|
||||||
{
|
{
|
||||||
|
reflection = new FloatNode(this, "reflection");
|
||||||
|
|
||||||
material = new SurfaceMaterial;
|
material = new SurfaceMaterial;
|
||||||
depth_color = new Color;
|
depth_color = new Color;
|
||||||
foam_material = new SurfaceMaterial;
|
foam_material = new SurfaceMaterial;
|
||||||
|
@ -15,7 +18,6 @@ WaterDefinition::WaterDefinition(DefinitionNode* parent):
|
||||||
|
|
||||||
transparency_depth = 0.0;
|
transparency_depth = 0.0;
|
||||||
transparency = 0.0;
|
transparency = 0.0;
|
||||||
reflection = 0.0;
|
|
||||||
lighting_depth = 0.0;
|
lighting_depth = 0.0;
|
||||||
scaling = 1.0;
|
scaling = 1.0;
|
||||||
waves_height = 0.0;
|
waves_height = 0.0;
|
||||||
|
@ -40,7 +42,6 @@ void WaterDefinition::save(PackStream* stream) const
|
||||||
depth_color->save(stream);
|
depth_color->save(stream);
|
||||||
stream->write(&transparency_depth);
|
stream->write(&transparency_depth);
|
||||||
stream->write(&transparency);
|
stream->write(&transparency);
|
||||||
stream->write(&reflection);
|
|
||||||
stream->write(&lighting_depth);
|
stream->write(&lighting_depth);
|
||||||
|
|
||||||
stream->write(&scaling);
|
stream->write(&scaling);
|
||||||
|
@ -62,7 +63,6 @@ void WaterDefinition::load(PackStream* stream)
|
||||||
depth_color->load(stream);
|
depth_color->load(stream);
|
||||||
stream->read(&transparency_depth);
|
stream->read(&transparency_depth);
|
||||||
stream->read(&transparency);
|
stream->read(&transparency);
|
||||||
stream->read(&reflection);
|
|
||||||
stream->read(&lighting_depth);
|
stream->read(&lighting_depth);
|
||||||
|
|
||||||
stream->read(&scaling);
|
stream->read(&scaling);
|
||||||
|
@ -87,7 +87,6 @@ void WaterDefinition::copy(DefinitionNode* _destination) const
|
||||||
*destination->depth_color = *depth_color;
|
*destination->depth_color = *depth_color;
|
||||||
destination->transparency_depth = transparency_depth;
|
destination->transparency_depth = transparency_depth;
|
||||||
destination->transparency = transparency;
|
destination->transparency = transparency;
|
||||||
destination->reflection = reflection;
|
|
||||||
destination->lighting_depth = lighting_depth;
|
destination->lighting_depth = lighting_depth;
|
||||||
destination->scaling = scaling;
|
destination->scaling = scaling;
|
||||||
destination->waves_height = waves_height;
|
destination->waves_height = waves_height;
|
||||||
|
@ -113,7 +112,7 @@ void WaterDefinition::applyPreset(WaterPreset preset)
|
||||||
if (preset == WATER_PRESET_LAKE)
|
if (preset == WATER_PRESET_LAKE)
|
||||||
{
|
{
|
||||||
transparency = 0.5;
|
transparency = 0.5;
|
||||||
reflection = 0.2;
|
reflection->setValue(0.2);
|
||||||
transparency_depth = 4.0;
|
transparency_depth = 4.0;
|
||||||
material->setColor(0.08, 0.15, 0.2, 1.0);
|
material->setColor(0.08, 0.15, 0.2, 1.0);
|
||||||
depth_color->r = 0.0;
|
depth_color->r = 0.0;
|
||||||
|
@ -129,7 +128,7 @@ void WaterDefinition::applyPreset(WaterPreset preset)
|
||||||
else if (preset == WATER_PRESET_SEA)
|
else if (preset == WATER_PRESET_SEA)
|
||||||
{
|
{
|
||||||
transparency = 0.3;
|
transparency = 0.3;
|
||||||
reflection = 0.07;
|
reflection->setValue(0.07);
|
||||||
transparency_depth = 3.0;
|
transparency_depth = 3.0;
|
||||||
material->setColor(0.05, 0.18, 0.2, 1.0);
|
material->setColor(0.05, 0.18, 0.2, 1.0);
|
||||||
depth_color->r = 0.0;
|
depth_color->r = 0.0;
|
||||||
|
|
|
@ -20,6 +20,8 @@ public:
|
||||||
virtual void copy(DefinitionNode* destination) const override;
|
virtual void copy(DefinitionNode* destination) const override;
|
||||||
virtual void validate() override;
|
virtual void validate() override;
|
||||||
|
|
||||||
|
inline FloatNode *propReflection() const {return reflection;}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -30,7 +32,6 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
double transparency;
|
double transparency;
|
||||||
double reflection;
|
|
||||||
SurfaceMaterial* material;
|
SurfaceMaterial* material;
|
||||||
Color* depth_color;
|
Color* depth_color;
|
||||||
double transparency_depth;
|
double transparency_depth;
|
||||||
|
@ -45,6 +46,9 @@ public:
|
||||||
SurfaceMaterial* foam_material;
|
SurfaceMaterial* foam_material;
|
||||||
|
|
||||||
NoiseState* noise_state;
|
NoiseState* noise_state;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FloatNode *reflection;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "MainModelerWindow.h"
|
#include "MainModelerWindow.h"
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
#include "TerrainDefinition.h"
|
#include "TerrainDefinition.h"
|
||||||
|
#include "WaterDefinition.h"
|
||||||
#include "FloatPropertyBind.h"
|
#include "FloatPropertyBind.h"
|
||||||
#include "OpenGLRenderer.h"
|
#include "OpenGLRenderer.h"
|
||||||
#include "OpenGLWater.h"
|
#include "OpenGLWater.h"
|
||||||
|
@ -17,11 +18,13 @@ WaterModeler::WaterModeler(MainModelerWindow *ui):
|
||||||
}
|
}
|
||||||
|
|
||||||
prop_water_height = new FloatPropertyBind(ui, "water_height", "value", ui->getScenery()->getTerrain()->propWaterHeight());
|
prop_water_height = new FloatPropertyBind(ui, "water_height", "value", ui->getScenery()->getTerrain()->propWaterHeight());
|
||||||
|
prop_water_reflexion = new FloatPropertyBind(ui, "water_reflection", "value", ui->getScenery()->getWater()->propReflection());
|
||||||
}
|
}
|
||||||
|
|
||||||
WaterModeler::~WaterModeler()
|
WaterModeler::~WaterModeler()
|
||||||
{
|
{
|
||||||
delete prop_water_height;
|
delete prop_water_height;
|
||||||
|
delete prop_water_reflexion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterModeler::enableRendering(bool enable)
|
void WaterModeler::enableRendering(bool enable)
|
||||||
|
|
|
@ -21,6 +21,7 @@ public slots:
|
||||||
private:
|
private:
|
||||||
MainModelerWindow *ui;
|
MainModelerWindow *ui;
|
||||||
FloatPropertyBind *prop_water_height;
|
FloatPropertyBind *prop_water_height;
|
||||||
|
FloatPropertyBind *prop_water_reflexion;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,13 @@ BaseSection {
|
||||||
picture: "images/icon_water_level.png"
|
picture: "images/icon_water_level.png"
|
||||||
hovertext: qsTr("Change the water altitude")
|
hovertext: qsTr("Change the water altitude")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ToolbarButton {
|
||||||
|
id: tool_water_reflection
|
||||||
|
checked: false
|
||||||
|
picture: "images/icon_water_reflection.png"
|
||||||
|
hovertext: qsTr("Reflection of the water surface")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PanelSimpleFloat {
|
PanelSimpleFloat {
|
||||||
|
@ -24,6 +31,13 @@ BaseSection {
|
||||||
objectName: "water_height"
|
objectName: "water_height"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PanelSimpleFloat {
|
||||||
|
id: panel_water_reflection
|
||||||
|
enabled: false
|
||||||
|
anchors.left: toolbar.right
|
||||||
|
objectName: "water_reflection"
|
||||||
|
}
|
||||||
|
|
||||||
states: [
|
states: [
|
||||||
State {
|
State {
|
||||||
name: "WaterHeight"
|
name: "WaterHeight"
|
||||||
|
@ -32,6 +46,14 @@ BaseSection {
|
||||||
target: panel_water_level
|
target: panel_water_level
|
||||||
enabled: true
|
enabled: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "WaterReflection"
|
||||||
|
when: tool_water_reflection.checked
|
||||||
|
PropertyChanges {
|
||||||
|
target: panel_water_reflection
|
||||||
|
enabled: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,5 +43,6 @@
|
||||||
<file>BaseSection.qml</file>
|
<file>BaseSection.qml</file>
|
||||||
<file>AtmosphereSection.qml</file>
|
<file>AtmosphereSection.qml</file>
|
||||||
<file>PanelSimpleFloat.qml</file>
|
<file>PanelSimpleFloat.qml</file>
|
||||||
|
<file>images/icon_water_reflection.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 646 B |
|
@ -156,7 +156,7 @@ void OpenGLRenderer::paint()
|
||||||
}
|
}
|
||||||
|
|
||||||
int error_code;
|
int error_code;
|
||||||
while ((error_code = glGetError()) != GL_NO_ERROR)
|
while ((error_code = functions->glGetError()) != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
Logs::warning() << "[OpenGL] ERROR : " << error_code << std::endl;
|
Logs::warning() << "[OpenGL] ERROR : " << error_code << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ void OpenGLWater::initialize()
|
||||||
|
|
||||||
// Watch for definition changes
|
// Watch for definition changes
|
||||||
renderer->getScenery()->getTerrain()->propWaterHeight()->addWatcher(this, true);
|
renderer->getScenery()->getTerrain()->propWaterHeight()->addWatcher(this, true);
|
||||||
|
renderer->getScenery()->getWater()->propReflection()->addWatcher(this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLWater::update()
|
void OpenGLWater::update()
|
||||||
|
@ -48,9 +49,6 @@ void OpenGLWater::update()
|
||||||
Color water_color = *renderer->getScenery()->getWater()->material->base;
|
Color water_color = *renderer->getScenery()->getWater()->material->base;
|
||||||
renderer->getSharedState()->set("waterColor", water_color);
|
renderer->getSharedState()->set("waterColor", water_color);
|
||||||
|
|
||||||
double water_reflection = renderer->getScenery()->getWater()->reflection;
|
|
||||||
renderer->getSharedState()->set("waterReflection", water_reflection);
|
|
||||||
|
|
||||||
renderer->getSharedState()->set("simplexSampler", NoiseFunctionSimplex::getNormalTexture(), true, true);
|
renderer->getSharedState()->set("simplexSampler", NoiseFunctionSimplex::getNormalTexture(), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +73,10 @@ void OpenGLWater::nodeChanged(const DefinitionNode *node, const DefinitionDiff *
|
||||||
{
|
{
|
||||||
renderer->getSharedState()->set("waterOffset", renderer->getScenery()->getTerrain()->getWaterOffset());
|
renderer->getSharedState()->set("waterOffset", renderer->getScenery()->getTerrain()->getWaterOffset());
|
||||||
}
|
}
|
||||||
|
else if (node->getPath() == "/water/reflection")
|
||||||
|
{
|
||||||
|
renderer->getSharedState()->set("waterReflection", renderer->getScenery()->getWater()->propReflection()->getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLWater::setEnabled(bool enabled)
|
void OpenGLWater::setEnabled(bool enabled)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
#include "SurfaceMaterial.h"
|
#include "SurfaceMaterial.h"
|
||||||
#include "NoiseFunctionSimplex.h"
|
#include "NoiseFunctionSimplex.h"
|
||||||
|
#include "FloatNode.h"
|
||||||
|
|
||||||
WaterRenderer::WaterRenderer(SoftwareRenderer* parent):
|
WaterRenderer::WaterRenderer(SoftwareRenderer* parent):
|
||||||
parent(parent)
|
parent(parent)
|
||||||
|
@ -172,6 +173,7 @@ WaterRenderer::WaterResult WaterRenderer::getResult(double x, double z)
|
||||||
Vector3 location, normal, look_direction;
|
Vector3 location, normal, look_direction;
|
||||||
Color color, foam;
|
Color color, foam;
|
||||||
double detail, depth;
|
double detail, depth;
|
||||||
|
double reflection = definition->propReflection()->getValue();
|
||||||
|
|
||||||
location.x = x;
|
location.x = x;
|
||||||
location.y = _getHeight(noise, x, z);
|
location.y = _getHeight(noise, x, z);
|
||||||
|
@ -188,7 +190,7 @@ WaterRenderer::WaterResult WaterRenderer::getResult(double x, double z)
|
||||||
look_direction = location.sub(parent->getCameraLocation(location)).normalize();
|
look_direction = location.sub(parent->getCameraLocation(location)).normalize();
|
||||||
|
|
||||||
/* Reflection */
|
/* Reflection */
|
||||||
if (definition->reflection == 0.0)
|
if (reflection == 0.0)
|
||||||
{
|
{
|
||||||
result.reflected = COLOR_BLACK;
|
result.reflected = COLOR_BLACK;
|
||||||
}
|
}
|
||||||
|
@ -225,9 +227,9 @@ WaterRenderer::WaterResult WaterRenderer::getResult(double x, double z)
|
||||||
/* Lighting from environment */
|
/* Lighting from environment */
|
||||||
color = parent->applyLightingToSurface(location, normal, *definition->material);
|
color = parent->applyLightingToSurface(location, normal, *definition->material);
|
||||||
|
|
||||||
color.r += result.reflected.r * definition->reflection + result.refracted.r * definition->transparency;
|
color.r += result.reflected.r * reflection + result.refracted.r * definition->transparency;
|
||||||
color.g += result.reflected.g * definition->reflection + result.refracted.g * definition->transparency;
|
color.g += result.reflected.g * reflection + result.refracted.g * definition->transparency;
|
||||||
color.b += result.reflected.b * definition->reflection + result.refracted.b * definition->transparency;
|
color.b += result.reflected.b * reflection + result.refracted.b * definition->transparency;
|
||||||
|
|
||||||
/* Merge with foam */
|
/* Merge with foam */
|
||||||
foam = _getFoamMask(parent, definition, noise, location, normal, detail);
|
foam = _getFoamMask(parent, definition, noise, location, normal, detail);
|
||||||
|
|
Loading…
Reference in a new issue