Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GraPa
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
GraPa
Commits
eb660cbd
Commit
eb660cbd
authored
Jan 05, 2016
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
geometry
parent
86111c8b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
10 deletions
+64
-10
glview.cpp
A4/glview.cpp
+9
-4
hellocube.pro
A4/hellocube.pro
+2
-1
hellocube.qrc
A4/hellocube.qrc
+1
-0
landscape.frag
A4/landscape.frag
+17
-5
landscape.geo
A4/landscape.geo
+35
-0
No files found.
A4/glview.cpp
View file @
eb660cbd
...
@@ -121,10 +121,6 @@ void GLView::initShader()
...
@@ -121,10 +121,6 @@ void GLView::initShader()
if
(
!
vertex2
->
compileSourceFile
(
QLatin1String
(
":/landscape.vert"
)))
if
(
!
vertex2
->
compileSourceFile
(
QLatin1String
(
":/landscape.vert"
)))
qCritical
()
<<
"Vertex Shader landscape failed"
<<
vertex2
->
log
();
qCritical
()
<<
"Vertex Shader landscape failed"
<<
vertex2
->
log
();
QOpenGLShader
*
fragment2
=
new
QOpenGLShader
(
QOpenGLShader
::
Fragment
);
if
(
!
fragment2
->
compileSourceFile
(
QLatin1String
(
":/landscape.frag"
)))
qCritical
()
<<
"Fragment Shader landscape failed"
<<
fragment2
->
log
();
QOpenGLShader
*
tesselationControl
=
new
QOpenGLShader
(
QOpenGLShader
::
TessellationControl
);
QOpenGLShader
*
tesselationControl
=
new
QOpenGLShader
(
QOpenGLShader
::
TessellationControl
);
if
(
!
tesselationControl
->
compileSourceFile
(
QLatin1String
(
":/landscape.tcs"
)))
if
(
!
tesselationControl
->
compileSourceFile
(
QLatin1String
(
":/landscape.tcs"
)))
qCritical
()
<<
"Tesselation Control landscape failed"
<<
tesselationControl
->
log
();
qCritical
()
<<
"Tesselation Control landscape failed"
<<
tesselationControl
->
log
();
...
@@ -133,11 +129,20 @@ void GLView::initShader()
...
@@ -133,11 +129,20 @@ void GLView::initShader()
if
(
!
tesselationEval
->
compileSourceFile
(
QLatin1String
(
":/landscape.tes"
)))
if
(
!
tesselationEval
->
compileSourceFile
(
QLatin1String
(
":/landscape.tes"
)))
qCritical
()
<<
"Tesselation Eval landscape failed"
<<
tesselationEval
->
log
();
qCritical
()
<<
"Tesselation Eval landscape failed"
<<
tesselationEval
->
log
();
QOpenGLShader
*
geometry
=
new
QOpenGLShader
(
QOpenGLShader
::
Geometry
);
if
(
!
geometry
->
compileSourceFile
(
QLatin1String
(
":/landscape.geo"
)))
qCritical
()
<<
"Tesselation Eval landscape failed"
<<
geometry
->
log
();
QOpenGLShader
*
fragment2
=
new
QOpenGLShader
(
QOpenGLShader
::
Fragment
);
if
(
!
fragment2
->
compileSourceFile
(
QLatin1String
(
":/landscape.frag"
)))
qCritical
()
<<
"Fragment Shader landscape failed"
<<
fragment2
->
log
();
landscapeShader
=
new
QOpenGLShaderProgram
(
this
);
landscapeShader
=
new
QOpenGLShaderProgram
(
this
);
landscapeShader
->
addShader
(
vertex2
);
landscapeShader
->
addShader
(
vertex2
);
landscapeShader
->
addShader
(
fragment2
);
landscapeShader
->
addShader
(
fragment2
);
landscapeShader
->
addShader
(
tesselationControl
);
landscapeShader
->
addShader
(
tesselationControl
);
landscapeShader
->
addShader
(
tesselationEval
);
landscapeShader
->
addShader
(
tesselationEval
);
landscapeShader
->
addShader
(
geometry
);
if
(
!
landscapeShader
->
link
()){
if
(
!
landscapeShader
->
link
()){
qCritical
()
<<
"Linking landscape failed:"
<<
landscapeShader
->
log
();
qCritical
()
<<
"Linking landscape failed:"
<<
landscapeShader
->
log
();
}
}
...
...
A4/hellocube.pro
View file @
eb660cbd
...
@@ -53,6 +53,7 @@ DISTFILES += \
...
@@ -53,6 +53,7 @@ DISTFILES += \
landscape
.
frag
\
landscape
.
frag
\
landscape
.
vert
\
landscape
.
vert
\
landscape
.
tec
\
landscape
.
tec
\
landscape
.
tes
landscape
.
tes
\
landscape
.
geo
FORMS
+=
FORMS
+=
A4/hellocube.qrc
View file @
eb660cbd
...
@@ -25,5 +25,6 @@
...
@@ -25,5 +25,6 @@
<file>landscape.vert</file>
<file>landscape.vert</file>
<file>landscape.tcs</file>
<file>landscape.tcs</file>
<file>landscape.tes</file>
<file>landscape.tes</file>
<file>landscape.geo</file>
</qresource>
</qresource>
</RCC>
</RCC>
A4/landscape.frag
View file @
eb660cbd
#version 420
#version 420
out
vec4
FragColor
;
out
vec4
FragColor
;
in
vec3
tePosition
;
in
vec3
gPosition
;
in
vec2
teUV
;
in
vec2
gUV
;
in
vec3
gTriDistance
;
uniform
sampler2D
heightmap
;
uniform
sampler2D
heightmap
;
uniform
sampler2D
landTex1
;
uniform
sampler2D
landTex1
;
...
@@ -14,17 +15,28 @@ void main()
...
@@ -14,17 +15,28 @@ void main()
{
{
//
//
vec2
textureUV
=
te
UV
*
8
;
vec2
textureUV
=
g
UV
*
8
;
vec3
col1
=
texture2D
(
landTex1
,
textureUV
).
xyz
;
vec3
col1
=
texture2D
(
landTex1
,
textureUV
).
xyz
;
vec3
col2
=
texture2D
(
landTex2
,
textureUV
).
xyz
;
vec3
col2
=
texture2D
(
landTex2
,
textureUV
).
xyz
;
float
height
=
te
Position
.
y
/
5
;
float
height
=
g
Position
.
y
/
5
;
float
alpha
=
smoothstep
(
0
.
4
f
,
0
.
6
f
,
height
);
float
alpha
=
smoothstep
(
0
.
4
f
,
0
.
6
f
,
height
);
//float alpha = clamp(height,0.0,1.0);
//float alpha = clamp(height,0.0,1.0);
FragColor
=
vec4
((
1
-
alpha
)
*
col2
+
alpha
*
col1
,
1
.
0
);
float
d
=
min
(
gTriDistance
[
0
],
min
(
gTriDistance
.
y
,
gTriDistance
.
z
));
float
edgeIntensity
=
exp2
(
-
1
.
0
*
d
*
d
);
FragColor
=
+
vec4
((
1
-
alpha
)
*
col2
+
alpha
*
col1
,
1
.
0
);
if
(
d
<
0
.
05
){
FragColor
=
edgeIntensity
*
vec4
(
0
.
0
,
1
.
0
,
0
.
0
,
1
.
0
);
}
//FragColor = vec4(gUV,0.0,1.0);
//FragColor = vec4(alpha);
//FragColor = vec4(alpha);
//FragColor = vec4(col1,1.0);
//FragColor = vec4(col1,1.0);
//FragColor = clamp(vec4(vec3(textureLod(heightmap,teUV,0).x), 1.0)*10,0,1);
//FragColor = clamp(vec4(vec3(textureLod(heightmap,teUV,0).x), 1.0)*10,0,1);
...
...
A4/landscape.geo
0 → 100644
View file @
eb660cbd
#version 420
layout (triangles) in;
layout (triangle_strip, max_vertices = 3) out;
in vec2 teUV[3];
out vec2 gUV;
in vec3 tePosition[3];
out vec3 gPosition;
out vec3 gTriDistance;
void main(void)
{
gTriDistance = vec3(1, 0, 0);
gUV = teUV[0];
gPosition = tePosition[0];
gl_Position = gl_in[0].gl_Position; EmitVertex();
gTriDistance = vec3(0, 1, 0);
gUV = teUV[1];
gPosition = tePosition[1];
gl_Position = gl_in[1].gl_Position; EmitVertex();
gTriDistance = vec3(0, 0, 1);
gUV = teUV[2];
gPosition = tePosition[2];
gl_Position = gl_in[2].gl_Position; EmitVertex();
EndPrimitive();
}
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