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
8038a3bd
Commit
8038a3bd
authored
Jun 04, 2017
by
Browse files
Added minor functionality for LS
parent
0bdf6069
Changes
9
Hide whitespace changes
Inline
Side-by-side
assets/shaders/linespace/visualize/visualize.frag
0 → 100644
View file @
8038a3bd
#version 430
in
vec2
pass_texcoord
;
uniform
sampler2D
u_grid_texture
;
layout
(
location
=
0
)
out
vec4
out_final_color
;
void
main
()
{
out_final_color
=
vec4
(
1
,
1
,
1
,
texture
(
u_grid_texture
,
pass_texcoord
).
a
);
/*if (out_final_color.a < 0.9f)
discard;*/
}
\ No newline at end of file
assets/shaders/linespace/visualize/visualize.vert
0 → 100644
View file @
8038a3bd
#version 430
layout
(
location
=
0
)
in
vec4
in_position
;
layout
(
location
=
2
)
in
vec2
in_texcoord
;
uniform
mat4
u_model_view_projection
;
out
vec2
pass_texcoord
;
void
main
()
{
gl_Position
=
u_model_view_projection
*
in_position
;
pass_texcoord
=
in_texcoord
;
}
\ No newline at end of file
include/glare_advanced
View file @
8038a3bd
...
...
@@ -2,10 +2,8 @@
#define __GLARE_INCLUDE_ADVANCED
#include <advanced/IntersectionTests.h>
#include <advanced/KdTree.h>
#include <advanced/linespace/LineSpaceMath.h>
#include <advanced/linespace/LineSpaceMaskGenerator.h>
#include <advanced/tracer/RayGenerator.h>
#include <advanced/tracer/Raytracer.h>
...
...
src/executables/FullExecutable/Application.cpp
View file @
8038a3bd
...
...
@@ -2,6 +2,7 @@
#include
<engine/graphics/ImageTexture2DMultisample.h>
#include
<components/Rotator.h>
#include
<advanced/linespace/LineSpaceMath.h>
namespace
glare
{
...
...
@@ -46,13 +47,37 @@ namespace glare
//Create a skybox from cube map.
m_skybox
=
std
::
make_shared
<
core
::
Skybox
>
(
core
::
Skybox
::
collectFilesFrom
(
core
::
asset
(
"/textures/ryfjallet/"
)));
initializeScene
(
core
::
asset
(
"/meshes/s.dae"
),
1.
f
);
initializeScene
(
core
::
asset
(
"/meshes/s
cenery/Spheres
.dae"
),
1.
f
);
initializeRenderRequirements
();
initializeAdvanced
();
initializeGUI
();
gl
::
setEnabled
(
gl
::
EnableParameter
::
eMultisample
,
true
);
////////////////////////////////////////////////////////////////////////////////
/////
///// LS STUFF
/////
{
m_collector
->
collect
();
const
auto
&
mesh_collector
=
m_collector
->
meshCollectors
().
begin
()
->
second
;
math
::
UniformBoundsSubdivision
subdivision
(
mesh_collector
.
bounds
(),
20
);
size_t
lines
=
advanced
::
lsmath
::
calculateLineCount
(
subdivision
);
Log_Info
<<
subdivision
.
subdivisions
.
x
<<
"; "
<<
subdivision
.
subdivisions
.
y
<<
"; "
<<
subdivision
.
subdivisions
.
z
;
quitPromptDefault
(
0
);
}
/////
////////////////////////////////////////////////////////////////////////////////
glare
::
core
::
EngineState
::
opengl_core
->
loop
([
&
](
double
delta
)
{
//General state updates (camera and so on)
...
...
src/libraries/advanced/linespace/LineSpaceMath.cpp
View file @
8038a3bd
...
...
@@ -3,7 +3,34 @@ namespace glare
{
namespace
advanced
{
size_t
LineSpaceMath
::
calculateLineCount
(
math
::
UniformBoundsSubdivision
subdivision
)
unsigned
lsmath
::
faceAxis
(
Face
face
)
{
return
unsigned
(
face
)
/
2
;
}
size_t
lsmath
::
patchIndex
(
const
math
::
UniformBoundsSubdivision
&
subdivision
,
const
Patch
&
patch
)
{
float
offset_x
=
subdivision
.
subdivisions
.
y
*
subdivision
.
subdivisions
.
z
;
float
offset_y
=
subdivision
.
subdivisions
.
x
*
subdivision
.
subdivisions
.
z
;
float
offset_z
=
subdivision
.
subdivisions
.
x
*
subdivision
.
subdivisions
.
y
;
glm
::
uvec3
face_widths
=
{
subdivision
.
subdivisions
.
z
,
subdivision
.
subdivisions
.
x
,
subdivision
.
subdivisions
.
x
};
int
face_width
=
face_widths
[
faceAxis
(
patch
.
face
)];
size_t
patch_index_on_face
=
(
patch
.
index_vertical
*
face_width
+
patch
.
index_horizontal
)
*
targetPatchCount
(
subdivision
,
patch
.
face
);
}
size_t
lsmath
::
targetPatchCount
(
const
math
::
UniformBoundsSubdivision
&
subdivision
,
Face
face
)
{
return
subdivision
.
subdivisions
[((
unsigned
(
face
)
+
1
)
%
3
)]
*
subdivision
.
subdivisions
[((
unsigned
(
face
)
+
2
)
%
3
)]
+
//Opposite Face
2
*
subdivision
.
subdivisions
[((
unsigned
(
face
)
+
2
)
%
3
)]
*
subdivision
.
subdivisions
[((
unsigned
(
face
)
+
3
)
%
3
)]
+
//perpendicular Face
2
*
subdivision
.
subdivisions
[((
unsigned
(
face
)
+
3
)
%
3
)]
*
subdivision
.
subdivisions
[((
unsigned
(
face
)
+
4
)
%
3
)];
//Remaining Face
}
size_t
lsmath
::
calculateLineCount
(
const
math
::
UniformBoundsSubdivision
&
subdivision
)
{
return
((
subdivision
.
subdivisions
.
x
*
subdivision
.
subdivisions
.
y
*
2
*
(
subdivision
.
subdivisions
.
x
*
subdivision
.
subdivisions
.
z
+
subdivision
.
subdivisions
.
y
*
subdivision
.
subdivisions
.
z
))
+
subdivision
.
subdivisions
.
x
*
subdivision
.
subdivisions
.
y
*
subdivision
.
subdivisions
.
x
*
subdivision
.
subdivisions
.
y
...
...
src/libraries/advanced/linespace/LineSpaceMath.h
View file @
8038a3bd
...
...
@@ -7,9 +7,43 @@ namespace glare
{
namespace
advanced
{
namespace
LineSpaceM
ath
namespace
lsm
ath
{
size_t
calculateLineCount
(
math
::
UniformBoundsSubdivision
subdivision
);
enum
class
Face
:
uint32_t
{
ePosX
=
0
,
eNegX
=
1
,
ePosY
=
2
,
eNegY
=
3
,
ePosZ
=
4
,
eNegZ
=
5
};
struct
Patch
{
Patch
()
:
face
(
Face
::
ePosX
),
index
(
0
)
{}
Patch
(
Face
face
)
:
face
(
face
),
index
(
0
)
{}
Patch
(
Face
face
,
glm
::
uvec2
index
)
:
face
(
face
),
index
(
index
)
{}
Patch
(
Face
face
,
unsigned
id_horizontal
,
unsigned
id_vertical
)
:
face
(
face
),
index
(
id_horizontal
,
id_vertical
)
{}
Face
face
;
union
{
struct
{
unsigned
index_horizontal
;
unsigned
index_vertical
;
};
glm
::
uvec2
index
;
};
};
unsigned
faceAxis
(
Face
face
);
size_t
patchIndex
(
const
math
::
UniformBoundsSubdivision
&
subdivision
,
const
Patch
&
patch
);
size_t
targetPatchCount
(
const
math
::
UniformBoundsSubdivision
&
subdivision
,
Face
face
);
size_t
calculateLineCount
(
const
math
::
UniformBoundsSubdivision
&
subdivision
);
}
}
}
...
...
src/libraries/advanced/meshlocal/LocalCollector.cpp
View file @
8038a3bd
...
...
@@ -31,6 +31,8 @@ namespace glare
Triangle
triangle
;
for
(
int
index
=
0
;
index
<
3
;
index
++
)
{
triangle
.
indices
[
index
]
=
mesh
.
getMesh
()
->
getIndices
()[
i
+
index
];
m_bounds
.
expand
(
mesh
.
getMesh
()
->
getVertices
()[
mesh
.
getMesh
()
->
getIndices
()[
i
+
index
]].
position
);
}
triangle
.
material_id
=
0
;
...
...
src/libraries/engine/Math.cpp
View file @
8038a3bd
...
...
@@ -241,9 +241,9 @@ namespace glare
UniformBoundsSubdivision
::
UniformBoundsSubdivision
(
Bounds
bounds
,
int
max_subdivisions
)
{
int
largest_axis
=
bounds
.
largest
();
glm
::
vec3
size
=
bounds
.
size
().
xyz
+
glm
::
vec3
(
1e-5
f
);
float
largest_axis_value
=
glm
::
compMax
(
size
);
c
hi
ld_
size
=
largest_axis_value
/
float
(
max_subdivisions
);
glm
::
vec3
bounds_size
=
glm
::
max
(
glm
::
vec3
(
bounds
.
size
().
xyz
),
glm
::
vec3
(
1e-5
f
)
)
;
float
largest_axis_value
=
glm
::
compMax
(
bounds_
size
);
t
hi
s
->
size
=
largest_axis_value
/
float
(
max_subdivisions
);
subdivisions
=
glm
::
ivec3
(
0
);
subdivisions
[
largest_axis
]
=
max_subdivisions
;
...
...
@@ -251,11 +251,11 @@ namespace glare
for
(
unsigned
char
offset
=
1
;
offset
<
3
;
++
offset
)
{
unsigned
char
side
=
(
largest_axis
+
offset
)
%
3
;
float
side_size
=
size
[
side
];
float
side_size
=
bounds_
size
[
side
];
while
(
side_size
>
0
)
{
side_size
-=
c
hi
ld_
size
;
side_size
-=
t
hi
s
->
size
;
++
subdivisions
[
side
];
}
}
...
...
src/libraries/engine/Math.h
View file @
8038a3bd
...
...
@@ -242,14 +242,14 @@ namespace glare
struct
UniformBoundsSubdivision
{
UniformBoundsSubdivision
()
:
child_
size
(
0
)
UniformBoundsSubdivision
()
:
size
(
0
)
{
}
UniformBoundsSubdivision
(
Bounds
bounds
,
int
max_subdivisions
);
size_t
childCount
()
const
;
glm
::
ivec3
subdivisions
;
float
child_
size
;
float
size
;
};
template
<
typename
T
>
...
...
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