Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
RoboGuide
scigl_render
Commits
22ea6d63
Commit
22ea6d63
authored
Mar 01, 2019
by
Tim Übelhör
Browse files
fixed specular lighting
parent
92c9c91f
Changes
9
Hide whitespace changes
Inline
Side-by-side
.vscode/launch.json
View file @
22ea6d63
...
...
@@ -9,7 +9,7 @@
"type"
:
"cppdbg"
,
"request"
:
"launch"
,
"program"
:
"${workspaceFolder}/build/bin/scigl_viewer"
,
"args"
:
[
"${workspaceFolder}/model/
beckenkamm.dae
"
],
"args"
:
[
"${workspaceFolder}/model/
monkey.blend
"
],
"stopAtEntry"
:
false
,
"cwd"
:
"${workspaceFolder}"
,
"environment"
:
[],
...
...
conanfile.py
View file @
22ea6d63
...
...
@@ -3,7 +3,7 @@ from conans import ConanFile, CMake
class
SciglRenderConan
(
ConanFile
):
name
=
"scigl_render"
version
=
"0.
3
"
version
=
"0.
4
"
license
=
"MIT"
url
=
"https://git.rwth-aachen.de/robo_guide/scigl_render"
description
=
(
"Library to simplify rendering objects via OpenGL."
...
...
include/scigl_render/shader/simple.vs
View file @
22ea6d63
R
""
(
#version 330 core
layout
(
location
=
0
)
in
vec3
position
;
uniform
mat4
model_matrix
;
uniform
mat4
view_matrix
;
uniform
mat4
projection_matrix
;
out
float
depth
;
out
vec3
world_position
;
// simple linear transformation into projection space
void
main
()
{
vec4
local_pos
=
vec4
(
position
,
1
.
0
);
vec4
view_pos
=
view_matrix
*
model_matrix
*
local_pos
;
vec4
local_position
=
vec4
(
position
,
1
.
0
);
world_position
=
(
model_matrix
*
local_position
).
xyz
;
vec4
view_pos
=
view_matrix
*
vec4
(
world_position
,
1
.
0
);
depth
=
view_pos
.
z
;
gl_Position
=
projection_matrix
*
view_pos
;
})
""
\ No newline at end of file
include/scigl_render/shader/texture.fs
View file @
22ea6d63
...
...
@@ -32,15 +32,15 @@ void main()
vec3
diffuse_color
=
material
.
diffuse
+
diffuse_texture_strength
*
texture
(
texture0
,
texture_coordinate
).
xyz
;
float
diff
=
max
(
dot
(
normal
,
light_direction
),
0
.
0
);
vec3
diffuse
=
diff
*
diffuse_color
;
vec3
diffuse
=
diff
*
diffuse_color
*
light_color
;
// specular
vec3
view_direction
=
normalize
(
camera_position
-
world_position
);
vec3
reflection_direction
=
reflect
(-
light_direction
,
normal
);
float
spec
=
pow
(
max
(
dot
(
view_direction
,
reflection_direction
),
0
.
0
),
material
.
shininess
);
vec3
specular
=
material
.
specular
*
spec
;
vec3
specular
=
spec
*
material
.
specular
*
light_color
;
// combined
vec3
result
=
(
ambient
+
diffuse
+
specular
)
*
light_color
;
vec3
result
=
ambient
+
diffuse
+
specular
;
fragment_color
=
vec4
(
result
,
1
.
0
);
}
)
""
\ No newline at end of file
model/monkey.3ds
LFS
View file @
22ea6d63
No preview for this file type
model/monkey.blend
LFS
View file @
22ea6d63
No preview for this file type
package.xml
View file @
22ea6d63
...
...
@@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package
format=
"2"
>
<name>
scigl_render
</name>
<version>
0.
3
</version>
<version>
0.
4
</version>
<description>
Library to simplify rendering objects via OpenGL. The intendet use case
is scientific (e.g. probabalistic filtering). It is not supposed to be a
...
...
src/example/scigl_viewer.cpp
View file @
22ea6d63
...
...
@@ -67,7 +67,11 @@ int main(int argc, char *argv[])
camera_intrinsics
.
c_y
=
310
;
camera_intrinsics
.
f_x
=
511
;
camera_intrinsics
.
f_y
=
513
;
camera_intrinsics
.
dist_coeffs
[
0
]
=
5
;
camera_intrinsics
.
dist_coeffs
[
0
]
=
4.1925421198910247e-02
;
camera_intrinsics
.
dist_coeffs
[
1
]
=
-
9.6463442423611379e-02
;
camera_intrinsics
.
dist_coeffs
[
2
]
=
-
2.3391717576772839e-03
;
camera_intrinsics
.
dist_coeffs
[
3
]
=
5.8792609967242386e-04
;
camera_intrinsics
.
dist_coeffs
[
4
]
=
4.9171950039135250e-02
;
CvCamera
camera
(
camera_intrinsics
);
// Test if Cartesian -> Quaternion works
CartesianPose
camera_pose
=
{
glm
::
vec3
(
0
,
0
,
0
),
glm
::
vec3
(
0
,
0
,
0
)};
...
...
@@ -77,7 +81,7 @@ int main(int argc, char *argv[])
model
.
pose
.
position
=
glm
::
vec3
(
0
,
0
,
0.5
);
model
.
pose
.
orientation
.
x
=
0.707
;
model
.
pose
.
orientation
.
w
=
0.707
;
light
.
position
=
glm
::
vec3
(
0
,
0
,
0
);
light
.
position
=
glm
::
vec3
(
0
,
-
0.1
,
0
);
light
.
color
=
glm
::
vec3
(
1
,
1
,
1
);
// main loop
...
...
src/scene/mesh.cpp
View file @
22ea6d63
...
...
@@ -67,7 +67,7 @@ Mesh::Mesh(const aiMesh *mesh, const aiScene *scene)
material
.
diffuse
=
convert_color
(
diffuse_color
);
}
aiColor3D
specular_color
;
if
(
AI_SUCCESS
==
ai_material
->
Get
(
AI_MATKEY_COLOR_
DIFFUSE
,
specular_color
))
if
(
AI_SUCCESS
==
ai_material
->
Get
(
AI_MATKEY_COLOR_
SPECULAR
,
specular_color
))
{
material
.
specular
=
convert_color
(
specular_color
);
}
...
...
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