Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCP point-line duality rendering #1071

Draft
wants to merge 34 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a20c843
WIP dual pcp Rendering
r3sox Jun 13, 2022
0b927c0
prototype, unscaled, unplaced dual pcp
r3sox Jun 13, 2022
6b9f8b8
almost correct scaling and positions (dual)
r3sox Jun 14, 2022
8335ed6
Point and Line dual rendering, WIP
r3sox Jun 27, 2022
9a4a376
WIP true hough
r3sox Jul 7, 2022
5acfd37
some progress on line completeness
r3sox Jul 15, 2022
f14a755
Merge branch 'master' into pcp_point-line-dual-rendering
moritz-h Jul 15, 2022
cb02c9d
fix merge
moritz-h Jul 15, 2022
cce3de7
hesse mode without perfect horizontals
r3sox Aug 4, 2022
3167fb9
Merge branch 'pcp_point-line-dual-rendering' of https://github.com/in…
r3sox Aug 4, 2022
b61aa96
fix merge
moritz-h Aug 4, 2022
6f365bf
format
moritz-h Aug 4, 2022
21eed7f
Merge branch 'master' into pcp_point-line-dual-rendering
moritz-h Aug 4, 2022
5fa918c
Merge branch 'master' into pcp_point-line-dual-rendering
moritz-h Aug 4, 2022
0f74a88
Mode switching
r3sox Sep 1, 2022
ea23c15
Merge branch 'master' into pcp_point-line-dual-rendering
moritz-h Sep 1, 2022
c65ede2
spawn lines blending
r3sox Sep 15, 2022
0f5145d
Merge branch 'master' into pcp_point-line-dual-rendering
moritz-h Sep 29, 2022
22b564b
experimental (unstable) state
r3sox Oct 27, 2022
4d524a0
some light code cleanup
r3sox Oct 27, 2022
1b98c9b
single pass theta-rho selection
r3sox Oct 28, 2022
12d531d
Multi add compute shdaer
r3sox Nov 10, 2022
7391638
Merge branch 'master' into pcp_point-line-dual-rendering
moritz-h Nov 10, 2022
41d11d6
Experimenting with mb-space implementation
invor Nov 15, 2022
a454dfb
Merge branch 'pcp_point-line-dual-rendering' of https://github.com/in…
invor Nov 15, 2022
99b43ec
Fix texture format, restore original shader for dualHough program
invor Nov 16, 2022
43751e1
Update m-b-space shader, add axis-space shader
invor Nov 16, 2022
c1f8e90
Add new render modes for testing/debugging
invor Nov 16, 2022
0e5e943
use fixed point conversion in dualHough draw shader
invor Nov 16, 2022
9ff33f9
Update normalization of axis-space dual mode
invor Nov 16, 2022
a691ce9
delete dead code, minor fixes in mb-space shader (that dont fix the a…
invor Nov 16, 2022
ba5807f
fix normalization for dual-axis
invor Nov 22, 2022
96bbaaf
Improve m-b-space parameterization
invor Nov 22, 2022
9b97701
Optimizing sample cnt and add weighting to m-b-space
invor Nov 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions plugins/infovis_gl/shaders/infovis_gl/pc/dual.comp.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#version 450

layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;

#include "common/common.inc.glsl"
#include "common/invocation_index.inc.glsl"

layout(binding = 7, r32ui) uniform coherent uimage2DArray o_dualtex;
uniform int axPxHeight;

void main() {
uint invID = globalInvocationIndex();
uint itemID = invID % (itemCount);
uint dimID = invID / (itemCount);
float left = pc_dataValueNormalized(itemID, dimID);
float right = pc_dataValueNormalized(itemID, dimID + 1);

// Height - 1, because both left can be 0.0 and 1.0
imageAtomicAdd(o_dualtex, ivec3(left * float(axPxHeight -1), right* float(axPxHeight -1), dimID), 1);
}
13 changes: 13 additions & 0 deletions plugins/infovis_gl/shaders/infovis_gl/pc/dual.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#version 450

#include "common/common.inc.glsl"

in vec2 uvCoords;
out vec4 fragOut;
in vec4 color;
in float bins;
layout (binding=7, r32ui) uniform uimage2DArray imgRead;

void main() {
fragOut = color;
}
37 changes: 37 additions & 0 deletions plugins/infovis_gl/shaders/infovis_gl/pc/dual.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#version 450

#include "common/common.inc.glsl"
#include "mmstd_gl/common/tflookup.inc.glsl"
#include "mmstd_gl/common/tfconvenience.inc.glsl"

out vec2 uvCoords;
layout (binding=7, r32ui) uniform uimage2DArray imgRead;
uniform int axPxHeight;
uniform int fboHeight;
uniform int fboWidth;
uniform float debugFloat;
out vec4 color;

void main() {
int right = (gl_InstanceID % axPxHeight);
int cDim = gl_InstanceID / (axPxHeight*axPxHeight);
int left = (gl_InstanceID % (axPxHeight*axPxHeight)) / axPxHeight;
float fHeight = float(axPxHeight);
vec2 coord = vec2(float(gl_VertexID % 2), float((gl_VertexID % 4) / 2));
mat4 compMx = projMx * viewMx;
vec2 realOffset = vec2(margin.x + cDim * axisDistance, margin.y);

if (imageLoad(imgRead, ivec3(left, right, cDim)).x > 0u) {
float ycoordinate = axisHeight * (gl_VertexID * (right/fHeight) + ((gl_VertexID + 1) % 2) * (left/fHeight)) + margin.y;
ycoordinate = (compMx * vec4(0, ycoordinate, 0, 1)).y;
float xcoordinate = margin.x + (gl_VertexID + cDim) * axisDistance;
xcoordinate = (compMx * vec4(xcoordinate, 0, 0, 1)).x;
color = vec4(imageLoad(imgRead, ivec3(left, right, cDim)).r,0,0,1);
//color = vec4(1,0,0,1);
gl_Position = vec4(xcoordinate, ycoordinate, 0.0f, 1.0f);
} else {
gl_Position = vec4(-100, -100, -1.0, 0.0);
}

uvCoords = coord;
}
60 changes: 60 additions & 0 deletions plugins/infovis_gl/shaders/infovis_gl/pc/dualAlt.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#version 450

#include "common/common.inc.glsl"
#include "mmstd_gl/common/tflookup.inc.glsl"
#include "mmstd_gl/common/tfconvenience.inc.glsl"

in vec2 uvCoords;
out vec4 fragOut;
uniform int axPxHeight;
uniform int axPxWidth;
uniform float debugFloat;
layout (binding=7) uniform usampler2DArray imgRead;

void main() {
int axPxDist = axPxWidth / int(dimensionCount-1);

int cdim = int(floor(uvCoords.x) / float(axPxDist));
int a, b, c, d;

float result = 0;
//if (float(int(uvCoords.x) % axPxDist) / float(axPxDist) > 0.5) {
for (int i = 0; i < axPxHeight; i++) {
float xbot = (int(floor(uvCoords.x)) % axPxDist) / float(axPxDist);
float xtop = (int(ceil(uvCoords.x)) % axPxDist) / float(axPxDist);
a = int((floor(uvCoords.y) - float(i)) / xbot); // bottom left
b = int((floor(uvCoords.y) - float(i)) / xtop); // bottom right
c = int((ceil(uvCoords.y) - float(i)) / xbot); // bottom left
d = int((ceil(uvCoords.y) - float(i)) / xtop); // bottom right
int minY = a;
int maxY = a;
maxY = max(max(a, b), max(c, d));
minY = min(min(a, b), min(c, d));
if (minY < -i) {
minY = -i;
}
if (maxY > axPxHeight - i) {
maxY = axPxHeight - i;
}
while (minY <= maxY && minY < axPxHeight) {
minY = minY + 1;
result += 10 * texelFetch(imgRead, ivec3(i, i + minY, cdim), 0).x;
}
}
//}else{
//}

if (result > 0) {
fragOut = tflookup(result);
} else {
//fragOut = vec4(0.7);
}
//fragOut = vec4(fract(uvCoords.x), uvCoords.y / float(axPxHeight) , 0 ,1);
if (uvCoords.y == 1.0) {
//vec4(1.0);
} else {
//vec4(0.0, 0.0, 0.0, 1.0);
}

//fragOut = vec4(1, 1,0,1);
}
20 changes: 20 additions & 0 deletions plugins/infovis_gl/shaders/infovis_gl/pc/dualAlt.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#version 450

#include "common/common.inc.glsl"
//#include "mmstd_gl/common/tflookup.inc.glsl"
//#include "mmstd_gl/common/tfconvenience.inc.glsl"

out vec2 uvCoords;
layout (binding=7) uniform usampler2DArray imgRead;
uniform int axPxHeight;
uniform int axPxWidth;

void main() {
mat4 compMx = projMx * viewMx;
vec2 coord = margin.x + vec2(float(gl_VertexID % 2) * axisDistance * (dimensionCount-1), float(gl_VertexID / 2) * axisHeight);
coord = (compMx * vec4(coord, 0, 1)).xy;
gl_Position = vec4(coord, 0.0f, 1.0f);
uvCoords = vec2(float(gl_VertexID % 2) * axPxWidth, float(gl_VertexID / 2) * axPxHeight);
//gl_Position = vec4(vec2(float(gl_VertexID % 2), float((gl_VertexID % 4) / 2)),0,1);
//uvCoords = vec2(float(gl_VertexID % 2), float((gl_VertexID % 4) / 2));
}
51 changes: 51 additions & 0 deletions plugins/infovis_gl/shaders/infovis_gl/pc/dualHough.comp.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#version 450

layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;

#include "common/common.inc.glsl"
#include "common/invocation_index.inc.glsl"
#include "mmstd_gl/flags/bitflags.inc.glsl"

layout(binding = 7, r32ui) uniform coherent uimage2DArray o_dualtex;
layout(binding = 6, r32ui) uniform coherent uimage2DArray o_select_dualtex;
uniform int axPxHeight;
uniform int thetas;
uniform int rhos;
uniform uint itemTestMask = 0;
uniform uint itemPassMask = 0;

void main() {
uint invID = globalInvocationIndex();
uint itemID = invID % (itemCount);

uint dimID = invID / (itemCount); // correct division of inv to item/dim
float left = pc_dataValueNormalized(itemID, dimID);
float right = pc_dataValueNormalized(itemID, dimID + 1);
vec2 from = vec2(0.0, left);
vec2 to = vec2(1.0, right);
vec2 lineDir = normalize(to - from);
vec2 orthLine = normalize(vec2(-lineDir.y, lineDir.x));
float theta = acos(dot(orthLine, vec2(1.0, 0.0)));
float rho = abs((from.x * lineDir.y - from.y * lineDir.x)/(orthLine.x * lineDir.y - orthLine.y * lineDir.x));
if(!bitflag_test(flags[itemID], itemTestMask, itemPassMask)){
//imageAtomicAdd(o_dualtex, ivec3(left * axisHeight, right* axisHeight, dimID), 1);

//weights
float binnedTheta = (theta - 3.141/4.0) * (thetas) / (3.141/2.0);
float binnedRho = rho * (rhos-1.0);

float wt = fract(binnedRho);
float wb = 1.0 - fract(binnedRho);
float wl = 1.0 - fract(binnedTheta);
float wr = fract(binnedTheta);

imageAtomicAdd(o_dualtex, ivec3(int(binnedTheta) + 1, int(binnedRho) , dimID), int(1000.0* wb * wr / ((wt+wb)*(wl+wr))));
imageAtomicAdd(o_dualtex, ivec3(int(binnedTheta) , int(binnedRho) , dimID), int(1000.0* wb * wl / ((wt+wb)*(wl+wr))));
imageAtomicAdd(o_dualtex, ivec3(int(binnedTheta) + 1, int(binnedRho) + 1 , dimID), int(1000.0* wt * wr / ((wt+wb)*(wl+wr))));
imageAtomicAdd(o_dualtex, ivec3(int(binnedTheta), int(binnedRho) +1, dimID), int(1000.0* wt * wl / ((wt+wb)*(wl+wr))));
// write to texture at (left, right) atomically
}
else{
imageAtomicAdd(o_select_dualtex, ivec3(int((theta - 3.141/4.0) * (thetas) / (3.141/2.0)), int(rho * (rhos-1)) , dimID), 1);
}
}
52 changes: 52 additions & 0 deletions plugins/infovis_gl/shaders/infovis_gl/pc/dualHough.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#version 450

#include "common/common.inc.glsl"
#include "mmstd_gl/common/tflookup.inc.glsl"
#include "mmstd_gl/common/tfconvenience.inc.glsl"

in vec2 uvCoords;
out vec4 fragOut;
// height is actually number of bins
uniform int axPxHeight;
uniform int axPxWidth;
uniform float debugFloat;
uniform int binsNr;
uniform int thetas;
uniform int rhos;
layout (binding=7) uniform usampler2DArray imgRead;
layout (binding=8) uniform usampler2DArray slctRead;

void main() {
bool selected = false;
int axPxDist = axPxWidth / int(dimensionCount-1);
float PI = 3.1415926535;
int cdim = int(floor(uvCoords.x));
float relx = fract(uvCoords.x);
float result = 0;

for (int i = 0; i <= thetas; i++) {
//int((theta + 45/360 * 2 * 3.141) / (90/360 * 2 * 3.141) * axPxHeight
float theta = (float(i)/float(thetas) * PI/2.0 + PI/4.0);
vec2 orth = vec2(cos(theta), sin(theta));
vec2 dir = vec2(-orth.y, orth.x);
//float rho = (dir.x * uvCoords.y - dir.y * relx) / (dir.x * orth.y - dir.y * orth.x);
float rho = relx * cos(theta) + fract(uvCoords.y) * sin(theta);
if (texelFetch(imgRead, ivec3(i, rho * (rhos-1), cdim), 0).x > 0) {
result += float(texelFetch(imgRead, ivec3(i, rho * (rhos-1), cdim), 0).x) / 1000.0;
}
if(texelFetch(slctRead, ivec3(i, rho * (rhos-1), cdim), 0).x != 0){
selected = true;
break;
}
}

if(result > 0 || selected){
if(!selected){
fragOut = tflookup((result-1));
}else{
fragOut = vec4(1,0,0,1);
}
} else {
discard;
}
}
21 changes: 21 additions & 0 deletions plugins/infovis_gl/shaders/infovis_gl/pc/dualHough.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#version 450

#include "common/common.inc.glsl"
//#include "mmstd_gl/common/tflookup.inc.glsl"
//#include "mmstd_gl/common/tfconvenience.inc.glsl"

out vec2 uvCoords;
layout (binding=7) uniform usampler2DArray imgRead;
uniform int axPxHeight;
uniform int axPxWidth;
uniform int binsNr;
uniform int thetas;
uniform int rhos;

void main() {
mat4 compMx = projMx * viewMx;
vec2 coord = margin.x + vec2(float(gl_VertexID % 2) * axisDistance * (dimensionCount-1), float(gl_VertexID / 2) * axisHeight);
coord = (compMx * vec4(coord, 0, 1)).xy;
gl_Position = vec4(coord, 0.0f, 1.0f);
uvCoords = vec2(float(gl_VertexID % 2) * (dimensionCount-1), float(gl_VertexID / 2));
}
21 changes: 21 additions & 0 deletions plugins/infovis_gl/shaders/infovis_gl/pc/dualM.comp.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#version 450

layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;

#include "common/common.inc.glsl"
#include "common/invocation_index.inc.glsl"

layout(binding = 7, r32ui) uniform coherent uimage2DArray o_dualtex;
uniform int axesHeight;

void main() {
uint invID = globalInvocationIndex();
uint itemID = invID % (itemCount);
uint dimID = invID / (itemCount); // correct division of inv to item/dim
float left = pc_dataValueNormalized(itemID, dimID);
float right = pc_dataValueNormalized(itemID, dimID + 1);

//imageAtomicAdd(o_dualtex, ivec3(left * axisHeight, right* axisHeight, dimID), 1);
imageAtomicAdd(o_dualtex, ivec3(left * axesHeight, axesHeight + (right-left) * axesHeight, dimID), 1);
// write to texture at (left, right) atomically
}
27 changes: 27 additions & 0 deletions plugins/infovis_gl/shaders/infovis_gl/pc/dualM.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#version 450

#include "common/common.inc.glsl"
#include "mmstd_gl/common/tflookup.inc.glsl"
#include "mmstd_gl/common/tfconvenience.inc.glsl"

in vec2 uvCoords;
out vec4 fragOut;
uniform int axesHeight;
layout (binding=7, r32ui) uniform uimage2DArray imgRead;

void main() {
int cdim = int(uvCoords.x * (dimensionCount-1));
float relX = fract(uvCoords.x);
float relY = uvCoords.y;
float result = 0;
for (int i = 0; i < axesHeight; i++) {
int targetY = int((i - relY) / relX);
result += imageLoad(imgRead, ivec3(i, axesHeight - targetY, cdim)).x;
}
if (result > 0) {
//fragOut = tflookup(result);
} else {
//discard;
}
//fragOut = vec4(relX, relX,relX,1);
}
19 changes: 19 additions & 0 deletions plugins/infovis_gl/shaders/infovis_gl/pc/dualM.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#version 450

#include "common/common.inc.glsl"
//#include "mmstd_gl/common/tflookup.inc.glsl"
//#include "mmstd_gl/common/tfconvenience.inc.glsl"

out vec2 uvCoords;
layout (binding=7, r32ui) uniform uimage2DArray imgRead;
uniform int axesHeight;

void main() {
mat4 compMx = projMx * viewMx;
vec2 coord = margin.x + vec2(float(gl_VertexID % 2) * axisDistance * (dimensionCount-1), float(gl_VertexID / 2) * axisHeight);
coord = (compMx * vec4(coord, 0, 1)).xy;
gl_Position = vec4(coord, 0.0f, 1.0f);
uvCoords = vec2(float(gl_VertexID % 2) * (dimensionCount-1), float(gl_VertexID / 2) * axesHeight);
//gl_Position = vec4(vec2(float(gl_VertexID % 2), float((gl_VertexID % 4) / 2)),0,1);
//uvCoords = vec2(float(gl_VertexID % 2), float((gl_VertexID % 4) / 2));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#version 450

#include "common/common.inc.glsl"
#include "mmstd_gl/common/tflookup.inc.glsl"
#include "mmstd_gl/common/tfconvenience.inc.glsl"

layout(binding = 1) uniform sampler2D fragmentCountTex;

smooth in vec2 texCoord;

layout(location = 0) out vec4 fragColor;

void main() {
float fragmentCount = texture(fragmentCountTex, texCoord).r;
if (fragmentCount > 0) {
fragColor = tflookup(fragmentCount);
//fragColor = vec4(fragmentCount/500.0, 0, 0, 1);
//fragColor = vec4(0.5);
}else{
discard;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#version 450

#include "common/common.inc.glsl"
#include "mmstd_gl/common/quad_vertices.inc.glsl"

smooth out vec2 texCoord;

void main() {
vec2 pos = quadVertexPosition();

texCoord = pos;
gl_Position = vec4(pos * 2.0f - 1.0f, pc_defaultDepth, 1.0f);
}
Loading