Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
Unterteilungsalgorithmen
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kai Westerkamp
Unterteilungsalgorithmen
Commits
2117bcae
Commit
2117bcae
authored
Sep 26, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add shader for neighbor calculation
parent
beb432b2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
1 deletion
+78
-1
resources.qrc
QTProject/resources.qrc
+1
-0
subdivision-neighbors.compute
QTProject/subdivision-neighbors.compute
+71
-0
subdivision.cpp
QTProject/subdivision.cpp
+5
-1
subdivision.h
QTProject/subdivision.h
+1
-0
No files found.
QTProject/resources.qrc
View file @
2117bcae
...
...
@@ -7,6 +7,7 @@
<file>subdivide.vert</file>
<file>subdivision-copy.compute</file>
<file>subdivision-edge.compute</file>
<file>subdivision-neighbors.compute</file>
<file>subdivision-vertex.compute</file>
<file>subdivideRegular.tcs</file>
<file>subdivideRegular.tes</file>
...
...
QTProject/subdivision-neighbors.compute
0 → 100644
View file @
2117bcae
#version 430 core
layout (local_size_x = 1, local_size_y = 1) in;
struct Vertex {
vec3 pos;
vec3 norm;
vec2 uv;
};
layout(std430, binding=0) buffer Vertices {
Vertex vb[];
};
layout(std430, binding=1) buffer Index {
unsigned int ib[];
};
layout(std430, binding=2) buffer Offset {
unsigned int offset_in;
unsigned int offset_search;
};
layout(std430, binding=3) buffer Output {
int neighbors[][3];
};
int shared_edge(vec3 u, vec3 v, vec3 w, vec3 a, vec3 b, vec3 c) {
if (u == a && v == c) {
return 0;
} else if (u == a && w == b) {
return 2;
} else if (v == a && w == c) {
return 1;
}
return -1;
}
void main() {
if (3 * (gl_GlobalInvocationID.x + offset_in) + 2 >= ib.length()) {
return;
}
int found = 0;
found += (neighbors[gl_GlobalInvocationID.x + offset_in][0] > 0) ? 1 : 0;
found += (neighbors[gl_GlobalInvocationID.x + offset_in][1] > 0) ? 1 : 0;
found += (neighbors[gl_GlobalInvocationID.x + offset_in][2] > 0) ? 1 : 0;
vec3 u = vb[ib[3 * (gl_GlobalInvocationID.x + offset_in) + 0]].pos;
vec3 v = vb[ib[3 * (gl_GlobalInvocationID.x + offset_in) + 1]].pos;
vec3 w = vb[ib[3 * (gl_GlobalInvocationID.x + offset_in) + 2]].pos;
for (int i = 0; found < 3 && i < 128 && (3 * gl_GlobalInvocationID.y + offset_search + gl_NumWorkGroups.y * i) + 2 < ib.length(); i++) {
vec3 a = vb[ib[3 * (gl_GlobalInvocationID.y + offset_search + gl_NumWorkGroups.y * i) + 0]].pos;
vec3 b = vb[ib[3 * (gl_GlobalInvocationID.y + offset_search + gl_NumWorkGroups.y * i) + 1]].pos;
vec3 c = vb[ib[3 * (gl_GlobalInvocationID.y + offset_search + gl_NumWorkGroups.y * i) + 2]].pos;
int edge;
edge = shared_edge(u, v, w, a, b, c);
if (edge < 0) {
edge = shared_edge(u, v, w, b, c, a);
}
if (edge < 0) {
edge = shared_edge(u, v, w, c, a, b);
}
if (edge >= 0) {
neighbors[gl_GlobalInvocationID.x + offset_in][edge] = int(gl_GlobalInvocationID.y + offset_search + gl_NumWorkGroups.y * i);
found++;
}
}
}
QTProject/subdivision.cpp
View file @
2117bcae
...
...
@@ -10,6 +10,7 @@ Subdivision::Subdivision(QOpenGLFunctions_4_3_Core *f)
Subdivision
::~
Subdivision
()
{
delete
neighborsShader
;
delete
copyShader
;
delete
edgeShader
;
delete
vertexShader
;
...
...
@@ -22,7 +23,10 @@ QString Subdivision::formatTimeMeasurement(int time){
}
void
Subdivision
::
init
()
{
QString
source
=
QLatin1String
(
":/subdivision-copy.compute"
);
QString
source
=
QLatin1String
(
":/subdivision-neighbors.compute"
);
neighborsShader
=
initComputeShaderProgram
(
source
);
source
=
QLatin1String
(
":/subdivision-copy.compute"
);
copyShader
=
initComputeShaderProgram
(
source
);
source
=
QLatin1String
(
":/subdivision-edge.compute"
);
...
...
QTProject/subdivision.h
View file @
2117bcae
...
...
@@ -51,6 +51,7 @@ private:
QString
formatTimeMeasurement
(
int
time
);
QOpenGLFunctions_4_3_Core
*
f
;
QOpenGLShaderProgram
*
neighborsShader
;
QOpenGLShaderProgram
*
copyShader
;
QOpenGLShaderProgram
*
edgeShader
;
QOpenGLShaderProgram
*
vertexShader
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment