Commit 2e0ec1f2 authored by Marc R.'s avatar Marc R.

skew-T: simplified drawing of diagram background

parent 8d8f50d2
......@@ -1990,23 +1990,6 @@ void MSkewTActor::drawDiagramGeometryAndLabels(
GL_FALSE, 0, (const GLvoid *)(0 * sizeof(float)));
float diagramWorldZOffset = 0.f;
float yOffset = 0.f;
if (!config->pressureEqualsWorldPressure)
{
yOffset = 0.1f;
}
// Draw background of diagram.
// ===========================
if (!renderAsWireFrame)
{
skewTShader->bindProgram("DiagramBackground");
skewTShader->setUniformValue("yOffset", (GLfloat)yOffset);
setShaderGeneralVars(sceneView, config);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDrawArrays(GL_POINTS, 0, 1);
}
// Bind shader for diagram geometry.
// =================================
......@@ -2018,15 +2001,28 @@ void MSkewTActor::drawDiagramGeometryAndLabels(
skewTShader->setUniformValue("xy2worldMatrix",
computeXY2WorldSpaceTransformationMatrix(sceneView));
// Draw diagram frame.
// ===================
// Draw diagram background and frame.
// ==================================
// The first four vertices of the frame, drawn as a triangle strip,
// represent the diagram background.
skewTShader->setUniformValue("colour", QVector4D(1.f, 1.f, 1.f, 1.f));
skewTShader->setUniformValue("depthOffset", 0.001f); // draw in background
glLineWidth(1);
glPolygonMode(GL_FRONT_AND_BACK, renderAsWireFrame ? GL_LINE : GL_FILL);
glDrawArrays(GL_TRIANGLE_STRIP,
config->vertexArrayDrawRanges.frame.startIndex, 4);
// Render the frame as thick lines.
glLineWidth(3);
skewTShader->setUniformValue("colour", diagramConfiguration.diagramColor);
skewTShader->setUniformValue("depthOffset", 0.f);
glDrawArrays(GL_LINES,
config->vertexArrayDrawRanges.frame.startIndex,
config->vertexArrayDrawRanges.frame.indexCount);
glLineWidth(1.f);
glLineWidth(1);
// Draw dry adiabates.
// ===================
......
......@@ -97,6 +97,7 @@ uniform float actTemperature, actPressure;
uniform float humidityVal, temperatureVal;
uniform vec4 humidityColour, temperatureColour;
uniform float layer;
uniform float depthOffset;
uniform int ensemble;
uniform int numberOfLevels;
uniform int numberOfLats;
......@@ -522,12 +523,12 @@ shader VSDiagramContent(in vec2 vertex : 0, out vec2 diagramXY)
{
// Map the diagram's (x,y) coordinates to full screen clip space.
vec2 vertexClipSpace = mapDiagramXYToClipSpace(diagramXY);
gl_Position = vec4(vertexClipSpace.x, vertexClipSpace.y, layer, 1.);
gl_Position = vec4(vertexClipSpace.x, vertexClipSpace.y, depthOffset, 1.);
}
else
{
// Map the diagram's (x,y) coordinates to world space...
vec4 vertexWorldSpace = vec4(diagramXY.x, 0., diagramXY.y, 1.);
vec4 vertexWorldSpace = vec4(diagramXY.x, depthOffset, diagramXY.y, 1.);
vertexWorldSpace = xy2worldMatrix * vertexWorldSpace;
// ...and map world space to view space.
gl_Position = mvpMatrix * vertexWorldSpace;
......@@ -756,70 +757,6 @@ shader GSTubes(in vec2 worldPos[])
}
shader GSBackground(in vec4 worldPos[])
{
if (fullscreen)
{
gl_Position = vec4(-1.0, -1.0, 0, 1);
EmitVertex();
gl_Position = vec4(-1.0, 1.0, 0, 1);
EmitVertex();
gl_Position = vec4(1.0, -1.0, 0, 1);
EmitVertex();
gl_Position = vec4(1.0, 1.0, 0, 1);
EmitVertex();
EndPrimitive();
}
else
{
vec3 CameraRight = vec3(viewMatrix[0][0], viewMatrix[1][0],
viewMatrix[2][0]);
vec3 CameraUp;
if (!uprightOrientation)
{
CameraUp = vec3(viewMatrix[0][1], viewMatrix[1][1],
viewMatrix[2][1]);
}
else
{
CameraUp = vec3(0, 0, 1.0);
}
vec3 CameraFront = vec3(viewMatrix[0][2], viewMatrix[1][2],
viewMatrix[2][2]);
float size = 36;
gl_Position = mvpMatrix
* vec4((CameraRight * size * (area.right - 0.05)
+ CameraUp * size * area.bottom)
+ vec3(position.x, position.y, 0.)
- CameraFront * layer, 1.);
EmitVertex();
gl_Position = mvpMatrix
* vec4((CameraRight * size * (area.right - 0.05)
+ CameraUp * size * area.top)
+ vec3(position.x, position.y, 0.)
- CameraFront * layer, 1.);
EmitVertex();
gl_Position = mvpMatrix * vec4((CameraUp * size * area.bottom)
+ vec3(position.x, position.y, 0.), 1.);
EmitVertex();
gl_Position = mvpMatrix * vec4((CameraUp * size * area.top)
+ vec3(position.x, position.y, 0.), 1.);
EmitVertex();
EndPrimitive();
}
}
shader GSMeasurementPoint(in vec4 worldPos[])
{
// getting camera up vector
......@@ -1007,13 +944,6 @@ shader FSEmpty()
*** PROGRAMS
*****************************************************************************/
program DiagramBackground
{
vs(400)=VSWorld();
gs(400)=GSBackground() : in(points), out(triangle_strip, max_vertices = 4);
fs(400)=FSColourWhite();
};
program DiagramVerticesWithoutAreaCheck
{
vs(400)=VS2DVertexYInPressure();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment