Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GameDevWeek
Sommersemester 2015
Cpp
Deth Buff Arr
Commits
08267fae
Commit
08267fae
authored
Sep 27, 2015
by
Georg Schaefer
Browse files
add somewhat dof
parent
208c4ad1
Changes
6
Hide whitespace changes
Inline
Side-by-side
assets/shader/dof.fs
0 → 100644
View file @
08267fae
#
version
330
in
vec2
texcoord_
;
uniform
sampler2D
albedo_texture
;
uniform
sampler2D
depth_texture
;
uniform
vec2
dof_scale
;
uniform
vec2
resolution
;
uniform
mat4
inv_projection
;
uniform
float
dof_plane
;
out
vec4
frag_color
;
void
main
()
{
float
depth
=
2
.
0
*
texture
(
depth_texture
,
gl_FragCoord
.
xy
/
resolution
).
x
-
1
.
0
;
vec3
clip_space
;
clip_space
.
xy
=
2
.
0
*
gl_FragCoord
.
xy
/
resolution
-
1
.
0
;
clip_space
.
z
=
depth
;
vec4
world_space
=
inv_projection
*
vec4
(
clip_space
,
1
.
0
);
vec3
p
=
world_space
.
xyz
/
world_space
.
w
;
vec4
color
=
vec4
(
0
.
0
);
if
(
p
.
z
<
-
dof_plane
)
{
color
+=
texture
(
albedo_texture
,
texcoord_
+
(
vec2
(-
3
.
f
)
*
dof_scale
.
xy
))
*
0
.
00598
f
;
color
+=
texture
(
albedo_texture
,
texcoord_
+
(
vec2
(-
2
.
f
)
*
dof_scale
.
xy
))
*
0
.
060626
f
;
color
+=
texture
(
albedo_texture
,
texcoord_
+
(
vec2
(-
1
.
f
)
*
dof_scale
.
xy
))
*
0
.
241843
f
;
color
+=
texture
(
albedo_texture
,
texcoord_
+
(
vec2
(
0
.
f
)
*
dof_scale
.
xy
))
*
0
.
383103
f
;
color
+=
texture
(
albedo_texture
,
texcoord_
+
(
vec2
(
1
.
f
)
*
dof_scale
.
xy
))
*
0
.
241843
f
;
color
+=
texture
(
albedo_texture
,
texcoord_
+
(
vec2
(
2
.
f
)
*
dof_scale
.
xy
))
*
0
.
060626
f
;
color
+=
texture
(
albedo_texture
,
texcoord_
+
(
vec2
(
3
.
f
)
*
dof_scale
.
xy
))
*
0
.
00598
f
;
}
else
{
color
=
texture
(
albedo_texture
,
texcoord_
);
}
frag_color
=
color
;
}
include/rendering/rendering_system.hpp
View file @
08267fae
...
...
@@ -74,6 +74,9 @@ namespace gdw {
mesh_ptr
traktor_beam_stripes_
;
std
::
vector
<
tractor_beam
>
tractor_beams_
;
program
dof_program_
;
framebuffer
dof_buffer_
;
vertex_layout
simple_render_layout_
;
program
simple_render_program_
;
vertex_buffer
simple_render_vbo_
;
...
...
@@ -143,7 +146,7 @@ namespace gdw {
void
blur_shadow_map
();
void
render_non_opauqe_geometry
(
float
delta_time
,
camera_component
&
camera
);
void
render_navMesh
(
camera_component
&
camera
);
void
render_final_image
();
void
render_final_image
(
camera_component
&
camera
);
void
register_component
(
camera_component
*
component
);
...
...
src/core/engine.cpp
View file @
08267fae
...
...
@@ -39,14 +39,14 @@ namespace gdw {
}
game_play_system_
=
make_unique
<
gdw
::
game_play_system
>
(
*
this
);
physics_system_
=
make_unique
<
gdw
::
physics_system
>
(
*
this
);
physics_system_
=
make_unique
<
gdw
::
physics_system
>
(
*
this
);
audio_
=
make_unique
<
gdw
::
audio
>
(
*
this
);
audioEventHandler_
=
make_unique
<
gdw
::
AudioEventHandler
>
(
*
this
);
graphics_system_
=
make_unique
<
gdw
::
graphics_system
>
(
*
this
);
input_
=
make_unique
<
gdw
::
input
>
(
*
this
);
rendering_system_
=
make_unique
<
gdw
::
rendering_system
>
(
*
this
);
ui_system_
=
make_unique
<
gdw
::
ui_system
>
(
*
this
);
game_state_machine_
=
make_unique
<
gdw
::
game_state_machine
>
(
*
this
);
game_state_machine_
=
make_unique
<
gdw
::
game_state_machine
>
(
*
this
);
}
engine
::~
engine
()
noexcept
{
...
...
@@ -56,13 +56,11 @@ namespace gdw {
void
engine
::
update
(
float
delta_time
)
{
physics_system_
->
update
(
1.
f
/
60.
f
);
//Update fix 60 Hz
game_state_machine_
->
update
(
delta_time
);
graphics_system_
->
begin
();
rendering_system_
->
update
(
delta_time
);
ui_system_
->
render
();
graphics_system_
->
end
(
delta_time
);
}
void
engine
::
run
()
{
...
...
src/gameplay/level_manager.cpp
View file @
08267fae
...
...
@@ -72,7 +72,7 @@ namespace gdw {
plane
.
scale
(
glm
::
vec3
(
5.
f
));
auto
&
planet
=
entity_manager
.
emplace_back
(
glm
::
vec3
(
80.
f
,
-
50.
f
,
-
100.
f
),
glm
::
angleAxis
(
glm
::
radians
(
0.
f
),
glm
::
vec3
(
0.
f
)),
glm
::
vec3
(
100.
f
));
//
planet.emplace_back<staticmesh_component>("mesh/planet.msh");
planet
.
emplace_back
<
staticmesh_component
>
(
"mesh/planet.msh"
);
auto
&
deathstar
=
entity_manager
.
emplace_back
(
glm
::
vec3
(
-
60.
f
,
-
20.
f
,
-
100.
f
),
glm
::
angleAxis
(
glm
::
radians
(
90.
f
),
glm
::
vec3
(
0.
f
,
1.
f
,
0.
f
)),
glm
::
vec3
(
10.
f
));
deathstar
.
emplace_back
<
staticmesh_component
>
(
"mesh/deathstar.msh"
);
...
...
src/rendering/rendering_system.cpp
View file @
08267fae
...
...
@@ -280,6 +280,25 @@ namespace gdw {
traktor_beam_program_
.
attach_shader
(
fragment_shader
);
staticmesh_layout_
.
setup_program
(
traktor_beam_program_
,
"frag_color"
);
traktor_beam_program_
.
link
();
vertex_shader
=
shader_manager
.
load
(
"shader/screen_quad.vs"
,
GL_VERTEX_SHADER
);
if
(
!
vertex_shader
)
{
throw
std
::
runtime_error
(
"could not load shader/creen_quad.vs"
);
}
dof_program_
.
attach_shader
(
vertex_shader
);
fragment_shader
=
shader_manager
.
load
(
"shader/dof.fs"
,
GL_FRAGMENT_SHADER
);
if
(
!
fragment_shader
)
{
throw
std
::
runtime_error
(
"could not load shader/dof.fs"
);
}
dof_program_
.
attach_shader
(
fragment_shader
);
staticmesh_layout_
.
setup_program
(
dof_program_
,
"frag_color"
);
dof_program_
.
link
();
dof_buffer_
.
attach
(
GL_DEPTH_ATTACHMENT
,
GL_TEXTURE_2D
,
GL_DEPTH_COMPONENT32F
,
width
,
height
,
GL_DEPTH_COMPONENT
,
GL_FLOAT
);
dof_buffer_
.
attach
(
GL_COLOR_ATTACHMENT0
,
GL_TEXTURE_2D
,
GL_RGBA32F
,
width
,
height
,
GL_RGBA
,
GL_FLOAT
);
dof_buffer_
.
bind
();
glDrawBuffers
(
2
,
shadow_buffers
);
framebuffer
::
bind_default
();
}
void
rendering_system
::
update
(
float
delta_time
)
{
...
...
@@ -303,7 +322,7 @@ namespace gdw {
render_gbuffer
(
delta_time
,
*
camera
);
render_lights
(
*
camera
);
render_non_opauqe_geometry
(
delta_time
,
*
camera
);
render_final_image
();
render_final_image
(
*
camera
);
if
(
engine_
.
getConfig
().
get
(
"navDebug"
,
true
))
render_navMesh
(
*
camera
);
...
...
@@ -727,15 +746,28 @@ namespace gdw {
glDisable
(
GL_CULL_FACE
);
}
void
rendering_system
::
render_final_image
()
{
frame
buffer
::
bind
_default
();
void
rendering_system
::
render_final_image
(
camera_component
&
camera
)
{
dof_
buffer
_
.
bind
();
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
screen_quad_program_
.
use
();
screen_quad_program_
.
uniform
(
"projection"
,
false
,
ortho_projection_
);
screen_quad_program_
.
uniform
(
"albedo_texture"
,
0
);
screen_quad_program_
.
uniform
(
"linearize"
,
false
);
auto
width
=
static_cast
<
float
>
(
engine_
.
graphics_system
().
width
());
auto
height
=
static_cast
<
float
>
(
engine_
.
graphics_system
().
height
());
dof_program_
.
use
();
dof_program_
.
uniform
(
"projection"
,
false
,
ortho_projection_
);
dof_program_
.
uniform
(
"albedo_texture"
,
0
);
dof_program_
.
uniform
(
"depth_texture"
,
1
);
dof_program_
.
uniform
(
"inv_projection"
,
false
,
glm
::
inverse
(
camera
.
projection
()));
dof_program_
.
uniform
(
"dof_plane"
,
30.
f
);
dof_program_
.
uniform
(
"dof_scale"
,
glm
::
vec2
(
1.
f
/
width
,
0.
f
));
dof_program_
.
uniform
(
"resolution"
,
glm
::
vec2
(
width
,
height
));
composition_buffer_
.
attachment
(
GL_COLOR_ATTACHMENT0
).
bind
(
0
);
g_buffer_
.
attachment
(
GL_DEPTH_ATTACHMENT
).
bind
(
1
);
screen_quad_
->
draw
();
framebuffer
::
bind_default
();
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
dof_program_
.
uniform
(
"dof_scale"
,
glm
::
vec2
(
0.
f
,
1.
f
/
height
));
screen_quad_
->
draw
();
}
...
...
mesh_converter
@
3d4dbe84
Compare
ad9ab973
...
3d4dbe84
Subproject commit
ad9ab973a17ebbf0471883a5d25d9f295c56af59
Subproject commit
3d4dbe849e8db70238497c1546f390aea8cf51bb
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