Skip to content

Commit 44ba4ef

Browse files
author
phillemann
committed
Fixed the fov, simplified overlay pass
1 parent c594710 commit 44ba4ef

23 files changed

+305
-234
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ graphics/camera/scoped.cpp)
9494
SET(texture_files textures/interpolators/bernstein_polynomial.cpp
9595
textures/weights.cpp
9696
textures/blend.cpp)
97-
SET(overlay_files overlay/object.cpp
98-
overlay/function_backend.cpp)
97+
SET(overlay_files overlay/object.cpp)
9998
SET(console_files console/streambuf.cpp
10099
console/object.cpp)
101100
SET(skydome_files
@@ -107,6 +106,7 @@ scene/instance.cpp
107106
scene/backend.cpp
108107
scene/manager.cpp
109108
scene/scoped_backend.cpp
109+
scene/function_backend.cpp
110110
scene/render_pass/scoped.cpp
111111
)
112112
SET(prop_files prop/instance.cpp

gizmo/to_mat4.hpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifndef INSULA_GIZMO_TO_MAT4_HPP_INCLUDED
2+
#define INSULA_GIZMO_TO_MAT4_HPP_INCLUDED
3+
4+
#include "rotation_to_mat4.hpp"
5+
#include "basic.hpp"
6+
#include <fcppt/math/matrix/translation.hpp>
7+
8+
namespace insula
9+
{
10+
namespace gizmo
11+
{
12+
template<typename T>
13+
typename
14+
fcppt::math::matrix::static_<T,4,4>::type
15+
to_mat4(
16+
gizmo::basic<T,3> const &g)
17+
{
18+
return
19+
rotation_to_mat4(g) *
20+
fcppt::math::matrix::translation(
21+
-g.position());
22+
}
23+
}
24+
}
25+
26+
#endif

height_map/object.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "../math/triangle/to_plane.hpp"
1616
#include "../scene/render_pass/object.hpp"
1717
#include "../shadow/object.hpp"
18+
#include "../gizmo/to_mat4.hpp"
1819
#include "vf/format.hpp"
1920
#include "vf/normal.hpp"
2021
#include "vf/vertex_view.hpp"
@@ -351,8 +352,9 @@ insula::height_map::object::begin(
351352

352353
shader_.set_uniform(
353354
"shadow_mvp",
354-
shadow_.mvp(
355-
camera_.perspective()));
355+
camera_.perspective() *
356+
gizmo::to_mat4(
357+
shadow_.gizmo()));
356358

357359
sge::renderer::scoped_vertex_buffer const scoped_vb_(
358360
renderer_,

machine.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include "media_path.hpp"
6262
// Config file end
6363
#include <fcppt/text.hpp>
64+
#include <fcppt/math/deg_to_rad.hpp>
6465
// Viewport hack begin
6566
#include <sge/renderer/viewport.hpp>
6667
#include <sge/renderer/pixel_pos.hpp>
@@ -130,9 +131,10 @@ insula::machine::machine(
130131
input_delegator_,
131132
sge::renderer::aspect<graphics::scalar>(
132133
systems_.renderer()->screen_size()),
133-
json::find_member<graphics::scalar>(
134-
config_file_,
135-
FCPPT_TEXT("camera/fov")),
134+
fcppt::math::deg_to_rad(
135+
json::find_member<graphics::scalar>(
136+
config_file_,
137+
FCPPT_TEXT("camera/fov"))),
136138
json::find_member<graphics::scalar>(
137139
config_file_,
138140
FCPPT_TEXT("camera/near")),

media/quad_fragment.glsl

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
$$$HEADER$$$
44
out vec4 frag_color;
5+
in vec4 screen_space;
56

67
void main()
78
{
89
frag_color =
910
texture2D(
1011
texture,
11-
gl_FragCoord.xy / screen_size);
12+
(screen_space / screen_space.w * 0.5 + 0.5).xy);
13+
//gl_FragCoord.xy / screen_size);
14+
// gl_FragCoord.xy / gl_FragCoord.w);
1215
}
1316

media/quad_vertex.glsl

+4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#version 140
22

33
$$$HEADER$$$
4+
out vec4 screen_space;
45

56
void main()
67
{
8+
gl_PointSize = float(screen_size);
9+
screen_space = mvp
10+
* vec4(position,1.0);
711
gl_Position =
812
mvp
913
* vec4(position,1.0);

media/skydome_fragment.glsl

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
#version 140
22

33
$$$HEADER$$$
4-
/*
5-
uniform vec3 sun_position;
6-
uniform vec3 color0;
7-
uniform vec3 color1;
8-
*/
94

5+
in vec3 gradient_color_interp;
6+
in vec3 position_interp;
107
out vec4 frag_color;
11-
in vec3 gradient_color;
12-
in float sun_intensity;
13-
in vec3 position_out;
148

159
const vec4 sun_color = vec4(1.0,1.0,0.91,1.0);
1610

1711
void main()
1812
{
19-
float sun_intensity = 1.0 - length(position_out - sun_position)/2;
13+
float sun_intensity = 1.0 - length(position_interp - sun_position)/2;
2014
sun_intensity = sun_intensity * sun_intensity * sun_intensity;
2115

2216
frag_color =
2317
mix(
24-
vec4(gradient_color,1.0),
18+
vec4(gradient_color_interp,1.0),
2519
sun_color,
2620
sun_intensity);
2721
}

media/skydome_vertex.glsl

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
#version 140
22

33
$$$HEADER$$$
4-
/*
5-
uniform mat4 mvp;
6-
uniform vec3 sun_position;
7-
uniform vec3 color0;
8-
uniform vec3 color1;
94

10-
in vec3 position;
11-
*/
12-
13-
out vec3 gradient_color;
14-
out float sun_intensity;
15-
out vec3 position_out;
5+
out vec3 gradient_color_interp;
6+
out vec3 position_interp;
167

178
const float ypos = 0.5;
189

@@ -24,13 +15,12 @@ void main()
2415
position - vec3(0,ypos,0),
2516
1.0);
2617

27-
gradient_color =
18+
gradient_color_interp =
2819
mix(
2920
color0,
3021
color1,
3122
position.y);
3223

33-
position_out = vec3(position);
34-
24+
position_interp = vec3(position);
3525
gl_Position = result;
3626
}

notizen.org

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Landschaftsgenerierung http://www.dungeonleague.com/page/2/
1111
- Neue AA-Methode: http://www.gamedev.net/community/forums/topic.asp?topic_id=580517
1212
- VSM, bestes Paper: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch08.html
13+
- Szenegraphen: http://www.realityprime.com/articles/scenegraphs-past-present-and-future
1314
* Konfigurationssystem
1415
- Alle Daten stehen in der json-Datei
1516
- Alle Subsysteme kriegen ein json-Objekt

overlay/function_backend.cpp

-34
This file was deleted.

overlay/function_backend.hpp

-55
This file was deleted.

0 commit comments

Comments
 (0)