mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-29 15:29:26 -05:00
Merge branch 'master' into feature/loadingscreen-refactor
# Conflicts: # modules/base/rendering/renderabletrailorbit.h # modules/digitaluniverse/rendering/renderablebillboardscloud.cpp # modules/digitaluniverse/rendering/renderableplanescloud.cpp # modules/digitaluniverse/rendering/renderablepoints.cpp # modules/galaxy/rendering/renderablegalaxy.cpp # modules/galaxy/rendering/renderablegalaxy.h # modules/kameleonvolume/rendering/renderablekameleonvolume.cpp # modules/kameleonvolume/rendering/renderablekameleonvolume.h # modules/spacecraftinstruments/rendering/renderablefov.h # modules/spacecraftinstruments/rendering/renderableplaneprojection.h # modules/toyvolume/rendering/renderabletoyvolume.cpp # modules/toyvolume/rendering/renderabletoyvolume.h # modules/volume/rendering/renderabletimevaryingvolume.cpp # modules/volume/rendering/renderabletimevaryingvolume.h
This commit is contained in:
@@ -36,12 +36,11 @@
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
|
||||
|
||||
namespace {
|
||||
const std::string GlslRaycastPath = "${MODULES}/galaxy/shaders/galaxyraycast.glsl";
|
||||
const std::string GlslBoundsVsPath = "${MODULES}/galaxy/shaders/raycasterbounds.vs";
|
||||
const std::string GlslBoundsFsPath = "${MODULES}/galaxy/shaders/raycasterbounds.fs";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -49,31 +48,31 @@ GalaxyRaycaster::GalaxyRaycaster(ghoul::opengl::Texture& texture)
|
||||
: _boundingBox(glm::vec3(1.0))
|
||||
, _texture(texture)
|
||||
, _textureUnit(nullptr) {}
|
||||
|
||||
|
||||
GalaxyRaycaster::~GalaxyRaycaster() {}
|
||||
|
||||
void GalaxyRaycaster::initialize() {
|
||||
_boundingBox.initialize();
|
||||
}
|
||||
|
||||
|
||||
void GalaxyRaycaster::deinitialize() {
|
||||
}
|
||||
|
||||
|
||||
void GalaxyRaycaster::renderEntryPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) {
|
||||
program.setUniform("modelTransform", _modelTransform);
|
||||
program.setUniform("viewProjection", data.camera.viewProjectionMatrix());
|
||||
program.setUniform("blendMode", static_cast<unsigned int>(1));
|
||||
|
||||
Renderable::setPscUniforms(program, data.camera, data.position);
|
||||
|
||||
|
||||
// Cull back face
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
|
||||
// Render bounding geometry
|
||||
_boundingBox.render();
|
||||
}
|
||||
|
||||
|
||||
void GalaxyRaycaster::renderExitPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) {
|
||||
// Uniforms
|
||||
program.setUniform("modelTransform", _modelTransform);
|
||||
@@ -84,21 +83,21 @@ void GalaxyRaycaster::renderExitPoints(const RenderData& data, ghoul::opengl::Pr
|
||||
// Cull front face
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_FRONT);
|
||||
|
||||
|
||||
// Render bounding geometry
|
||||
_boundingBox.render();
|
||||
|
||||
|
||||
// Restore defaults
|
||||
glCullFace(GL_BACK);
|
||||
}
|
||||
|
||||
|
||||
void GalaxyRaycaster::preRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) {
|
||||
std::string colorUniformName = "color" + std::to_string(data.id);
|
||||
std::string stepSizeUniformName = "maxStepSize" + std::to_string(data.id);
|
||||
std::string galaxyTextureUniformName = "galaxyTexture" + std::to_string(data.id);
|
||||
std::string volumeAspectUniformName = "aspect" + std::to_string(data.id);
|
||||
std::string opacityCoefficientUniformName = "opacityCoefficient" + std::to_string(data.id);
|
||||
|
||||
|
||||
program.setUniform(volumeAspectUniformName, _aspect);
|
||||
program.setUniform(stepSizeUniformName, _stepSize);
|
||||
program.setUniform(opacityCoefficientUniformName, _opacityCoefficient);
|
||||
@@ -107,9 +106,8 @@ void GalaxyRaycaster::preRaycast(const RaycastData& data, ghoul::opengl::Program
|
||||
_textureUnit->activate();
|
||||
_texture.bind();
|
||||
program.setUniform(galaxyTextureUniformName, *_textureUnit);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GalaxyRaycaster::postRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) {
|
||||
_textureUnit = nullptr; // release texture unit.
|
||||
}
|
||||
@@ -119,7 +117,7 @@ bool GalaxyRaycaster::cameraIsInside(const RenderData& data, glm::vec3& localPos
|
||||
glm::vec4 rigWorldPos = glm::vec4(data.camera.position().vec3(), 1.0);
|
||||
//rigWorldPos /= data.camera.scaling().x * pow(10.0, data.camera.scaling().y);
|
||||
//glm::mat4 invSgctMatrix = glm::inverse(data.camera.viewMatrix());
|
||||
|
||||
|
||||
// Camera position in world coordinates.
|
||||
glm::vec4 camWorldPos = rigWorldPos;
|
||||
glm::vec3 objPos = data.position.vec3();
|
||||
@@ -134,7 +132,7 @@ bool GalaxyRaycaster::cameraIsInside(const RenderData& data, glm::vec3& localPos
|
||||
glm::mat4 scaledModelTransform = modelTransform / divisor;
|
||||
|
||||
glm::vec4 modelPos = (glm::inverse(scaledModelTransform) / divisor) * camWorldPos;
|
||||
|
||||
|
||||
localPosition = (glm::vec3(modelPos) + glm::vec3(0.5));
|
||||
return (localPosition.x > 0 && localPosition.y > 0 && localPosition.z > 0 && localPosition.x < 1 && localPosition.y < 1 && localPosition.z < 1);
|
||||
}
|
||||
@@ -142,7 +140,7 @@ bool GalaxyRaycaster::cameraIsInside(const RenderData& data, glm::vec3& localPos
|
||||
std::string GalaxyRaycaster::getBoundsVsPath() const {
|
||||
return GlslBoundsVsPath;
|
||||
}
|
||||
|
||||
|
||||
std::string GalaxyRaycaster::getBoundsFsPath() const {
|
||||
return GlslBoundsFsPath;
|
||||
}
|
||||
@@ -170,9 +168,9 @@ void GalaxyRaycaster::setOpacityCoefficient(float opacityCoefficient) {
|
||||
void GalaxyRaycaster::setTime(double time) {
|
||||
_time = time;
|
||||
}
|
||||
|
||||
|
||||
void GalaxyRaycaster::setStepSize(float stepSize) {
|
||||
_stepSize = stepSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user