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;
|
||||
}
|
||||
|
||||
// renderer = new SoftwareCanvasRenderer(scenery);
|
||||
auto raytracing = window->findQmlObject("tool_render_raytracing");
|
||||
if (raytracing->property("checked").toBool()) {
|
||||
renderer = new SoftwareRayRenderer(scenery);
|
||||
} else {
|
||||
renderer = new SoftwareCanvasRenderer(scenery);
|
||||
}
|
||||
renderer->setConfig(config);
|
||||
|
||||
destination->setCanvas(renderer->getCanvas());
|
||||
|
|
|
@ -112,6 +112,13 @@ OpenGLView {
|
|||
hovertext: qsTr("Show last rendered image")
|
||||
shortcut: "F6"
|
||||
}
|
||||
|
||||
ToolbarButton {
|
||||
id: tool_render_raytracing
|
||||
toggle: true
|
||||
objectName: "tool_render_raytracing"
|
||||
hovertext: qsTr("Use raytracing instead of rasterization")
|
||||
}
|
||||
}
|
||||
|
||||
BaseSecondaryToolbar {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "SkyIntersector.h"
|
||||
#include "TerrainIntersector.h"
|
||||
#include "Vector3.h"
|
||||
#include "WaterIntersector.h"
|
||||
|
||||
class SoftwareRayRenderer::pimpl {
|
||||
public:
|
||||
|
@ -30,6 +31,7 @@ void SoftwareRayRenderer::registerStandardIntersectors() {
|
|||
|
||||
impl->manager.registerIntersector(make_shared<SkyIntersector>(getAtmosphereRenderer()));
|
||||
impl->manager.registerIntersector(make_shared<TerrainIntersector>(getTerrainRenderer()));
|
||||
impl->manager.registerIntersector(make_shared<WaterIntersector>(getWaterRenderer()));
|
||||
}
|
||||
|
||||
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 RayIntersector;
|
||||
class SkyIntersector;
|
||||
class WaterIntersector;
|
||||
|
||||
class NightSky;
|
||||
class MoonRenderer;
|
||||
|
|
Loading…
Reference in a new issue