mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-21 12:29:04 -06:00
Temporary solution for precision problems in spherical grids.
This commit is contained in:
@@ -214,16 +214,22 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
|
||||
const glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() *
|
||||
modelTransform;
|
||||
|
||||
_gridProgram->setUniform("modelViewTransform", glm::mat4(modelViewTransform));
|
||||
_gridProgram->setUniform("projectionTransform", data.camera.projectionMatrix());
|
||||
|
||||
_gridProgram->setUniform("modelViewTransform", modelViewTransform);
|
||||
_gridProgram->setUniform("projectionTransform", glm::dmat4(data.camera.projectionMatrix()));
|
||||
|
||||
_gridProgram->setUniform("gridColor", _gridColor);
|
||||
|
||||
float adjustedLineWidth = 1.f;
|
||||
|
||||
#ifndef __APPLE__
|
||||
adjustedLineWidth = _lineWidth;
|
||||
#endif
|
||||
|
||||
// Saves current state:
|
||||
GLboolean isBlendEnabled = glIsEnabledi(GL_BLEND, 0);
|
||||
GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH);
|
||||
GLfloat currentLineWidth;
|
||||
glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth);
|
||||
GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH);
|
||||
|
||||
GLenum blendEquationRGB, blendEquationAlpha, blendDestAlpha,
|
||||
blendDestRGB, blendSrcAlpha, blendSrcRGB;
|
||||
@@ -235,11 +241,11 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
|
||||
glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB);
|
||||
|
||||
// Changes GL state:
|
||||
glLineWidth(_lineWidth);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glLineWidth(adjustedLineWidth);
|
||||
glEnablei(GL_BLEND, 0);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
|
||||
glBindVertexArray(_vaoID);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
|
||||
glDrawElements(_mode, _isize, GL_UNSIGNED_INT, nullptr);
|
||||
@@ -251,9 +257,11 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
|
||||
glLineWidth(currentLineWidth);
|
||||
glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha);
|
||||
glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha);
|
||||
|
||||
if (!isBlendEnabled) {
|
||||
glDisablei(GL_BLEND, 0);
|
||||
}
|
||||
|
||||
if (!isLineSmoothEnabled) {
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
in float vs_screenSpaceDepth;
|
||||
in vec4 vs_positionViewSpace;
|
||||
flat in double vs_double_depth;
|
||||
|
||||
uniform vec4 gridColor;
|
||||
uniform float opacity;
|
||||
@@ -34,9 +35,15 @@ uniform float opacity;
|
||||
Fragment getFragment() {
|
||||
Fragment frag;
|
||||
frag.color = gridColor;
|
||||
frag.color.a *= opacity;
|
||||
frag.depth = vs_screenSpaceDepth;
|
||||
frag.color.a *= opacity;
|
||||
// JCC: Temp solution for depth precision problems.
|
||||
frag.depth = float(vs_double_depth);
|
||||
//frag.depth = vs_screenSpaceDepth;
|
||||
frag.gPosition = vs_positionViewSpace;
|
||||
frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
// There is no normal here
|
||||
frag.gNormal = vec4(0.0, 0.0, -1.0, 1.0);
|
||||
|
||||
return frag;
|
||||
|
||||
}
|
||||
|
||||
@@ -30,16 +30,19 @@ layout(location = 0) in vec3 in_position;
|
||||
|
||||
out float vs_screenSpaceDepth;
|
||||
out vec4 vs_positionViewSpace;
|
||||
flat out double vs_double_depth;
|
||||
|
||||
uniform mat4 modelViewTransform;
|
||||
uniform mat4 projectionTransform;
|
||||
uniform dmat4 modelViewTransform;
|
||||
uniform dmat4 projectionTransform;
|
||||
|
||||
void main() {
|
||||
vec4 positionViewSpace = modelViewTransform * vec4(in_position, 1.0);
|
||||
vec4 positionClipSpace = projectionTransform * positionViewSpace;
|
||||
vec4 positionScreenSpace = z_normalization(positionClipSpace);
|
||||
vs_screenSpaceDepth = positionScreenSpace.w;
|
||||
vs_positionViewSpace = positionViewSpace;
|
||||
dvec4 positionViewSpace = modelViewTransform * dvec4(in_position, 1.0);
|
||||
dvec4 positionClipSpace = projectionTransform * positionViewSpace;
|
||||
vec4 positionScreenSpace = z_normalization(vec4(positionClipSpace));
|
||||
|
||||
vs_double_depth = positionClipSpace.w;
|
||||
vs_screenSpaceDepth = float(positionClipSpace.w);
|
||||
vs_positionViewSpace = vec4(positionViewSpace);
|
||||
|
||||
gl_Position = positionScreenSpace;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user