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
a7445df0
Commit
a7445df0
authored
Sep 28, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add buffer for sharpness to edge shader
parent
f804bd56
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
+29
-3
subdivision-edge.compute
QTProject/subdivision-edge.compute
+6
-0
subdivision.cpp
QTProject/subdivision.cpp
+22
-2
subdivision.h
QTProject/subdivision.h
+1
-1
No files found.
QTProject/subdivision-edge.compute
View file @
a7445df0
...
...
@@ -24,6 +24,10 @@ layout(std430, binding=3) readonly buffer OutputOffset {
unsigned int output_offset;
};
layout(std430, binding=4) readonly buffer EdgeSharpness {
unsigned int sharpness[];
};
void main(){
edges[output_offset + gl_GlobalInvocationID.x].uv = vec2(0.0, 0.0);
...
...
@@ -32,6 +36,8 @@ void main(){
Vertex c = vertices[indices[gl_GlobalInvocationID.x][2]];
Vertex d = vertices[indices[gl_GlobalInvocationID.x][3]];
unsigned int s = sharpness[gl_GlobalInvocationID.x];
vec3 pos;
edges[output_offset + gl_GlobalInvocationID.x].pos = 3.0f/8.0f * a.pos + 3.0f/8.0f * b.pos + 1.0f/8.0f * c.pos + 1.0f/8.0f * d.pos;
...
...
QTProject/subdivision.cpp
View file @
a7445df0
...
...
@@ -971,6 +971,19 @@ Subdivision::Result Subdivision::runShader(Input input, Tables &tables) {
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
edge_indices_handle
);
f
->
glBufferData
(
GL_SHADER_STORAGE_BUFFER
,
tables
.
edge_indices
.
size
()
*
sizeof
(
GLuint
),
tables
.
edge_indices
.
data
(),
GL_DYNAMIC_DRAW
);
//prepare sharpness buffer
QVector
<
unsigned
int
>
sharpness
;
for
(
int
i
=
0
;
i
<
tables
.
edge_indices
.
size
();
i
+=
4
){
sharpness
.
push_back
(
0
);
}
qCWarning
(
log_subdiv_trace
)
<<
"Sharpness: "
<<
sharpness
;
GLuint
edge_sharpness_handle
;
f
->
glGenBuffers
(
1
,
&
edge_sharpness_handle
);
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
edge_sharpness_handle
);
f
->
glBufferData
(
GL_SHADER_STORAGE_BUFFER
,
sharpness
.
size
()
*
sizeof
(
GLuint
),
sharpness
.
data
(),
GL_DYNAMIC_DRAW
);
// Create an output buffer
// the new vertex buffer contains the old vertices + the new edge vertices + the modified non-edge vertices
unsigned
int
output_size
=
input
.
vertex_buffer
.
size
()
+
tables
.
edge_indices
.
size
()
/
4
+
(
tables
.
vertex_offsets
.
size
()
-
1
);
...
...
@@ -999,7 +1012,7 @@ Subdivision::Result Subdivision::runShader(Input input, Tables &tables) {
GLuint
*
offset_buffer
=
(
GLuint
*
)
f
->
glMapBuffer
(
GL_SHADER_STORAGE_BUFFER
,
GL_WRITE_ONLY
);
*
offset_buffer
=
input
.
vertex_buffer
.
size
();
f
->
glUnmapBuffer
(
GL_SHADER_STORAGE_BUFFER
);
runEdgeShader
(
tables
.
edge_indices
.
size
()
/
4
,
input
.
vb_handle
,
edge_indices_handle
,
output_handle
,
offset_handle
);
runEdgeShader
(
tables
.
edge_indices
.
size
()
/
4
,
input
.
vb_handle
,
edge_indices_handle
,
edge_sharpness_handle
,
output_handle
,
offset_handle
);
int
edgeTime
=
timer
.
elapsed
();
// move old vertices
...
...
@@ -1077,13 +1090,19 @@ void Subdivision::runVertexShader(GLuint size, GLuint vb_handle, GLuint vertex_i
vertexShader
->
release
();
}
void
Subdivision
::
runEdgeShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
edge_indices_handle
,
GLuint
output_handle
,
GLuint
offset_handle
)
{
void
Subdivision
::
runEdgeShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
edge_indices_handle
,
GLuint
edge_sharpness_handle
,
GLuint
output_handle
,
GLuint
offset_handle
)
{
edgeShader
->
bind
();
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
0
,
vb_handle
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
1
,
edge_indices_handle
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
2
,
output_handle
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
3
,
offset_handle
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
4
,
edge_sharpness_handle
);
// Run the shader
f
->
glDispatchCompute
(
size
,
1
,
1
);
...
...
@@ -1096,6 +1115,7 @@ void Subdivision::runEdgeShader(GLuint size, GLuint vb_handle, GLuint edge_indic
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
1
,
0
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
2
,
0
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
3
,
0
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
4
,
0
);
edgeShader
->
release
();
}
...
...
QTProject/subdivision.h
View file @
a7445df0
...
...
@@ -83,7 +83,7 @@ private:
Result
runShader
(
Input
input
,
Tables
&
tables
);
void
runCopyShader
(
GLuint
size
,
GLuint
vb_in
,
GLuint
vb_out
);
void
runVertexShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
vertex_indices_handle
,
GLuint
vertex_offsets_handle
,
GLuint
output_handle
,
GLuint
offset_handle
);
void
runEdgeShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
edge_indices_handle
,
GLuint
output_handle
,
GLuint
offset_handle
);
void
runEdgeShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
edge_indices_handle
,
GLuint
edge_sharpness_handle
,
GLuint
output_handle
,
GLuint
offset_handle
);
void
updateIrregularForDraw
(
const
QVector
<
Triangle
>
&
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
&
neighbors
,
Result
&
result
);
bool
containsVertex
(
QVector
<
Vertex
>
&
vertices
,
Vertex
vertex
);
QVector
<
Vertex
>
getAllVertices
(
const
QVector
<
Triangle
>
&
triangles
);
...
...
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