Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
OpenGL
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
C-Fu
OpenGL
Commits
541a9756
Commit
541a9756
authored
Feb 05, 2017
by
Anakin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added preview imange,
passed data to shader, need to process data in shader
parent
30f1a1e6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
6 deletions
+29
-6
QtMeshViewer/Resources/fshader.glsl
QtMeshViewer/Resources/fshader.glsl
+13
-3
QtMeshViewer/Source/GeometryEngine.cpp
QtMeshViewer/Source/GeometryEngine.cpp
+16
-3
preview.jpg
preview.jpg
+0
-0
No files found.
QtMeshViewer/Resources/fshader.glsl
View file @
541a9756
...
...
@@ -8,11 +8,13 @@ uniform mat3 n_matrix;
uniform
vec3
cameraPosition
;
uniform
sampler2D
texture
;
uniform
sampler2D
secondTexture
;
uniform
float
materialShininess
;
uniform
vec3
materialSpecularColor
;
uniform
bool
b_transparent
;
uniform
bool
b_specular
;
uniform
bool
b_normalmap
;
uniform
bool
b_light
;
uniform
struct
Light
{
...
...
@@ -35,7 +37,15 @@ void main()
if
(
b_light
)
{
// some values
vec3
normalWorld
=
normalize
(
n_matrix
*
v_surfaceNormal
);
mat3
tbn
=
transpose
(
mat3
(
a_polyTan
,
a_polyBiTan
,
a_polyNorm
));
vec3
finalNormal
=
normalize
(
n_matrix
*
v_surfaceNormal
);
// if(b_normalmap)
// {
// finalNormal = texture2D(secondTexture, v_surfaceUV).rgb;
// finalNormal = normalize(finalNormal * 2.0 -1.0)
// }
vec4
surfaceColor
=
vec4
(
texture2D
(
texture
,
v_surfaceUV
));
surfaceColor
.
rgb
=
pow
(
surfaceColor
.
rgb
,
vec3
(
2
.
2
));
...
...
@@ -62,13 +72,13 @@ void main()
vec3
ambient
=
light
.
ambientCoefficient
*
surfaceColor
.
rgb
*
light
.
intensities
;
// diffuse
float
diffuseCoefficient
=
max
(
0
.
0
,
dot
(
normalWorld
,
surfaceToLight
));
float
diffuseCoefficient
=
max
(
0
.
0
,
dot
(
finalNormal
,
surfaceToLight
));
vec3
diffuse
=
diffuseCoefficient
*
surfaceColor
.
rgb
*
light
.
intensities
;
// specular
float
specularCoefficient
=
0
.
0
;
if
(
diffuseCoefficient
>
0
.
0
)
specularCoefficient
=
pow
(
max
(
0
.
0
,
dot
(
surfaceToCamera
,
reflect
(
-
surfaceToLight
,
normalWorld
))),
materialShininess
);
specularCoefficient
=
pow
(
max
(
0
.
0
,
dot
(
surfaceToCamera
,
reflect
(
-
surfaceToLight
,
finalNormal
))),
materialShininess
);
vec3
specColor
;
if
(
b_specular
)
specColor
=
vec3
(
surfaceColor
.
a
);
...
...
QtMeshViewer/Source/GeometryEngine.cpp
View file @
541a9756
...
...
@@ -121,8 +121,9 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
normMatrix
.
translate
(
-
m_boundings
.
center
[
0
],
-
m_boundings
.
center
[
1
],
-
m_boundings
.
center
[
2
]);
program
->
setUniformValue
(
"norm_matrix"
,
normMatrix
);
// Allways use texture unit 0
// Allways use texture unit 0
and 1
program
->
setUniformValue
(
"texture"
,
0
);
program
->
setUniformValue
(
"secondTexture"
,
1
);
//setup the pipeline
setupPipeline
(
program
);
...
...
@@ -133,23 +134,34 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
{
bool
tmp_transparent
(
false
);
bool
tmp_specular
(
false
);
bool
tmp_normalmap
(
false
);
float
shininess
(
0.0
);
QVector3D
specularColor
;
// bind the correct texture
if
(
it
.
textureIndex
<
(
unsigned
)
m_materials
->
size
()
&&
m_materials
->
at
(
it
.
textureIndex
).
texture0
!=
Q_NULLPTR
)
{
m_materials
->
at
(
it
.
textureIndex
).
texture0
->
bind
();
m_materials
->
at
(
it
.
textureIndex
).
texture0
->
bind
(
0
);
tmp_transparent
=
m_materials
->
at
(
it
.
textureIndex
).
transparent
;
tmp_specular
=
m_materials
->
at
(
it
.
textureIndex
).
flags
[
7
];
shininess
=
m_materials
->
at
(
it
.
textureIndex
).
shininess
;
specularColor
=
m_materials
->
at
(
it
.
textureIndex
).
specularColor
.
toVector3D
();
if
(
m_materials
->
at
(
it
.
textureIndex
).
rendertype
==
27
||
m_materials
->
at
(
it
.
textureIndex
).
rendertype
==
28
)
{
if
(
m_materials
->
at
(
it
.
textureIndex
).
texture1
!=
Q_NULLPTR
)
{
tmp_normalmap
=
true
;
m_materials
->
at
(
it
.
textureIndex
).
texture1
->
bind
(
1
);
}
}
}
else
{
m_defaultMaterial
->
texture0
->
bind
();
m_defaultMaterial
->
texture0
->
bind
(
0
);
tmp_transparent
=
m_defaultMaterial
->
transparent
;
}
// Set model matrix
program
->
setUniformValue
(
"m_matrix"
,
it
.
modelMatrix
);
...
...
@@ -159,6 +171,7 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
// set some more values
program
->
setUniformValue
(
"b_transparent"
,
tmp_transparent
);
program
->
setUniformValue
(
"b_specular"
,
tmp_specular
);
program
->
setUniformValue
(
"b_normalmap"
,
tmp_normalmap
);
// set some material attributes
program
->
setUniformValue
(
"materialShininess"
,
shininess
);
...
...
preview.jpg
0 → 100644
View file @
541a9756
43.4 KB
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