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
1b375f80
Commit
1b375f80
authored
Aug 22, 2017
by
Johannes Braun
Browse files
Fixes #36
parent
e78c388a
Changes
7
Hide whitespace changes
Inline
Side-by-side
assets/preferences/linespace_default.xml
View file @
1b375f80
<linespace
version=
"1.0"
>
<item
name=
"subdivisions"
value=
"2
2
"
/>
<item
name=
"subdivisions"
value=
"2
5
"
/>
<item
name=
"radial-subdivision"
value=
"50"
/>
<item
name=
"generator"
value=
"gpu"
/>
</linespace>
assets/shaders/pathtracer/data/mesh_linespace.glsl
View file @
1b375f80
...
...
@@ -134,7 +134,10 @@ bool traverseLineSpace(const in Mesh mesh, const in Ray local_ray, const in bool
int
face_tmin
;
int
face_tmax
;
float
offset
=
compMin
(
mesh
.
linespace
.
patch_size
);
Ray
loc
=
local_ray
;
loc
.
origin
+=
0
.
05
f
*
loc
.
direction
;
float
offset
=
-
1
.
f
;
//compMin(mesh.linespace.patch_size);
Ray
offset_ray
=
local_ray
;
offset_ray
.
origin
+=
local_ray
.
direction
*
offset
;
...
...
@@ -157,7 +160,7 @@ bool traverseLineSpace(const in Mesh mesh, const in Ray local_ray, const in bool
{
nearer
.
triangle
=
near_data
;
nearer
.
mesh
=
mesh
.
id
;
if
(
loc
al_ray
.
intersectsTrianglePlane
(
near_data
,
mesh
,
t
,
nearer
.
barycentric
.
x
,
nearer
.
barycentric
.
y
))
if
(
loc
.
intersectsTrianglePlane
(
near_data
,
mesh
,
t
,
nearer
.
barycentric
.
x
,
nearer
.
barycentric
.
y
))
{
float
nearest_distance
=
t
-
offset
;
if
(
nearest_distance
>
0
&&
max_distance
>
nearest_distance
){
...
...
@@ -174,7 +177,7 @@ bool traverseLineSpace(const in Mesh mesh, const in Ray local_ray, const in bool
{
nearer
.
triangle
=
near_data
;
nearer
.
mesh
=
mesh
.
id
;
if
(
loc
al_ray
.
intersectsTrianglePlane
(
near_data
,
mesh
,
t
,
nearer
.
barycentric
.
x
,
nearer
.
barycentric
.
y
))
if
(
loc
.
intersectsTrianglePlane
(
near_data
,
mesh
,
t
,
nearer
.
barycentric
.
x
,
nearer
.
barycentric
.
y
))
{
float
farthest_distance
=
t
-
offset
;
...
...
assets/shaders/pathtracer/pathtracer.comp
View file @
1b375f80
...
...
@@ -21,6 +21,7 @@ layout(local_size_variable) in;
layout(rgba32f) uniform image2D u_color_store;
layout(rgba32f) uniform image2D u_render_target;
uniform Environment u_environment;
uniform int random_seed;
subroutine uniform lightSample u_light_sample[4];
//Global properties for the pathtracer itself
...
...
@@ -120,7 +121,7 @@ bool shade(int id, inout vec3 radiance, uint bounce, out uint bsdf_id)
// generate a random sample on each bounce so there won't be any notifiable patterns
const vec2 base_random = vec2(ray.px, ray.py) - ivec2(floor(ray.px), floor(ray.py));
const ivec2 img_size = u_render_target.imageSize();
vec2 random_sample = rand2D(int(id + base_random.x * 60337 + base_random.y * 27487), img_size.x * img_size.y);
vec2 random_sample = rand2D(
random_seed +
int(id + base_random.x * 60337 + base_random.y * 27487)
+ int(bounce)
, img_size.x * img_size.y);
BSDFResult bsdf_result = material.computeBSDF(random_sample, vertex, ray);
...
...
src/executables/pathtracing/main.cpp
View file @
1b375f80
...
...
@@ -297,38 +297,41 @@ void drawSceneWindow()
ImGui
::
DragFloat3
(
"Scale"
,
reinterpret_cast
<
float
*>
(
&
(
selected_node
->
transform
.
scale
)),
0.01
f
);
break
;
case
2
:
// Components (if available)
selected_node
->
iterateComponentsStable
([](
core
::
SceneComponent
&
component
)
if
(
selected_node
)
{
ImGui
::
PushID
((
"component-"
+
std
::
to_string
(
component
.
id
())).
c_str
());
if
(
ImGui
::
CollapsingHeader
(
component
.
typeName
().
c_str
()))
selected_node
->
iterateComponentsStable
([](
core
::
SceneComponent
&
component
)
{
component
.
debugGui
();
if
(
ImGui
::
AntiFeatureButton
(
"Delete"
,
ImVec2
(
ImGui
::
GetC
on
t
ent
RegionAvailWidth
(),
24
)))
ImGui
::
PushID
((
"component-"
+
std
::
to_string
(
component
.
id
())).
c_str
());
if
(
ImGui
::
CollapsingHeader
(
comp
onent
.
typeName
().
c_str
(
)))
{
ImGui
::
OpenPopup
(
"del_comp"
);
}
if
(
ImGui
::
BeginPopup
(
"del_comp"
))
{
ImGui
::
Text
(
"Do you really want to delete this node?"
);
if
(
ImGui
::
AntiFeatureButton
(
"Yes"
))
component
.
debugGui
();
if
(
ImGui
::
AntiFeatureButton
(
"Delete"
,
ImVec2
(
ImGui
::
GetContentRegionAvailWidth
(),
24
)))
{
component
.
destroy
();
ImGui
::
CloseCurrentPopup
();
ImGui
::
OpenPopup
(
"del_comp"
);
}
ImGui
::
SameLine
();
if
(
ImGui
::
B
utton
(
"No
"
))
if
(
ImGui
::
B
eginPopup
(
"del_comp
"
))
{
ImGui
::
CloseCurrentPopup
();
ImGui
::
Text
(
"Do you really want to delete this node?"
);
if
(
ImGui
::
AntiFeatureButton
(
"Yes"
))
{
component
.
destroy
();
ImGui
::
CloseCurrentPopup
();
}
ImGui
::
SameLine
();
if
(
ImGui
::
Button
(
"No"
))
{
ImGui
::
CloseCurrentPopup
();
}
ImGui
::
EndPopup
();
}
ImGui
::
EndPopup
();
}
}
ImGui
::
PopID
();
ImGui
::
PopID
();
ImGui
::
Spacing
();
});
ImGui
::
Spacing
();
});
}
ImGui
::
Spacing
();
if
(
ImGui
::
FeatureButton
(
"Add..."
,
ImVec2
(
ImGui
::
GetContentRegionAvailWidth
(),
32
)))
...
...
src/libraries/core/graph/scene_node.h
View file @
1b375f80
...
...
@@ -30,12 +30,10 @@ namespace glare::core
math
::
Transform
transform
;
protected:
/**
* \brief Will get called when this node's transformation has changed.
*/
void
onTransform
()
override
;
void
onAttached
(
std
::
shared_ptr
<
SceneNode
>
node
)
override
;
void
onDetached
(
std
::
shared_ptr
<
SceneNode
>
node
)
override
;
void
onTransform
()
override
;
void
onDestroy
()
override
;
void
onStart
()
override
;
void
onActivate
()
override
;
...
...
@@ -47,6 +45,8 @@ namespace glare::core
void
onDraw
(
DrawMode
mode
=
DrawMode
::
eShaded
)
override
;
private:
// A helper method for not having to write the same lines of code again and again.
// Calls an entity function on each component and then passes the call to it's children.
template
<
typename
...
Args
>
void
callAndTraverse
(
void
(
Entity
::*
node_function
)(
Args
...),
Args
...
args
);
...
...
src/libraries/raytrace/tracer/pathtracer.cpp
View file @
1b375f80
...
...
@@ -175,6 +175,7 @@ namespace glare::raytrace
if
(
debug
.
print_render_times
)
core
::
ClockGL
::
instance
().
start
();
m_render_shader
->
use
();
m_render_shader
->
uniform
(
"u_render_config.current_sample"
,
m_render_config
.
current_sample
);
m_render_shader
->
uniform
(
"random_seed"
,
ray_generator
->
randomSeed
());
m_render_shader
->
dispatch2d
(
width
,
16
,
height
,
16
);
if
(
debug
.
print_render_times
)
Log_Hint
<<
"RENDER TIME [Trace and Bounce]: "
<<
core
::
ClockGL
::
instance
().
end
()
<<
" ns"
;
...
...
src/libraries/raytrace/tracer/raygenerator.h
View file @
1b375f80
...
...
@@ -33,9 +33,9 @@ namespace glare::raytrace
RayGenerator
()
:
m_last_generator_type
(
RayGeneratorType
::
eTrace
)
{}
void
generate
(
Pathtracer
&
pathtracer
);
static
int32_t
randomSeed
();
protected:
static
int32_t
randomSeed
();
void
generateTrace
(
Pathtracer
&
pathtracer
,
bool
updated_size
)
const
;
void
generateOpenGL
(
Pathtracer
&
pathtracer
,
bool
updated_size
)
const
;
...
...
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