orbits rendered proporly

This commit is contained in:
Elon
2019-04-16 17:48:50 -06:00
parent d7d957d584
commit 20fdc00527
5 changed files with 45 additions and 35 deletions

View File

@@ -465,6 +465,9 @@ RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary)
dictionary.value<std::string>(MeanAnomalyAtEpochColumnInfo.identifier);
_epochColumnName =
dictionary.value<std::string>(EpochColumnInfo.identifier);
// fungerar inte
//_appearance.lineColor = glm::vec3(1.f), glm::vec3(0.f), glm::vec3(0.f);
addPropertySubOwner(_appearance);
addProperty(_path);
@@ -626,6 +629,9 @@ void RenderableSatellites::deinitialize() {
}
void RenderableSatellites::initializeGL() {
glGenVertexArrays(1, &_vertexArray);
glGenBuffers(1, &_vertexBuffer);
_programObject = SpaceModule::ProgramObjectManager.request(
ProgramName,
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
@@ -644,25 +650,9 @@ void RenderableSatellites::initializeGL() {
_uniformCache.useLineFade = _programObject->uniformLocation("useLineFade");
_uniformCache.lineFade = _programObject->uniformLocation("lineFade");
glGenVertexArrays(1, &_vertexArray);
glBindVertexArray(_vertexArray);
glGenBuffers(1, &_vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
glBufferData(
GL_ARRAY_BUFFER,
_vertexBufferData.size() * sizeof(TrailVBOLayout),
_vertexBufferData.data(),
GL_STATIC_DRAW
);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), nullptr);
glBindVertexArray(0);
updateBuffers();
setRenderBin(Renderable::RenderBin::Overlay);
glBindVertexArray(0);
}
void RenderableSatellites::deinitializeGL() {
@@ -684,8 +674,8 @@ bool RenderableSatellites::isReady() const {
void RenderableSatellites::update(const UpdateData&) {}
void RenderableSatellites::render(const RenderData& data, RendererTasks&) {
//if (_TLEData.empty())
// return;
if (_TLEData.empty())
return;
_programObject->activate();
_programObject->setUniform(_uniformCache.opacity, _opacity);
@@ -702,10 +692,10 @@ void RenderableSatellites::render(const RenderData& data, RendererTasks&) {
_programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix());
_programObject->setUniform(_uniformCache.color, _appearance.lineColor);
//_programObject->setUniform(_uniformCache.useLineFade, _appearance.useLineFade);
//if (_appearance.useLineFade) {
// _programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade);
//}
_programObject->setUniform(_uniformCache.useLineFade, _appearance.useLineFade);
if (_appearance.useLineFade) {
_programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade);
}
glLineWidth(_appearance.lineWidth);
@@ -766,6 +756,22 @@ void RenderableSatellites::updateBuffers() {
}
++orbitindex;
}
glBindVertexArray(_vertexArray);
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
glBufferData(
GL_ARRAY_BUFFER,
_vertexBufferData.size() * sizeof(TrailVBOLayout),
_vertexBufferData.data(),
GL_STATIC_DRAW
);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), nullptr);
glBindVertexArray(0);
}
}

View File

@@ -29,15 +29,16 @@ uniform vec3 color;
uniform float opacity = 1.0;
in vec4 viewSpacePosition;
in vec3 vs_position;
in vec3 vs_color;
in vec2 vs_texcoord;
in vec4 vs_position;
//in vec3 vs_color;
//in vec2 vs_texcoord;
Fragment getFragment() {
Fragment frag;
frag.color = vec4(color, opacity);
frag.depth = vs_position.w;
frag.gPosition = viewSpacePosition;
frag.gNormal = vec4(1, 1, 1 , 0);
return frag;
}

View File

@@ -24,19 +24,22 @@
#version __CONTEXT__
#include "D:\OpenSpace\shaders\PowerScaling\powerScalingMath.hglsl"
layout (location = 0) in vec4 vertex_data;
uniform dmat4 modelViewTransform;
uniform mat4 projectionTransform;
out vec4 viewSpacePosition;
out vec4 vs_position;
void main() {
dvec4 position = dvec4(vertex_data.xyz, 1.0);
float timeOffset = vertex_data.w;
void main() {
viewSpacePosition = vec4(modelViewTransform * dvec4(vertex_data.xyz, 1));
vs_position = z_normalization( projectionTransform * viewSpacePosition);
gl_Position = vs_position;
viewSpacePosition = vec4(modelViewTransform * position);
gl_Position = projectionTransform * viewSpacePosition;
}

View File

@@ -303,7 +303,7 @@ glm::dvec3 KeplerTranslation::position(const UpdateData& data) const {
};
return _orbitPlaneRotation * p;
}
// !!! is only used in module/space/rendering/renderablesatellites
glm::dvec3 KeplerTranslation::debrisPos(const Time& time) const {
if (_orbitPlaneDirty) {
computeOrbitPlane();

View File

@@ -6,13 +6,13 @@
-- occurs in a single window, a fisheye projection, or a dome cluster system
-- A regular 1280x720 window
-- SGCTConfig = sgct.config.single{}
SGCTConfig = sgct.config.single{}
-- A regular 1920x1080 window
-- 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"}
-- SGCTConfig = sgct.config.single{1920, 1080, border=false, windowPos={0,0}, shared=true, name="WV_OBS_SPOUT1"}
-- A 1k fisheye rendering
-- SGCTConfig = sgct.config.fisheye{1024, 1024}