Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RoFIbots
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marek Trtík
RoFIbots
Commits
d726a260
There was an error fetching the commit references. Please try again later.
Commit
d726a260
authored
1 year ago
by
Martin Štourač
Browse files
Options
Downloads
Patches
Plain Diff
added specular lighting
parent
453b1ef5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
data/shaders/lightshader.frag
+11
-1
11 additions, 1 deletion
data/shaders/lightshader.frag
src/gfx/include/gfx/control.hpp
+1
-1
1 addition, 1 deletion
src/gfx/include/gfx/control.hpp
src/gfx/src/render.cpp
+3
-2
3 additions, 2 deletions
src/gfx/src/render.cpp
with
15 additions
and
4 deletions
data/shaders/lightshader.frag
+
11
−
1
View file @
d726a260
...
...
@@ -7,17 +7,27 @@ in vec3 Normal;
uniform
vec3
objectColor
;
uniform
vec3
lightColor
;
uniform
vec3
lightPos
;
uniform
vec3
viewPos
;
void
main
()
{
//ambient
float
ambientStrength
=
0
.
1
;
vec3
ambient
=
ambientStrength
*
lightColor
;
// diffuse
vec3
norm
=
normalize
(
Normal
);
vec3
lightDir
=
normalize
(
lightPos
-
FragPos
);
float
diff
=
max
(
dot
(
norm
,
lightDir
),
0
.
0
);
vec3
diffuse
=
diff
*
lightColor
;
FragColor
=
vec4
((
ambient
+
diffuse
)
*
objectColor
,
1
.
0
f
);
// specular
float
specularStrength
=
0
.
5
;
// TO DO: Object shine
vec3
viewDir
=
normalize
(
viewPos
-
FragPos
);
vec3
reflectDir
=
reflect
(
-
lightDir
,
norm
);
float
spec
=
pow
(
max
(
dot
(
viewDir
,
reflectDir
),
0
.
0
),
32
);
vec3
specular
=
specularStrength
*
spec
*
lightColor
;
FragColor
=
vec4
((
ambient
+
diffuse
+
specular
)
*
objectColor
,
1
.
0
f
);
}
This diff is collapsed.
Click to expand it.
src/gfx/include/gfx/control.hpp
+
1
−
1
View file @
d726a260
...
...
@@ -18,8 +18,8 @@ protected:
float
step
=
0
;
// FTO DO: shared ptr
//Frame &bound_frame;
Frame
*
bound_frame
;
//std::shared_ptr<Frame> bound_frame;
public:
Controller
(
Frame
*
frame
)
...
...
This diff is collapsed.
Click to expand it.
src/gfx/src/render.cpp
+
3
−
2
View file @
d726a260
...
...
@@ -69,7 +69,7 @@ void send_matrices_to_shader(Shader &myShader, glm::mat4 &model, glm::mat4 &view
ASSUMPTION
(
glGetError
()
==
GL_NO_ERROR
);
}
void
draw_objects
(
std
::
map
<
std
::
string
,
shader_ptr
>
&
myShaders
,
void
draw_objects
(
std
::
map
<
std
::
string
,
shader_ptr
>
&
myShaders
,
Frame
&
cam_frame
,
std
::
vector
<
object_ptr
>
&
objects
,
std
::
vector
<
frame_ptr
>
&
obj_frames
,
glm
::
mat4
&
view
,
glm
::
mat4
&
projection
)
{
...
...
@@ -84,6 +84,7 @@ void draw_objects(std::map<std::string, shader_ptr> &myShaders,
// Hardcoded light index
myShaders
[
shader_used
]
->
setVec3
(
"lightColor"
,
objects
[
1
]
->
getColor
());
myShaders
[
shader_used
]
->
setVec3
(
"lightPos"
,
obj_frames
[
1
]
->
getPosition
());
myShaders
[
shader_used
]
->
setVec3
(
"viewPos"
,
cam_frame
.
getPosition
());
}
glm
::
mat4
model
=
obj_frames
[
i
]
->
getModelMat
();
...
...
@@ -158,7 +159,7 @@ void gfx_draw(std::map<std::string, shader_ptr> &myShaders,
ASSUMPTION
(
glGetError
()
==
GL_NO_ERROR
);
// DRAW OBJECTS
draw_objects
(
myShaders
,
objects
,
obj_frames
,
view
,
projection
);
draw_objects
(
myShaders
,
cam_frame
,
objects
,
obj_frames
,
view
,
projection
);
// DRAW GRID
draw_grid
(
myShaders
,
grid
,
grid_frame
,
view
,
projection
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment