Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Johannes Braun
glare
Commits
26e57f29
Commit
26e57f29
authored
Jun 22, 2017
by
unknown
Browse files
Added checkbox to switch between LS and pure BVH
parent
628cda11
Changes
7
Hide whitespace changes
Inline
Side-by-side
assets/shaders/raytracer/mesh_bvh.glh
View file @
26e57f29
...
...
@@ -130,10 +130,12 @@ bool traverse(const in Mesh mesh, const in Ray local_ray, const in bool use_firs
#define ALT_LS
uniform bool u_use_ls;
bool bvh__nearestIntersection(const in Ray ray, inout Hit hit)
{
#
if
def ALT_LS
if
(u_use_ls){
float current_t = FLT_MAX;
float min_t = FLT_MAX;
bool hits = false;
...
...
@@ -144,7 +146,9 @@ bool bvh__nearestIntersection(const in Ray ray, inout Hit hit)
}
return hits;
#else
}
else
{
float current_t = FLT_MAX;
float min_t = FLT_MAX;
bool hits = false;
...
...
@@ -155,14 +159,24 @@ bool bvh__nearestIntersection(const in Ray ray, inout Hit hit)
}
return hits;
#endif
}
}
bool bvh__intersectsAny(const in Ray ray, const in float max_distance)
{
#ifdef ALT_LS
if(u_use_ls){
Hit unused_hit;
float current_t = max_distance;
for (int i = 0; i < b_meshes.length(); ++i)
{
Mesh mesh = b_meshes[i];
if (ls__traverse(mesh, ray__makeMeshLocal(ray, mesh), true, max_distance, unused_hit, current_t))
return true;
}
return false;
#else
}
else
{
Hit unused_hit;
float current_t = max_distance;
for (int i = 0; i < b_meshes.length(); ++i)
...
...
@@ -172,7 +186,7 @@ bool bvh__intersectsAny(const in Ray ray, const in float max_distance)
return true;
}
return false;
#endif
}
}
#endif //__GL_BVH
\ No newline at end of file
src/executables/FullExecutable/Application.cpp
View file @
26e57f29
...
...
@@ -48,7 +48,14 @@ namespace glare
//Create a skybox from cube map.
m_skybox
=
std
::
make_shared
<
core
::
Skybox
>
(
core
::
Skybox
::
collectFilesFrom
(
core
::
asset
(
"/textures/ryfjallet/"
)));
initializeScene
(
m_current_scene_root
/
"anotherone.dae"
,
1.
f
);
//initializeScene(m_current_scene_root / "benchmark_single_quad_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_single_cube_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_suzanne_x1_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_suzanne_x2_diff.dae", 1.f);
initializeScene
(
m_current_scene_root
/
"benchmark_stfd_bunny_diff.dae"
,
1.
f
);
//initializeScene(m_current_scene_root / "benchmark_stfd_armadillo_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_stfd_dragon_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_stfd_asian_dragon_diff.dae", 1.f);
initializeRenderRequirements
();
initializeAdvanced
();
initializeGUI
();
...
...
@@ -91,8 +98,12 @@ namespace glare
break;*/
case
AppRenderState
::
ePathtracer
:
{
core
::
ClockGL
::
instance
().
start
();
auto
&&
rt_texture
=
m_raytracer
->
render
(
m_config
.
window_width
,
m_config
.
window_height
);
m_texture_renderer_default
->
draw
(
rt_texture
);
Log_Info
<<
"Render took: "
<<
(
core
::
ClockGL
::
instance
().
end
()
/
1000000.
f
);
}
break
;
}
...
...
@@ -146,7 +157,7 @@ namespace glare
cam_node
->
makeComponent
<
component
::
PlayerController
>
();
m_scene_root
->
makeComponent
<
component
::
FramerateCounter
>
();
#define DEBUG__ADD_ROTATOR
#define DEBUG__ADD_ROTATOR
_x
#ifdef DEBUG__ADD_ROTATOR
if
(
auto
&&
node
=
m_scene_root
->
findFirstWithName
(
"#Suzanne_001-mesh"
))
{
node
->
addComponent
(
std
::
make_shared
<
component
::
Rotator
>
());
...
...
@@ -239,6 +250,8 @@ namespace glare
}
ImGui
::
EndGroup
();
ImGui
::
Checkbox
(
"Use LS"
,
&
m_raytracer
->
m_use_ls
);
ImGui
::
Value
(
"Current Sample"
,
m_raytracer
->
currentSamples
());
int
bounces
=
m_raytracer
->
bounces
();
...
...
src/libraries/advanced/tracer/Raytracer.cpp
View file @
26e57f29
...
...
@@ -122,6 +122,8 @@ namespace glare
m_render_shader
->
updateUniformInt
(
"u_environment.has"
,
0
);
}
m_render_shader
->
updateUniformInt
(
"u_use_ls"
,
int
(
m_use_ls
));
core
::
ClockGL
::
instance
().
start
();
m_render_shader
->
dispatchCompute2D
(
width
,
4
,
height
,
4
);
...
...
src/libraries/advanced/tracer/Raytracer.h
View file @
26e57f29
...
...
@@ -87,12 +87,14 @@ namespace glare
m_samples_per_frame
=
count
;
}
bool
m_use_ls
=
true
;
private:
uint32_t
m_last_width
=
0
;
uint32_t
m_last_height
=
0
;
unsigned
m_current_sample
=
0
;
unsigned
m_max_samples
=
80
;
unsigned
m_max_samples
=
80
000
;
unsigned
m_samples_per_frame
=
1
;
unsigned
m_bounces
=
1
;
...
...
src/libraries/engine/Time.cpp
View file @
26e57f29
#include
"Time.h"
#include
<gl/glew.h>
#include
<GLFW/glfw3.h>
#include
"Log.h"
#include
<numeric>
namespace
glare
{
namespace
core
{
double
Time
::
m_delta
;
double
Time
::
m_current
;
double
Time
::
m_last
;
double
Time
::
deltaTime
()
{
return
m_delta
;
}
double
Time
::
time
()
{
return
glfwGetTime
();
}
void
Time
::
newFrame
()
{
m_current
=
glfwGetTime
();
m_delta
=
m_current
-
m_last
;
m_last
=
m_current
;
}
void
Time
::
waste
()
{
for
(
int
i
=
0
;
i
<
std
::
numeric_limits
<
int
>::
max
();
i
++
)
{
Log_Info
<<
"Time wasted for the "
<<
i
<<
"th time."
;
}
}
#include
"Time.h"
#include
<gl/glew.h>
#include
<GLFW/glfw3.h>
#include
"Log.h"
#include
<numeric>
namespace
glare
{
namespace
core
{
double
Time
::
m_delta
;
double
Time
::
m_current
;
double
Time
::
m_last
;
double
Time
::
deltaTime
()
{
return
m_delta
;
}
double
Time
::
time
()
{
return
glfwGetTime
();
}
void
Time
::
newFrame
()
{
m_current
=
glfwGetTime
();
m_delta
=
m_current
-
m_last
;
m_last
=
m_current
;
}
void
Time
::
waste
()
{
for
(
int
i
=
0
;
i
<
std
::
numeric_limits
<
int
>::
max
();
i
++
)
{
Log_Info
<<
"Time wasted for the "
<<
i
<<
"th time."
;
}
}
ClockGL
::
ClockGL
()
{
Log_Debug
<<
"Constructing GPU_Clock instance..."
;
...
...
@@ -77,6 +77,6 @@ namespace glare
}
ClockGL
::~
ClockGL
()
{}
}
}
}
}
src/libraries/engine/Time.h
View file @
26e57f29
#ifndef __TIME_H
#define __TIME_H
#include
<opengl/OpenGL.h>
#include
<chrono>
#include
<vector>
#include
<stack>
namespace
glare
{
namespace
core
{
/**
* \brief Provides a globally accessible time control. The most useful functionality is probably the deltaTime() method.
*/
class
Time
{
public:
/**
* \brief Just returns the current frame's delta time. There is no update happening in this method.
* \return The current frame delta time.
*/
static
double
deltaTime
();
/**
* \brief Just returns the time since the application start. There is no update happening in this method.
* \return The current time since the application start.
*/
static
double
time
();
/**
* \brief This method should be called every frame to update the private members.
*/
static
void
newFrame
();
/**
* \brief Self-explainatory
*/
static
void
waste
();
private:
static
double
m_delta
;
static
double
m_current
;
static
double
m_last
;
};
/**
* \brief A small chrono wrapper. Useful for stop watches.
* \tparam Scale The std::chrono time scale.
*/
template
<
typename
Scale
=
std
::
chrono
::
milliseconds
>
class
Clock
{
public:
/**
* \brief Creates, but also starts this timer.
*/
Clock
();
~
Clock
();
/**
* \brief Reset the timer time to 0.
*/
long
restart
();
/**
* \return The time since the last restart.
*/
long
time
()
const
;
private:
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
m_duration
;
};
using
ClockS
=
Clock
<
std
::
chrono
::
seconds
>
;
using
ClockMS
=
Clock
<
std
::
chrono
::
milliseconds
>
;
using
ClockMicros
=
Clock
<
std
::
chrono
::
microseconds
>
;
using
ClockNS
=
Clock
<
std
::
chrono
::
nanoseconds
>
;
template
<
typename
Scale
>
Clock
<
Scale
>::
Clock
()
{
restart
();
}
template
<
typename
Scale
>
Clock
<
Scale
>::~
Clock
()
{
}
template
<
typename
Scale
>
long
Clock
<
Scale
>::
restart
()
{
long
old
=
long
(
std
::
chrono
::
duration_cast
<
Scale
>
(
std
::
chrono
::
system_clock
::
now
()
-
m_duration
).
count
());
m_duration
=
std
::
chrono
::
system_clock
::
now
();
return
old
;
}
template
<
typename
Scale
>
long
Clock
<
Scale
>::
time
()
const
{
return
long
(
std
::
chrono
::
duration_cast
<
Scale
>
(
std
::
chrono
::
system_clock
::
now
()
-
m_duration
).
count
());
}
#ifndef __TIME_H
#define __TIME_H
#include
<opengl/OpenGL.h>
#include
<chrono>
#include
<vector>
#include
<stack>
namespace
glare
{
namespace
core
{
/**
* \brief Provides a globally accessible time control. The most useful functionality is probably the deltaTime() method.
*/
class
Time
{
public:
/**
* \brief Just returns the current frame's delta time. There is no update happening in this method.
* \return The current frame delta time.
*/
static
double
deltaTime
();
/**
* \brief Just returns the time since the application start. There is no update happening in this method.
* \return The current time since the application start.
*/
static
double
time
();
/**
* \brief This method should be called every frame to update the private members.
*/
static
void
newFrame
();
/**
* \brief Self-explainatory
*/
static
void
waste
();
private:
static
double
m_delta
;
static
double
m_current
;
static
double
m_last
;
};
/**
* \brief A small chrono wrapper. Useful for stop watches.
* \tparam Scale The std::chrono time scale.
*/
template
<
typename
Scale
=
std
::
chrono
::
milliseconds
>
class
Clock
{
public:
/**
* \brief Creates, but also starts this timer.
*/
Clock
();
~
Clock
();
/**
* \brief Reset the timer time to 0.
*/
long
restart
();
/**
* \return The time since the last restart.
*/
long
time
()
const
;
private:
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
m_duration
;
};
using
ClockS
=
Clock
<
std
::
chrono
::
seconds
>
;
using
ClockMS
=
Clock
<
std
::
chrono
::
milliseconds
>
;
using
ClockMicros
=
Clock
<
std
::
chrono
::
microseconds
>
;
using
ClockNS
=
Clock
<
std
::
chrono
::
nanoseconds
>
;
template
<
typename
Scale
>
Clock
<
Scale
>::
Clock
()
{
restart
();
}
template
<
typename
Scale
>
Clock
<
Scale
>::~
Clock
()
{
}
template
<
typename
Scale
>
long
Clock
<
Scale
>::
restart
()
{
long
old
=
long
(
std
::
chrono
::
duration_cast
<
Scale
>
(
std
::
chrono
::
system_clock
::
now
()
-
m_duration
).
count
());
m_duration
=
std
::
chrono
::
system_clock
::
now
();
return
old
;
}
template
<
typename
Scale
>
long
Clock
<
Scale
>::
time
()
const
{
return
long
(
std
::
chrono
::
duration_cast
<
Scale
>
(
std
::
chrono
::
system_clock
::
now
()
-
m_duration
).
count
());
}
/**
* This Clock measures the time of any OpenGL-Calls executed in between of start() and end().
* end() also returns the time as an GLuint64 measured in nanoseconds.
...
...
@@ -179,8 +179,8 @@ namespace glare
std
::
vector
<
GLuint64
>
m_times
;
std
::
stack
<
int
>
m_start_indices
;
};
}
}
#endif //__TIME_H
}
}
#endif //__TIME_H
src/libraries/linespace/LineSpace.cpp
View file @
26e57f29
...
...
@@ -20,7 +20,7 @@ namespace glare
unsigned
goodSubdivision
(
size_t
polygon_count
,
glm
::
vec3
bounds_size
)
{
return
2
5
;
// unsigned(5 * glm::ceil(glm::log2(glm::max(size_t(2), polygon_count)) * glm::log(log2((glm::compMax(bounds_size) / glm::compMin(bounds_size)) + 2 * glm::e<float>()))));
return
2
0
;
// unsigned(5 * glm::ceil(glm::log2(glm::max(size_t(2), polygon_count)) * glm::log(log2((glm::compMax(bounds_size) / glm::compMin(bounds_size)) + 2 * glm::e<float>()))));
}
}
...
...
Write
Preview
Supports
Markdown
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