some kind of working

This commit is contained in:
Joakim Kilby
2023-07-19 13:31:32 +02:00
parent b2c8bac35a
commit ef82ec49f7
3 changed files with 25 additions and 4 deletions
+10 -1
View File
@@ -25,9 +25,18 @@
#include "fragment.glsl"
uniform vec3 color;
uniform float lineWidth;
uniform float blendFactor;
in vec2 lineCenter;
Fragment getFragment() {
double dist = length(lineCenter - gl_FragCoord.xy);
float alpha = 0.0;
if (dist < lineWidth)
alpha = pow(float((lineWidth - dist) / lineWidth), 15);
Fragment frag;
frag.color = vec4(color, 1);
frag.color = vec4(color, alpha);
return frag;
}
+6 -1
View File
@@ -27,7 +27,12 @@
layout (location = 0) in vec2 in_position;
uniform dmat4 projectionMatrix;
uniform vec2 viewport;
out vec2 lineCenter;
void main() {
gl_Position = vec4(projectionMatrix * vec4(in_position, 0, 1));
vec4 pos = vec4(projectionMatrix * vec4(in_position, 0, 1));
gl_Position = pos;
lineCenter = 0.5 * (pos.xy + vec2(1)) * viewport;
}
@@ -424,10 +424,16 @@ void AsdfTileProvider::update() {
static_cast<GLsizei>(_rendertargetDimensions.y)
);
glClearColor(.2f, .2f, .2f, 0.f);
//glClearColor(.2f, .2f, .2f, 0.f);
glClearColor(.0f, .0f, .0f, 0.f);
glClear(GL_COLOR_BUFFER_BIT);
_program->activate();
_program->setUniform("viewport",
glm::vec2(_rendertargetDimensions.x, _rendertargetDimensions.y));
_program->setUniform("lineWidth", _lineWidth);
const float blend = 2.0;
//_program->setUniform("blendFactor", blend);
_program->setUniform("color", _color);
_program->setUniform("projectionMatrix", projection);
@@ -443,9 +449,10 @@ void AsdfTileProvider::update() {
if (_renderingMode == static_cast<int>(RenderingMode::Lines)) {
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
//glDepthMask(GL_FALSE);
glLineWidth(_lineWidth);
glDrawArrays(GL_LINE_STRIP, 0, points.size());
glDisable(GL_LINE_SMOOTH);
}
else {
glPointSize(_lineWidth);