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
b73ca4de
Commit
b73ca4de
authored
Sep 10, 2017
by
Johannes Braun
Browse files
LS grid does not work particularily correctly yet.
parent
205b3018
Changes
7
Hide whitespace changes
Inline
Side-by-side
assets/imgui/config.ini
View file @
b73ca4de
...
...
@@ -4,7 +4,7 @@ Size=353,64
Collapsed
=
0
[Scene]
Pos
=
-
4
,66
Pos
=
-
5
,66
Size
=
352,837
Collapsed
=
0
...
...
assets/preferences/linespace_default.xml
View file @
b73ca4de
<linespace
version=
"1.0"
>
<item
name=
"subdivisions"
value=
"
25
"
/>
<item
name=
"subdivisions"
value=
"
6
"
/>
<item
name=
"radial-subdivision"
value=
"50"
/>
<item
name=
"generator"
value=
"gpu"
/>
</linespace>
assets/shaders/pathtracer/data/mesh_linespace.glsl
View file @
b73ca4de
...
...
@@ -134,10 +134,13 @@ bool traverseLineSpace(const in Mesh mesh, int index, const in Ray local_ray, co
int
face_tmin
;
int
face_tmax
;
// LS can be empty.
if
(
mesh
.
linespaces
[
index
].
line_count
==
0
)
return
false
;
Ray
loc
=
local_ray
;
loc
.
origin
+=
0
.
05
f
*
loc
.
direction
;
float
offset
=
-
1
.
f
;
//compMin(mesh.linespace.patch_size);
float
offset
=
0
;
//
-1.f;//compMin(mesh.linespace.patch_size);
Ray
offset_ray
=
local_ray
;
offset_ray
.
origin
+=
local_ray
.
direction
*
offset
;
...
...
@@ -163,7 +166,7 @@ bool traverseLineSpace(const in Mesh mesh, int index, const in Ray local_ray, co
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
){
if
(
nearest_distance
>
0
&&
max_distance
>
nearest_distance
&&
t
<
t_min
){
hit
=
nearer
;
t_min
=
t
;
//Found an intersected shaft. But we don't yet know whether it contains geometry, so look it up as a last step.
...
...
@@ -181,7 +184,7 @@ bool traverseLineSpace(const in Mesh mesh, int index, const in Ray local_ray, co
{
float
farthest_distance
=
t
-
offset
;
if
(
farthest_distance
>
0
&&
max_distance
>
farthest_distance
){
if
(
farthest_distance
>
0
&&
max_distance
>
farthest_distance
&&
t
<
t_min
){
hit
=
nearer
;
t_min
=
t
;
//Found an intersected shaft. But we don't yet know whether it contains geometry, so look it up as a last step.
...
...
assets/shaders/pathtracer/generators/bvh/bvh_raygenerator.comp
View file @
b73ca4de
...
...
@@ -31,5 +31,5 @@ void main()
vec2 random = settings.u_random_subpixel ? vec2(0, 0) : rand2D(random_seed + id, target_size.x*target_size.y);
traces_data[id].ray = u_camera.getRayFromPixel(vec2(gl_GlobalInvocationID.xy), random, vec2(target_size));
traces_data[id].hit.invalidate();
traces_data[id].ray.nearestIntersection(traces_data[id].hit,
tru
e);
traces_data[id].ray.nearestIntersection(traces_data[id].hit,
fals
e);
}
src/libraries/raytrace/data/linespace.cpp
View file @
b73ca4de
...
...
@@ -5,6 +5,7 @@
#include
<core/Time.h>
#include
<core/res/res.h>
#include
"pugixml/pugixml.hpp"
#include
<raytrace/intersect.h>
namespace
glare
::
raytrace
{
...
...
@@ -44,10 +45,36 @@ namespace glare::raytrace
{
Log_Info
<<
"Building Line Space for collector id "
<<
collector
.
id
()
<<
"..."
;
core
::
ClockGL
::
instance
().
start
();
m_bounds
=
collector
.
bounds
();
auto
grid
=
m_bounds
.
computeSubdivision
(
uniform_grid_subdivision
);
int
grid_index
=
uniform_grid_index
;
glm
::
vec3
grid_index_3d
;
grid_index_3d
.
x
=
grid_index
%
grid
.
resolution
.
x
;
grid_index
/=
grid
.
resolution
.
x
;
grid_index_3d
.
y
=
grid_index
%
grid
.
resolution
.
y
;
grid_index_3d
.
z
=
grid_index
/
grid
.
resolution
.
y
;
math
::
Bounds
replacement
;
replacement
.
min
=
m_bounds
.
min
+
glm
::
vec4
(
grid_index_3d
*
grid
.
size
,
0
);
replacement
.
max
=
replacement
.
min
+
glm
::
vec4
(
grid
.
size
,
0
);
m_bounds
=
replacement
;
m_subdivision
=
m_bounds
.
subdivide
(
max_subdivisions
);
m_filled
=
collector
.
triangles
().
cend
()
!=
std
::
find_if
(
collector
.
triangles
().
cbegin
(),
collector
.
triangles
().
cend
(),
[
this
,
&
collector
](
const
TriangleIDs
&
tri
)
{
math
::
Triangle
triangle
;
triangle
.
a
=
collector
.
vertices
()[
tri
.
indices
[
0
]].
position
;
triangle
.
b
=
collector
.
vertices
()[
tri
.
indices
[
1
]].
position
;
triangle
.
c
=
collector
.
vertices
()[
tri
.
indices
[
2
]].
position
;
return
intersect
::
intersects
(
triangle
,
m_bounds
);
});
// if LS does not contain any triangles, don't try to generate.
if
(
!
m_filled
)
return
;
switch
(
generator
)
{
default:
...
...
@@ -269,8 +296,8 @@ namespace glare::raytrace
data
.
bounds
=
m_bounds
;
data
.
patch_size
=
m_subdivision
.
size
;
data
.
resolution
=
m_subdivision
.
resolution
;
data
.
lines
=
m_line_buffer
.
residentAddress
();
data
.
line_count
=
lineCount
();
data
.
lines
=
m_filled
?
m_line_buffer
.
residentAddress
()
:
0
;
data
.
line_count
=
m_filled
?
lineCount
()
:
0
;
return
data
;
}
...
...
@@ -288,4 +315,4 @@ namespace glare::raytrace
{
return
m_subdivision
;
}
}
\ No newline at end of file
}
src/libraries/raytrace/data/linespace.h
View file @
b73ca4de
...
...
@@ -117,6 +117,7 @@ namespace glare::raytrace
math
::
Bounds
m_bounds
;
math
::
Subdivision
m_subdivision
;
core
::
Buffer
m_line_buffer
;
bool
m_filled
=
false
;
//Collection of startpatch-endpatch configurations for merging two loops
//in the generation process into one parallel loop.
...
...
src/libraries/raytrace/data/local_collector.cpp
View file @
b73ca4de
...
...
@@ -2,6 +2,7 @@
#include
<raytrace/data/linespace.h>
#include
<core/rendering/batch_renderer.h>
#include
<pugixml/pugixml.hpp>
namespace
glare
::
raytrace
{
...
...
@@ -56,11 +57,32 @@ namespace glare::raytrace
m_vertex_buffer
->
makeResident
(
gl
::
Access
::
eReadOnly
);
m_triangle_buffer
->
makeResident
(
gl
::
Access
::
eReadOnly
);
m_linespaces
.
resize
(
1
,
std
::
make_shared
<
Linespace
>
());
m_linespaces
[
0
]
->
generate
(
*
this
,
files
::
asset
(
"preferences/linespace_default.xml"
));
int
subdiv_grid
=
5
;
m_linespace_data
.
resize
(
1
);
m_linespace_data
[
0
]
=
m_linespaces
[
0
]
->
data
();
auto
subdiv
=
m_bounds
.
computeSubdivision
(
subdiv_grid
);
int
count
=
subdiv
.
resolution
.
x
*
subdiv
.
resolution
.
y
*
subdiv
.
resolution
.
z
;
pugi
::
xml_document
doc
;
doc
.
load_file
(
files
::
asset
(
"preferences/linespace_default.xml"
).
c_str
());
const
auto
&
linespace_tag
=
doc
.
child
(
"linespace"
);
const
int
max_subdivisions
=
linespace_tag
.
find_child_by_attribute
(
"item"
,
"name"
,
"subdivisions"
).
attribute
(
"value"
).
as_int
(
16
);
const
std
::
string
gen
=
linespace_tag
.
find_child_by_attribute
(
"item"
,
"name"
,
"generator"
).
attribute
(
"value"
).
as_string
(
"cpu"
);
const
Platform
generator
=
gen
==
"gpu"
?
Platform
::
eGPU
:
Platform
::
eCPU
;
m_linespaces
.
resize
(
count
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
m_linespaces
[
i
]
=
std
::
make_shared
<
Linespace
>
();
m_linespaces
[
i
]
->
generate
(
*
this
,
subdiv_grid
,
i
,
max_subdivisions
,
generator
);
}
m_linespace_data
.
resize
(
count
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
m_linespace_data
[
i
]
=
m_linespaces
[
i
]
->
data
();
}
m_linespace_buffer
.
upload
(
m_linespace_data
,
gl
::
BufferUsage
::
eDynamicDraw
);
}
...
...
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