broken wip
This commit is contained in:
parent
fb16682876
commit
10d2b755e0
6 changed files with 63 additions and 2 deletions
|
@ -99,8 +99,12 @@ void RenderProcess::startRender(Scenery *scenery, const RenderConfig &config) {
|
||||||
delete renderer;
|
delete renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// renderer = new SoftwareCanvasRenderer(scenery);
|
auto raytracing = window->findQmlObject("tool_render_raytracing");
|
||||||
|
if (raytracing->property("checked").toBool()) {
|
||||||
renderer = new SoftwareRayRenderer(scenery);
|
renderer = new SoftwareRayRenderer(scenery);
|
||||||
|
} else {
|
||||||
|
renderer = new SoftwareCanvasRenderer(scenery);
|
||||||
|
}
|
||||||
renderer->setConfig(config);
|
renderer->setConfig(config);
|
||||||
|
|
||||||
destination->setCanvas(renderer->getCanvas());
|
destination->setCanvas(renderer->getCanvas());
|
||||||
|
|
|
@ -112,6 +112,13 @@ OpenGLView {
|
||||||
hovertext: qsTr("Show last rendered image")
|
hovertext: qsTr("Show last rendered image")
|
||||||
shortcut: "F6"
|
shortcut: "F6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ToolbarButton {
|
||||||
|
id: tool_render_raytracing
|
||||||
|
toggle: true
|
||||||
|
objectName: "tool_render_raytracing"
|
||||||
|
hovertext: qsTr("Use raytracing instead of rasterization")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseSecondaryToolbar {
|
BaseSecondaryToolbar {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "SkyIntersector.h"
|
#include "SkyIntersector.h"
|
||||||
#include "TerrainIntersector.h"
|
#include "TerrainIntersector.h"
|
||||||
#include "Vector3.h"
|
#include "Vector3.h"
|
||||||
|
#include "WaterIntersector.h"
|
||||||
|
|
||||||
class SoftwareRayRenderer::pimpl {
|
class SoftwareRayRenderer::pimpl {
|
||||||
public:
|
public:
|
||||||
|
@ -30,6 +31,7 @@ void SoftwareRayRenderer::registerStandardIntersectors() {
|
||||||
|
|
||||||
impl->manager.registerIntersector(make_shared<SkyIntersector>(getAtmosphereRenderer()));
|
impl->manager.registerIntersector(make_shared<SkyIntersector>(getAtmosphereRenderer()));
|
||||||
impl->manager.registerIntersector(make_shared<TerrainIntersector>(getTerrainRenderer()));
|
impl->manager.registerIntersector(make_shared<TerrainIntersector>(getTerrainRenderer()));
|
||||||
|
impl->manager.registerIntersector(make_shared<WaterIntersector>(getWaterRenderer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftwareRayRenderer::renderPortion(CanvasPortion *portion, RenderProgress *progress, bool *interrupt) {
|
void SoftwareRayRenderer::renderPortion(CanvasPortion *portion, RenderProgress *progress, bool *interrupt) {
|
||||||
|
|
22
src/render/software/WaterIntersector.cpp
Normal file
22
src/render/software/WaterIntersector.cpp
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#include "WaterIntersector.h"
|
||||||
|
|
||||||
|
#include "InfinitePlane.h"
|
||||||
|
#include "InfiniteRay.h"
|
||||||
|
#include "WaterRenderer.h"
|
||||||
|
|
||||||
|
WaterIntersector::WaterIntersector(WaterRenderer *renderer): renderer(renderer) {
|
||||||
|
}
|
||||||
|
|
||||||
|
int WaterIntersector::getPriority() const {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WaterIntersector::findIntersection(const Vector3 &eye, const Vector3 &direction, double, Vector3 *out_hit) const {
|
||||||
|
InfinitePlane water(Vector3(0.0, renderer->getHeightInfo().base_height, 0.0), VECTOR_UP);
|
||||||
|
int intersect = water.checkRayIntersection(InfiniteRay(eye, direction), out_hit);
|
||||||
|
return intersect == 1 && direction.dotProduct(out_hit->sub(eye)) > 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Color WaterIntersector::getColorAtHit(const Vector3 &, const Vector3 &location) const {
|
||||||
|
return renderer->getResult(location.x, location.z).final;
|
||||||
|
}
|
25
src/render/software/WaterIntersector.h
Normal file
25
src/render/software/WaterIntersector.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "software_global.h"
|
||||||
|
|
||||||
|
#include "RayIntersector.h"
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace software {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ray intersector with water.
|
||||||
|
*/
|
||||||
|
class SOFTWARESHARED_EXPORT WaterIntersector : public RayIntersector {
|
||||||
|
public:
|
||||||
|
WaterIntersector(WaterRenderer *renderer);
|
||||||
|
virtual int getPriority() const override;
|
||||||
|
virtual bool findIntersection(const Vector3 &eye, const Vector3 &direction, double limit,
|
||||||
|
Vector3 *out_hit) const override;
|
||||||
|
virtual Color getColorAtHit(const Vector3 &eye, const Vector3 &location) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
WaterRenderer *renderer;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,6 +49,7 @@ class RayCastingManager;
|
||||||
class RayCastingResult;
|
class RayCastingResult;
|
||||||
class RayIntersector;
|
class RayIntersector;
|
||||||
class SkyIntersector;
|
class SkyIntersector;
|
||||||
|
class WaterIntersector;
|
||||||
|
|
||||||
class NightSky;
|
class NightSky;
|
||||||
class MoonRenderer;
|
class MoonRenderer;
|
||||||
|
|
Loading…
Reference in a new issue