Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
edge-of-space
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dario Seyb
edge-of-space
Commits
c1208357
Commit
c1208357
authored
Feb 05, 2016
by
Dario Seyb
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GGJ2016 changes
parent
e81e2b02
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
67 additions
and
14 deletions
+67
-14
data/shader/CommonDeferredFrag.glsl
data/shader/CommonDeferredFrag.glsl
+3
-0
data/shader/CommonDeferredVert.glsl
data/shader/CommonDeferredVert.glsl
+3
-0
data/shader/PBR.fsh
data/shader/PBR.fsh
+4
-9
data/shader/Utils.glsl
data/shader/Utils.glsl
+4
-0
extern/acgl/include/ACGL/OpenGL/Data/GeometryDataLoadStore.hh
...rn/acgl/include/ACGL/OpenGL/Data/GeometryDataLoadStore.hh
+1
-1
extern/acgl/src/ACGL/OpenGL/Data/GeometryDataLoadStoreOBJ.cc
extern/acgl/src/ACGL/OpenGL/Data/GeometryDataLoadStoreOBJ.cc
+49
-2
src/game/src/engine/core/WindowSystem.cpp
src/game/src/engine/core/WindowSystem.cpp
+1
-1
src/game/src/engine/scene/scenes/AtmosphereTestScene.cpp
src/game/src/engine/scene/scenes/AtmosphereTestScene.cpp
+2
-1
No files found.
data/shader/CommonDeferredFrag.glsl
View file @
c1208357
...
...
@@ -2,18 +2,21 @@
#if LAST_SHADER == VERTEX
in
vec3
vNormal
;
in
vec3
vTangent
;
in
vec2
vTexCoord
;
in
vec3
vPosition
;
#endif
#if LAST_SHADER == TESSELATION
in
vec3
teNormal
;
in
vec3
teTangent
;
in
vec2
teTexCoord
;
in
vec3
tePosition
;
#endif
#if LAST_SHADER == GEOMETRY
in
vec3
gNormal
;
in
vec3
gTangent
;
in
vec2
gTexCoord
;
in
vec3
gPosition
;
in
vec3
gPatchDistance
;
...
...
data/shader/CommonDeferredVert.glsl
View file @
c1208357
...
...
@@ -7,10 +7,12 @@ uniform float uFar;
uniform
float
uTime
;
in
vec3
aNormal
;
in
vec3
aTangent
;
in
vec3
aPosition
;
in
vec2
aTexCoord
;
out
vec3
vNormal
;
out
vec3
vTangent
;
out
vec2
vTexCoord
;
out
vec3
vPosition
;
...
...
@@ -23,6 +25,7 @@ void main()
vNormal
=
normal
();
vTexCoord
=
texCoord
();
vPosition
=
position
();
vTangent
=
aTangent
;
gl_Position
=
uViewProjectionMatrix
*
vec4
(
vPosition
,
1
);
...
...
data/shader/PBR.fsh
View file @
c1208357
...
...
@@ -19,21 +19,16 @@ vec4 emissive() {
vec3 normal() {
if(false && uHasNormalMap) {
vec3 tangentNormal = unpackNormal(texture(uNormalMap, vTexCoord));
vec3 Q1 = dFdx(vPosition);
vec3 Q2 = dFdy(vPosition);
vec2 st1 = dFdx(vTexCoord);
vec2 st2 = dFdy(vTexCoord);
vec3 tangentNormal = unpackNormalTex(texture(uNormalMap, vTexCoord));
vec3 T = normalize(
Q1*st2.t - Q2*st1.
t);
vec3 B = normalize(
-Q1*st2.s + Q2*st1.s
);
vec3 T = normalize(
vTangen
t);
vec3 B = normalize(
cross(vNormal, vTangent)
);
// the transpose of texture-to-eye space matrix
mat3 TBN = mat3(T, B, vNormal);
// transform the normal to eye space
return
tangentNormal*TBN
;
return
TBN * tangentNormal
;
}
return vNormal;
}
...
...
data/shader/Utils.glsl
View file @
c1208357
#define M_PI 3.1415926535897932384626433832795
vec3
unpackNormalTex
(
vec4
tex
)
{
return
normalize
(
tex
.
xyz
*
2
.
0
-
vec3
(
1
.
0
));
}
vec3
unpackNormal
(
vec4
normalMotion
)
{
return
normalize
(
vec3
(
normalMotion
.
xy
,
sqrt
(
1
.
0
-
normalMotion
.
x
*
normalMotion
.
x
-
normalMotion
.
y
*
normalMotion
.
y
)));
}
\ No newline at end of file
extern/acgl/include/ACGL/OpenGL/Data/GeometryDataLoadStore.hh
View file @
c1208357
...
...
@@ -34,7 +34,7 @@ SharedGeometryData loadGeometryData(const std::string& _filename);
//! Loads from a Wavefront OBJ file. If _computeNormals and the mesh had no normals stored,
//! face normals are computed from the geometry
SharedGeometryData
loadGeometryDataFromOBJ
(
const
std
::
string
&
_filename
,
bool
_computeNormals
=
true
);
SharedGeometryData
loadGeometryDataFromOBJ
(
const
std
::
string
&
_filename
,
bool
_computeNormals
=
true
,
bool
_computeTangents
=
true
);
//! Loads data from an attribute ATB file. If no _attributeName is specified, it will be guessed
//! from the filename, e.g. /foo/bar/VertexColor.atb --> aVertexColor
...
...
extern/acgl/src/ACGL/OpenGL/Data/GeometryDataLoadStoreOBJ.cc
View file @
c1208357
...
...
@@ -144,7 +144,7 @@ namespace OpenGL{
// library specific load
///////////////////////////////////////////////////////////////////////////////////////////////////
SharedGeometryData
loadGeometryDataFromOBJ
(
const
std
::
string
&
_filename
,
bool
_computeNormals
)
SharedGeometryData
loadGeometryDataFromOBJ
(
const
std
::
string
&
_filename
,
bool
_computeNormals
,
bool
_computeTangents
)
{
char
*
currentLocale
;
currentLocale
=
setlocale
(
LC_NUMERIC
,
NULL
);
// store current locale
...
...
@@ -163,9 +163,11 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
GLenum
primitiveType
=
GL_INVALID_ENUM
;
bool
hasTexCoords
=
false
;
bool
hasNormals
=
false
;
bool
hasTangents
=
false
;
int
positionDimension
=
4
;
int
texCoordDimension
=
-
1
;
int
normalDimension
=
3
;
int
tangentDimension
=
3
;
std
::
vector
<
glm
::
vec4
>
positionData
;
std
::
vector
<
glm
::
vec3
>
texCoordData
;
...
...
@@ -346,10 +348,21 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
_computeNormals
=
false
;
}
if
(
!
hasTangents
&&
_computeTangents
)
{
// perform own per-face normal creation only if the model had no own normals!
if
(
primitiveType
!=
GL_TRIANGLES
||
!
hasNormals
||
!
hasTexCoords
)
{
warning
()
<<
"computing OBJ tangents is only supported for models with faces"
<<
std
::
endl
;
_computeTangents
=
false
;
}
else
{
debug
()
<<
"computing tangents"
<<
std
::
endl
;
hasTangents
=
true
;
}
}
// all data are read from the file. construct an ArrayBuffer from the data
data
=
SharedGeometryData
(
new
GeometryData
());
size_t
abDataElements
=
(
positionDimension
+
hasTexCoords
*
texCoordDimension
+
hasNormals
*
normalDimension
)
*
indices
.
size
();
size_t
abDataElements
=
(
positionDimension
+
hasTexCoords
*
texCoordDimension
+
hasNormals
*
normalDimension
+
hasTangents
*
tangentDimension
)
*
indices
.
size
();
GLfloat
*
abData
=
new
GLfloat
[
abDataElements
];
size_t
pos
=
0
;
...
...
@@ -393,6 +406,33 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
abData
[
pos
++
]
=
normal
.
z
;
}
}
if
(
_computeTangents
&&
hasNormals
&&
hasTexCoords
)
{
size_t
triangleIndex
=
i
/
3
;
glm
::
vec3
v0
=
(
glm
::
vec3
)
positionData
[
indices
[
3
*
triangleIndex
+
0
].
position
];
glm
::
vec3
v1
=
(
glm
::
vec3
)
positionData
[
indices
[
3
*
triangleIndex
+
1
].
position
];
glm
::
vec3
v2
=
(
glm
::
vec3
)
positionData
[
indices
[
3
*
triangleIndex
+
2
].
position
];
glm
::
vec3
uv0
=
(
glm
::
vec3
)
texCoordData
[
indices
[
3
*
triangleIndex
+
0
].
texCoord
];
glm
::
vec3
uv1
=
(
glm
::
vec3
)
texCoordData
[
indices
[
3
*
triangleIndex
+
1
].
texCoord
];
glm
::
vec3
uv2
=
(
glm
::
vec3
)
texCoordData
[
indices
[
3
*
triangleIndex
+
2
].
texCoord
];
// Edges of the triangle : postion delta
glm
::
vec3
deltaPos1
=
v1
-
v0
;
glm
::
vec3
deltaPos2
=
v2
-
v0
;
// UV delta
glm
::
vec3
deltaUV1
=
uv1
-
uv0
;
glm
::
vec3
deltaUV2
=
uv2
-
uv0
;
float
r
=
1.0
f
/
(
deltaUV1
.
x
*
deltaUV2
.
y
-
deltaUV1
.
y
*
deltaUV2
.
x
);
glm
::
vec3
tangent
=
(
deltaPos1
*
deltaUV2
.
y
-
deltaPos2
*
deltaUV1
.
y
)
*
r
;
abData
[
pos
++
]
=
tangent
.
x
;
abData
[
pos
++
]
=
tangent
.
y
;
abData
[
pos
++
]
=
tangent
.
z
;
}
}
size_t
strideSize
=
0
;
...
...
@@ -417,6 +457,13 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
data
->
mAttributes
.
push_back
(
attrNormal
);
}
if
(
hasTangents
)
{
ArrayBuffer
::
Attribute
attrTangent
=
{
"aTangent"
,
GL_FLOAT
,
tangentDimension
,
(
GLuint
)
strideSize
,
GL_FALSE
,
0
,
GL_FALSE
};
strideSize
+=
tangentDimension
*
sizeof
(
GLfloat
);
data
->
mAttributes
.
push_back
(
attrTangent
);
}
data
->
setStrideSize
(
(
GLsizei
)
strideSize
);
data
->
setSize
(
(
GLsizei
)
abDataElements
*
sizeof
(
GLfloat
));
data
->
setData
((
GLubyte
*
)
abData
);
...
...
src/game/src/engine/core/WindowSystem.cpp
View file @
c1208357
...
...
@@ -114,7 +114,7 @@ bool WindowSystem::createWindow() {
}
// Use Vsync
if
(
SDL_GL_SetSwapInterval
(
1
)
<
0
)
{
if
(
SDL_GL_SetSwapInterval
(
0
)
<
0
)
{
printf
(
"Warning: Unable to set VSync! SDL Error: %s
\n
"
,
SDL_GetError
());
}
...
...
src/game/src/engine/scene/scenes/AtmosphereTestScene.cpp
View file @
c1208357
...
...
@@ -82,8 +82,9 @@ bool AtmosphereTestScene::startup() {
m_renderer
->
setRenderPassActive
(
"Minimap"
_sh
,
false
);
m_renderer
->
addRenderPass
(
consoleCamera
,
"Console"
_sh
,
ScreenSpaceSize
::
HALF
);
m_renderer
->
setRenderPassActive
(
"Cockpit"
_sh
,
true
);
m_renderer
->
setRenderPassActive
(
"Console"
_sh
,
true
);
m_console
.
m_events
=
m_events
;
m_console
.
m_renderer
=
m_renderer
;
m_console
.
m_sceneGraph
=
m_sceneGraph
;
...
...
Dario Seyb
@dseyb
mentioned in commit
f4f017e5
·
Feb 05, 2016
mentioned in commit
f4f017e5
mentioned in commit f4f017e5afc9934120e0e9443c5f06aaa371b6c9
Toggle commit list
Write
Preview
Markdown
is supported
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