mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-02 01:30:34 -06:00
use lightsource from model specification instead of (hardcoded) sun
This commit is contained in:
@@ -96,6 +96,11 @@ float SceneGraphLightSource::intensity() const {
|
||||
return _intensity;
|
||||
}
|
||||
|
||||
glm::dvec3 SceneGraphLightSource::positionWorldSpace() const
|
||||
{
|
||||
return _sceneGraphNode->modelTransform() * glm::dvec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
glm::vec3 SceneGraphLightSource::directionViewSpace(const RenderData& renderData) const {
|
||||
if (!_sceneGraphNode) {
|
||||
return glm::vec3(0.f);
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
bool initialize() override;
|
||||
glm::vec3 directionViewSpace(const RenderData& renderData) const override;
|
||||
float intensity() const override;
|
||||
glm::dvec3 positionWorldSpace() const;
|
||||
|
||||
private:
|
||||
properties::FloatProperty _intensity;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <modules/base/rendering/renderablemodel.h>
|
||||
|
||||
#include <modules/base/basemodule.h>
|
||||
#include <modules/base/lightsource/scenegraphlightsource.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
@@ -1202,7 +1203,11 @@ const bool RenderableModel::isCastingShadow() const {
|
||||
return _castShadow;
|
||||
}
|
||||
|
||||
RenderableModel::DepthMapData RenderableModel::renderDepthMap(const glm::dvec3 light_position) const {
|
||||
RenderableModel::DepthMapData RenderableModel::renderDepthMap() const {
|
||||
|
||||
const openspace::SceneGraphLightSource* light =
|
||||
dynamic_cast<const openspace::SceneGraphLightSource*>(_lightSources.front().get());
|
||||
|
||||
GLint prevProg;
|
||||
glGetIntegerv(GL_CURRENT_PROGRAM, &prevProg);
|
||||
|
||||
@@ -1223,7 +1228,7 @@ RenderableModel::DepthMapData RenderableModel::renderDepthMap(const glm::dvec3 l
|
||||
|
||||
// View
|
||||
glm::dvec3 center = this->parent()->worldPosition();
|
||||
glm::dvec3 light_dir = glm::normalize(center - light_position);
|
||||
glm::dvec3 light_dir = glm::normalize(center - light->positionWorldSpace());
|
||||
glm::dvec3 right = glm::normalize(glm::cross(glm::dvec3(0, 1, 0), -light_dir));
|
||||
glm::dvec3 eye = center + light_dir * size;
|
||||
glm::dvec3 up = glm::cross(right, light_dir);
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
const bool isCastingShadow() const;
|
||||
DepthMapData renderDepthMap(const glm::dvec3 light_position) const;
|
||||
DepthMapData renderDepthMap() const;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
|
||||
@@ -1322,7 +1322,7 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&,
|
||||
std::vector<const RenderableModel*> shadowers = shadowingChildren(this->parent());
|
||||
std::vector<RenderableModel::DepthMapData> depthMapData;
|
||||
for (const RenderableModel* model : shadowers) {
|
||||
depthMapData.push_back(model->renderDepthMap(sun->worldPosition()));
|
||||
depthMapData.push_back(model->renderDepthMap());
|
||||
}
|
||||
|
||||
int globalCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user