mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Add an update method to the ProjectionComponent that takes care of Shader rebuildin
This commit is contained in:
@@ -31,6 +31,8 @@ function postInitialization()
|
||||
openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.55)
|
||||
openspace.setPropertyValue("MilkyWay.renderable.segments", 50)
|
||||
|
||||
openspace.setPropertyValue('67P.renderable.performShading', false);
|
||||
|
||||
openspace.printInfo("Done setting default values")
|
||||
end
|
||||
|
||||
|
||||
@@ -199,11 +199,15 @@ void RenderableModelProjection::render(const RenderData& data) {
|
||||
}
|
||||
|
||||
void RenderableModelProjection::update(const UpdateData& data) {
|
||||
if (_programObject->isDirty())
|
||||
if (_programObject->isDirty()) {
|
||||
_programObject->rebuildFromFile();
|
||||
}
|
||||
|
||||
if (_fboProgramObject->isDirty())
|
||||
if (_fboProgramObject->isDirty()) {
|
||||
_fboProgramObject->rebuildFromFile();
|
||||
}
|
||||
|
||||
_projectionComponent.update();
|
||||
|
||||
_time = data.time;
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
bool isReady() const override;
|
||||
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
virtual void update(const UpdateData& data) final override;
|
||||
|
||||
ghoul::opengl::Texture& baseTexture() const;
|
||||
|
||||
|
||||
@@ -368,6 +368,8 @@ void RenderablePlanetProjection::update(const UpdateData& data) {
|
||||
_programObject->rebuildFromFile();
|
||||
}
|
||||
|
||||
_projectionComponent.update();
|
||||
|
||||
_time = Time::ref().currentTime();
|
||||
_capture = false;
|
||||
|
||||
|
||||
@@ -186,9 +186,9 @@ bool ProjectionComponent::initializeProjectionSettings(const Dictionary& diction
|
||||
|
||||
_potentialTargets.resize(potentialTargets.size());
|
||||
for (int i = 0; i < potentialTargets.size(); ++i) {
|
||||
std::string target;
|
||||
potentialTargets.getValue(std::to_string(i + 1), target);
|
||||
_potentialTargets[i] = target;
|
||||
std::string target;
|
||||
potentialTargets.getValue(std::to_string(i + 1), target);
|
||||
_potentialTargets[i] = target;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,13 +267,6 @@ bool ProjectionComponent::initializeParser(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
|
||||
void ProjectionComponent::imageProjectBegin() {
|
||||
if (_needsTextureMapDilation) {
|
||||
if (_dilation.program->isDirty()) {
|
||||
_dilation.program->rebuildFromFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// keep handle to the current bound FBO
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO);
|
||||
|
||||
@@ -321,6 +314,14 @@ void ProjectionComponent::imageProjectEnd() {
|
||||
glViewport(_viewport[0], _viewport[1], _viewport[2], _viewport[3]);
|
||||
}
|
||||
|
||||
void ProjectionComponent::update() {
|
||||
if (_needsTextureMapDilation) {
|
||||
if (_dilation.program->isDirty()) {
|
||||
_dilation.program->rebuildFromFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ProjectionComponent::auxiliaryRendertarget() {
|
||||
bool completeSuccess = true;
|
||||
|
||||
@@ -402,18 +403,24 @@ glm::mat4 ProjectionComponent::computeProjectorMatrix(const glm::vec3 loc, glm::
|
||||
glm::vec3 e3 = glm::normalize(boreSight);
|
||||
glm::vec3 e1 = glm::normalize(glm::cross(uptmp, e3));
|
||||
glm::vec3 e2 = glm::normalize(glm::cross(e3, e1));
|
||||
glm::mat4 projViewMatrix = glm::mat4(e1.x, e2.x, e3.x, 0.f,
|
||||
e1.y, e2.y, e3.y, 0.f,
|
||||
e1.z, e2.z, e3.z, 0.f,
|
||||
-glm::dot(e1, loc), -glm::dot(e2, loc), -glm::dot(e3, loc), 1.f);
|
||||
glm::mat4 projViewMatrix = glm::mat4(
|
||||
e1.x, e2.x, e3.x, 0.f,
|
||||
e1.y, e2.y, e3.y, 0.f,
|
||||
e1.z, e2.z, e3.z, 0.f,
|
||||
-glm::dot(e1, loc), -glm::dot(e2, loc), -glm::dot(e3, loc), 1.f
|
||||
);
|
||||
// create perspective projection matrix
|
||||
glm::mat4 projProjectionMatrix = glm::perspective(glm::radians(fieldOfViewY), aspectRatio, nearPlane, farPlane);
|
||||
glm::mat4 projProjectionMatrix = glm::perspective(
|
||||
glm::radians(fieldOfViewY), aspectRatio, nearPlane, farPlane
|
||||
);
|
||||
// bias matrix
|
||||
glm::mat4 projNormalizationMatrix = glm::mat4(0.5f, 0, 0, 0,
|
||||
0, 0.5f, 0, 0,
|
||||
0, 0, 0.5f, 0,
|
||||
0.5f, 0.5f, 0.5f, 1);
|
||||
return projNormalizationMatrix*projProjectionMatrix*projViewMatrix;
|
||||
glm::mat4 projNormalizationMatrix = glm::mat4(
|
||||
0.5f, 0.f, 0.f, 0.f,
|
||||
0.f, 0.5f, 0.f, 0.f,
|
||||
0.f, 0.f, 0.5f, 0.f,
|
||||
0.5f, 0.5f, 0.5f, 1.f
|
||||
);
|
||||
return projNormalizationMatrix * projProjectionMatrix * projViewMatrix;
|
||||
}
|
||||
|
||||
bool ProjectionComponent::doesPerformProjection() const {
|
||||
|
||||
@@ -57,6 +57,8 @@ public:
|
||||
void imageProjectBegin();
|
||||
void imageProjectEnd();
|
||||
|
||||
void update();
|
||||
|
||||
bool generateProjectionLayerTexture();
|
||||
bool auxiliaryRendertarget();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user