mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-25 06:19:02 -06:00
Tentative fix for billbords alingment problems.
This commit is contained in:
Submodule ext/ghoul updated: 4dce717aac...a6244a16f9
@@ -133,9 +133,11 @@ public:
|
||||
class SgctInternal {
|
||||
friend class Camera;
|
||||
public:
|
||||
void setSceneMatrix(glm::mat4 sceneMatrix);
|
||||
void setViewMatrix(glm::mat4 viewMatrix);
|
||||
void setProjectionMatrix(glm::mat4 projectionMatrix);
|
||||
|
||||
const glm::mat4& sceneMatrix() const;
|
||||
const glm::mat4& viewMatrix() const;
|
||||
const glm::mat4& projectionMatrix() const;
|
||||
const glm::mat4& viewProjectionMatrix() const;
|
||||
@@ -148,6 +150,7 @@ public:
|
||||
{}
|
||||
|
||||
// State
|
||||
glm::mat4 _sceneMatrix;
|
||||
glm::mat4 _viewMatrix;
|
||||
glm::mat4 _projectionMatrix;
|
||||
|
||||
|
||||
@@ -384,7 +384,7 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
|
||||
_renderOption.addOption(1, "Camera Position Normal");
|
||||
_renderOption.addOption(2, "Screen center Position Normal");
|
||||
addProperty(_renderOption);
|
||||
_renderOption.set(1);
|
||||
//_renderOption.set(1);
|
||||
|
||||
if (dictionary.hasKey(keyUnit)) {
|
||||
std::string unit = dictionary.value<std::string>(keyUnit);
|
||||
@@ -606,7 +606,7 @@ void RenderableBillboardsCloud::deinitialize() {
|
||||
}
|
||||
|
||||
void RenderableBillboardsCloud::renderBillboards(const RenderData& data, const glm::dmat4& modelViewMatrix,
|
||||
const glm::dmat4& projectionMatrix, const glm::vec3& orthoRight, const glm::vec3& orthoUp,
|
||||
const glm::dmat4& worldToModelTransform, const glm::dvec3& orthoRight, const glm::dvec3& orthoUp,
|
||||
const float fadeInVariable) {
|
||||
glDepthMask(false);
|
||||
|
||||
@@ -635,17 +635,11 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, const g
|
||||
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
|
||||
_program->setIgnoreUniformLocationError(IgnoreError::Yes);
|
||||
|
||||
glm::dmat4 projMatrix = glm::dmat4(data.camera.projectionMatrix());
|
||||
_program->setUniform("screenSize", glm::vec2(OsEng.renderEngine().renderingResolution()));
|
||||
_program->setUniform("projection", projectionMatrix);
|
||||
_program->setUniform("projection", projMatrix);
|
||||
_program->setUniform("modelViewTransform", modelViewMatrix);
|
||||
_program->setUniform("modelViewProjectionTransform", glm::dmat4(projectionMatrix) * modelViewMatrix);
|
||||
|
||||
glm::dmat4 modelMatrix =
|
||||
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation
|
||||
glm::dmat4(data.modelTransform.rotation) * // Spice rotation
|
||||
glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale));
|
||||
glm::dmat4 worldToModelTransform = glm::inverse(modelMatrix);
|
||||
|
||||
_program->setUniform("modelViewProjectionTransform", projMatrix * modelViewMatrix);
|
||||
_program->setUniform("cameraPosition", glm::dvec3(worldToModelTransform *
|
||||
glm::dvec4(data.camera.positionVec3(), 1.0)));
|
||||
_program->setUniform("cameraLookUp", glm::dvec3(worldToModelTransform *
|
||||
@@ -719,7 +713,7 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, const g
|
||||
}
|
||||
|
||||
void RenderableBillboardsCloud::renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix,
|
||||
const glm::vec3& orthoRight, const glm::vec3& orthoUp, const float fadeInVariable) {
|
||||
const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, const float fadeInVariable) {
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
|
||||
_fontRenderer->setFramebufferSize(renderEngine.renderingResolution());
|
||||
@@ -837,20 +831,22 @@ void RenderableBillboardsCloud::render(const RenderData& data, RendererTasks&) {
|
||||
modelViewMatrix;
|
||||
|
||||
glm::vec3 lookup = data.camera.lookUpVectorWorldSpace();
|
||||
|
||||
/*glm::vec3 viewDirection = glm::vec3(glm::dmat4(OsEng.renderEngine().getSGCTModelMatrix()) *
|
||||
glm::dvec4(data.camera.viewDirectionWorldSpace(), 1.0));*/
|
||||
|
||||
glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace();
|
||||
glm::vec3 right = glm::cross(viewDirection, lookup);
|
||||
glm::vec3 up = glm::cross(right, viewDirection);
|
||||
|
||||
|
||||
glm::dmat4 worldToModelTransform = glm::inverse(modelMatrix);
|
||||
glm::vec3 orthoRight = glm::normalize(glm::vec3(worldToModelTransform * glm::vec4(right, 0.0)));
|
||||
glm::vec3 orthoUp = glm::normalize(glm::vec3(worldToModelTransform * glm::vec4(up, 0.0)));
|
||||
glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace();
|
||||
//glm::vec3 right = glm::cross(viewDirection, lookup);
|
||||
//glm::vec3 up = glm::cross(right, viewDirection);
|
||||
//glm::vec3 orthoRight = glm::normalize(glm::vec3(worldToModelTransform * glm::vec4(right, 0.0)));
|
||||
//glm::vec3 orthoUp = glm::normalize(glm::vec3(worldToModelTransform * glm::vec4(up, 0.0)));
|
||||
|
||||
//glm::dmat4 invMVP = glm::inverse(modelViewProjectionMatrix);
|
||||
glm::dmat4 invMVPParts = glm::inverse(modelMatrix) * glm::inverse(data.camera.combinedViewMatrix()) *
|
||||
glm::inverse(glm::dmat4(projectionMatrix));
|
||||
glm::dvec3 orthoRight = glm::dvec3(glm::normalize(glm::dvec3(invMVPParts * glm::dvec4(1.0, 0.0, 0.0, 0.0))));
|
||||
glm::dvec3 orthoUp = glm::dvec3(glm::normalize(glm::dvec3(invMVPParts * glm::dvec4(0.0, 1.0, 0.0, 0.0))));
|
||||
|
||||
if (_hasSpeckFile) {
|
||||
renderBillboards(data, modelViewMatrix, projectionMatrix, orthoRight, orthoUp, fadeInVariable);
|
||||
renderBillboards(data, modelViewMatrix, worldToModelTransform, orthoRight, orthoUp, fadeInVariable);
|
||||
}
|
||||
|
||||
if (_drawLabels && _hasLabel) {
|
||||
|
||||
@@ -89,10 +89,10 @@ private:
|
||||
void loadPolygonGeometryForRendering();
|
||||
void renderPolygonGeometry(GLuint vao);
|
||||
void renderBillboards(const RenderData& data, const glm::dmat4& modelViewMatrix,
|
||||
const glm::dmat4& projectionMatrix, const glm::vec3& orthoRight, const glm::vec3& orthoUp,
|
||||
const glm::dmat4& worldToModelTransform, const glm::dvec3& orthoRight, const glm::dvec3& orthoUp,
|
||||
const float fadeInVariable);
|
||||
void renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix,
|
||||
const glm::vec3& orthoRight, const glm::vec3& orthoUp, const float fadeInVariable);
|
||||
const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, const float fadeInVariable);
|
||||
|
||||
bool loadData();
|
||||
bool readSpeckFile();
|
||||
|
||||
@@ -323,7 +323,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
|
||||
_renderOption.addOption(1, "Camera Position Normal");
|
||||
_renderOption.addOption(2, "Screen center Position Normal");
|
||||
addProperty(_renderOption);
|
||||
_renderOption.set(1);
|
||||
//_renderOption.set(1);
|
||||
|
||||
if (dictionary.hasKey(keyUnit)) {
|
||||
std::string unit = dictionary.value<std::string>(keyUnit);
|
||||
@@ -586,7 +586,7 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&,
|
||||
}
|
||||
|
||||
void RenderablePlanesCloud::renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix,
|
||||
const glm::vec3& orthoRight, const glm::vec3& orthoUp, const float fadeInVariable) {
|
||||
const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, const float fadeInVariable) {
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
|
||||
_fontRenderer->setFramebufferSize(renderEngine.renderingResolution());
|
||||
@@ -688,15 +688,20 @@ void RenderablePlanesCloud::render(const RenderData& data, RendererTasks&) {
|
||||
glm::mat4 projectionMatrix = data.camera.projectionMatrix();
|
||||
glm::dmat4 modelViewProjectionMatrix = glm::dmat4(projectionMatrix) * modelViewMatrix;
|
||||
|
||||
glm::vec3 lookup = data.camera.lookUpVectorWorldSpace();
|
||||
/*glm::vec3 lookup = data.camera.lookUpVectorWorldSpace();
|
||||
glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace();
|
||||
glm::vec3 right = glm::cross(viewDirection, lookup);
|
||||
glm::vec3 up = glm::cross(right, viewDirection);
|
||||
|
||||
glm::dmat4 worldToModelTransform = glm::inverse(modelMatrix);
|
||||
glm::vec3 orthoRight = glm::normalize(glm::vec3(worldToModelTransform * glm::vec4(right, 0.0)));
|
||||
glm::vec3 orthoUp = glm::normalize(glm::vec3(worldToModelTransform * glm::vec4(up, 0.0)));
|
||||
glm::vec3 orthoUp = glm::normalize(glm::vec3(worldToModelTransform * glm::vec4(up, 0.0)));*/
|
||||
|
||||
//glm::dmat4 invMVP = glm::inverse(modelViewProjectionMatrix);
|
||||
glm::dmat4 invMVPParts = glm::inverse(modelMatrix) * glm::inverse(data.camera.combinedViewMatrix()) *
|
||||
glm::inverse(glm::dmat4(projectionMatrix));
|
||||
glm::dvec3 orthoRight = glm::dvec3(glm::normalize(glm::dvec3(invMVPParts * glm::dvec4(1.0, 0.0, 0.0, 0.0))));
|
||||
glm::dvec3 orthoUp = glm::dvec3(glm::normalize(glm::dvec3(invMVPParts * glm::dvec4(0.0, 1.0, 0.0, 0.0))));
|
||||
|
||||
if (_hasSpeckFile) {
|
||||
renderPlanes(data, modelViewMatrix, projectionMatrix, fadeInVariable);
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace openspace {
|
||||
void renderPlanes(const RenderData& data, const glm::dmat4& modelViewMatrix,
|
||||
const glm::dmat4& projectionMatrix, const float fadeInVariable);
|
||||
void renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix,
|
||||
const glm::vec3& orthoRight, const glm::vec3& orthoUp, const float fadeInVarible);
|
||||
const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, const float fadeInVarible);
|
||||
|
||||
bool loadData();
|
||||
bool loadTextures();
|
||||
|
||||
@@ -32,8 +32,8 @@ layout(triangle_strip, max_vertices = 6) out;
|
||||
//uniform dmat4 transformMatrix;
|
||||
uniform dmat4 modelViewProjectionTransform;
|
||||
uniform float scaleFactor;
|
||||
uniform vec3 up;
|
||||
uniform vec3 right;
|
||||
uniform dvec3 up;
|
||||
uniform dvec3 right;
|
||||
uniform dvec3 cameraPosition;
|
||||
uniform dvec3 cameraLookUp;
|
||||
uniform dvec4 centerScreenInWorldPosition;
|
||||
@@ -139,12 +139,13 @@ void main() {
|
||||
// EndPrimitive(); // Second Triangle
|
||||
|
||||
// Testing size:
|
||||
vec4 topLeft = thirdPosition/thirdPosition.w;
|
||||
topLeft = ((topLeft + vec4(1.0)) / vec4(2.0)) * vec4(screenSize.x, screenSize.y, 1.0, 1.0);
|
||||
vec4 topRight = secondPosition/secondPosition.w;
|
||||
topRight = ((topRight + vec4(1.0)) / vec4(2.0)) * vec4(screenSize.x, screenSize.y, 1.0, 1.0);
|
||||
vec4 bottomLeft = initialPosition/initialPosition.w;
|
||||
bottomLeft = ((bottomLeft + vec4(1.0)) / vec4(2.0)) * vec4(screenSize.x, screenSize.y, 1.0, 1.0);
|
||||
|
||||
if ((topLeft.y - bottomLeft.y) > maxBillboardSize) {
|
||||
if (((topRight.y - bottomLeft.y) > maxBillboardSize) ||
|
||||
((topRight.x - bottomLeft.x) > maxBillboardSize)) {
|
||||
return;
|
||||
} else {
|
||||
// Build primitive
|
||||
|
||||
@@ -7,11 +7,12 @@ return {
|
||||
-- occurs in a single window, a fisheye projection, or a dome cluster system
|
||||
|
||||
-- A regular 1280x720 window
|
||||
--SGCTConfig = sgct.config.single{1280, 720, scene={orientation = { yaw = 120, pitch = 15, roll = 0.0 }}},
|
||||
--SGCTConfig = "${CONFIG}/single_two_win.xml",
|
||||
SGCTConfig = sgct.config.single{1280, 720},
|
||||
-- SGCTConfig = sgct.config.single{1280, 720, scene={orientation = { yaw = 120, pitch = 15, roll = 0.0 }}},
|
||||
-- SGCTConfig = "${CONFIG}/single_two_win.xml",
|
||||
|
||||
-- A regular 1920x1080 window
|
||||
SGCTConfig = sgct.config.single{1920, 1080},
|
||||
-- SGCTConfig = sgct.config.single{1920, 1080},
|
||||
|
||||
-- A windowed 1920x1080 fullscreen
|
||||
-- SGCTConfig = sgct.config.single{1920, 1080, border=false, windowPos={0,0}, shared=true, name="WV_OBS_SPOUT1"},
|
||||
@@ -20,7 +21,7 @@ return {
|
||||
--SGCTConfig = sgct.config.fisheye{1024, 1024},
|
||||
|
||||
-- A 4k fisheye rendering in a 1024x1024 window
|
||||
--SGCTConfig = sgct.config.fisheye{1024, 1024, res={4096, 4096}, quality="2k", tilt=27},
|
||||
-- SGCTConfig = sgct.config.fisheye{1024, 1024, res={4096, 4096}, quality="2k", tilt=27},
|
||||
|
||||
-- Streaming OpenSpace via Spout to OBS
|
||||
-- SGCTConfig = sgct.config.single{2560, 1440, shared=true, name="WV_OBS_SPOUT1"},
|
||||
|
||||
@@ -576,6 +576,7 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat
|
||||
}
|
||||
else {
|
||||
_camera->sgctInternal.setViewMatrix(viewMatrix * sceneMatrix);
|
||||
_camera->sgctInternal.setSceneMatrix(sceneMatrix);
|
||||
}
|
||||
_camera->sgctInternal.setProjectionMatrix(projectionMatrix);
|
||||
|
||||
|
||||
@@ -226,10 +226,18 @@ namespace openspace {
|
||||
// SGCT INTERNAL //
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
Camera::SgctInternal::SgctInternal()
|
||||
: _viewMatrix()
|
||||
: _sceneMatrix()
|
||||
, _viewMatrix()
|
||||
, _projectionMatrix()
|
||||
{ }
|
||||
|
||||
void Camera::SgctInternal::setSceneMatrix(glm::mat4 sceneMatrix) {
|
||||
std::lock_guard<std::mutex> _lock(_mutex);
|
||||
|
||||
_sceneMatrix = std::move(sceneMatrix);
|
||||
//_cachedViewProjectionMatrix.isDirty = true;
|
||||
}
|
||||
|
||||
void Camera::SgctInternal::setViewMatrix(glm::mat4 viewMatrix) {
|
||||
std::lock_guard<std::mutex> _lock(_mutex);
|
||||
|
||||
@@ -244,6 +252,10 @@ namespace openspace {
|
||||
_cachedViewProjectionMatrix.isDirty = true;
|
||||
}
|
||||
|
||||
const glm::mat4& Camera::SgctInternal::sceneMatrix() const {
|
||||
return _sceneMatrix;
|
||||
}
|
||||
|
||||
const glm::mat4& Camera::SgctInternal::viewMatrix() const {
|
||||
return _viewMatrix;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user