-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
287 additions
and
209 deletions.
There are no files selected for viewing
Submodule engine
updated
12 files
+1 −1 | include/engine/Buffer.h | |
+29 −0 | include/engine/Framebuffer.h | |
+7 −0 | include/engine/Texture.h | |
+8 −5 | include/engine/Window.h | |
+3 −0 | include/engine/shader/ShaderProgram.h | |
+1 −1 | include/framework/Buffer.h | |
+16 −0 | include/framework/Framebuffer.h | |
+31 −0 | src/Framebuffer.cpp | |
+4 −0 | src/Texture.cpp | |
+4 −4 | src/framework/Buffer.cpp | |
+35 −0 | src/framework/Framebuffer.cpp | |
+8 −0 | src/shader/ShaderProgram.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
R"( | ||
#version 420 core | ||
out vec4 FragColor; | ||
|
||
void main() | ||
{ | ||
FragColor = vec4(1.0, 1.0, 0.0, 1.0); | ||
} | ||
)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
R"( | ||
#version 420 core | ||
layout (triangles) in; | ||
layout (line_strip, max_vertices = 6) out; | ||
|
||
in VS_OUT { | ||
vec3 normal; | ||
} gs_in[]; | ||
|
||
const float MAGNITUDE = 3.0; | ||
|
||
layout(std140) uniform camera { | ||
mat4 view; | ||
mat4 projection; | ||
}; | ||
|
||
void GenerateLine(int index) | ||
{ | ||
gl_Position = projection * gl_in[index].gl_Position; | ||
EmitVertex(); | ||
gl_Position = projection * (gl_in[index].gl_Position + | ||
vec4(gs_in[index].normal, 0.0) * MAGNITUDE); | ||
EmitVertex(); | ||
EndPrimitive(); | ||
} | ||
|
||
void main() | ||
{ | ||
GenerateLine(0); // first vertex normal | ||
GenerateLine(1); // second vertex normal | ||
GenerateLine(2); // third vertex normal | ||
} | ||
)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
R"( | ||
#version 420 core | ||
layout(location = 0) in vec3 in_position; | ||
layout(location = 1) in vec3 in_normal; | ||
layout(location = 2) in vec2 in_uv; | ||
layout(location = 3) in vec3 in_tangent; | ||
layout(location = 4) in vec3 in_bitangent; | ||
|
||
out VS_OUT { | ||
vec3 normal; | ||
} vs_out; | ||
|
||
uniform mat4 model; | ||
layout(std140) uniform camera { | ||
mat4 view; | ||
mat4 projection; | ||
}; | ||
|
||
void main() | ||
{ | ||
gl_Position = view * model * vec4(in_position, 1.0); | ||
mat3 normalMatrix = mat3(transpose(inverse(view * model))); | ||
vs_out.normal = normalize(vec3(vec4(normalMatrix * in_normal, 0.0))); | ||
} | ||
)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
R"( | ||
#version 420 core | ||
|
||
in VS_OUT { | ||
vec3 fragPos; | ||
vec2 uv; | ||
mat3 TBN; | ||
vec3 tangentLightDir; | ||
vec3 tangentViewPos; | ||
vec3 tangentFragPos; | ||
} fs_in; | ||
|
||
layout(binding=0) uniform sampler2D diffuseMap; | ||
layout(binding=1) uniform sampler2D normalMap; | ||
|
||
out vec4 fragColor; | ||
|
||
void main() { | ||
vec3 normal = texture(normalMap, fs_in.uv).rgb; | ||
normal = normalize(normal * 2.0 - 1.0); // this normal is in tangent space | ||
|
||
vec3 color = texture(diffuseMap, fs_in.uv).rgb; | ||
vec3 ambient = 0.1 * color; | ||
vec3 lightDir = fs_in.tangentLightDir; | ||
float diff = max(dot(lightDir, normal), 0.0); | ||
vec3 diffuse = diff * color; | ||
vec3 viewDir = normalize(fs_in.tangentViewPos - fs_in.tangentFragPos); | ||
vec3 reflectDir = reflect(-lightDir, normal); | ||
vec3 halfwayDir = normalize(lightDir + viewDir); | ||
float spec = pow(max(dot(normal, halfwayDir), 0.0), 32.0); | ||
|
||
vec3 specular = vec3(0.2) * spec; | ||
fragColor = vec4(ambient + diffuse + specular, 1.0); // + specular, 1.0); | ||
} | ||
)"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
R"( | ||
#version 420 core | ||
|
||
layout(location = 0) in vec3 in_position; | ||
layout(location = 1) in vec3 in_normal; | ||
layout(location = 2) in vec2 in_uv; | ||
layout(location = 3) in vec3 in_tangent; | ||
layout(location = 4) in vec3 in_bitangent; | ||
|
||
uniform mat4 model; | ||
layout(std140) uniform camera { | ||
mat4 view; | ||
mat4 projection; | ||
}; | ||
|
||
uniform uint time; | ||
|
||
out VS_OUT { | ||
vec3 fragPos; | ||
vec2 uv; | ||
mat3 TBN; | ||
vec3 tangentLightDir; | ||
vec3 tangentViewPos; | ||
vec3 tangentFragPos; | ||
} vs_out; | ||
|
||
void main() { | ||
vs_out.fragPos = vec3(model * vec4(in_position, 1.0)); | ||
vs_out.uv = in_uv; | ||
|
||
mat3 normalMatrix = transpose(inverse(mat3(model))); | ||
vec3 T = normalize(normalMatrix * in_tangent); | ||
vec3 N = normalize(normalMatrix * in_normal); | ||
T = normalize(T - dot(T, N) * N); | ||
vec3 B = cross(N, T); | ||
|
||
mat3 TBN = transpose(mat3(T, B, N)); | ||
vs_out.TBN = TBN; | ||
|
||
vec3 lightDir = normalize(vec3(sin(time * 0.001), 1.0, cos(time * 0.001))); | ||
vs_out.tangentLightDir = TBN * lightDir; | ||
vs_out.tangentViewPos = TBN * transpose(view)[3].xyz; | ||
vs_out.tangentFragPos = TBN * vs_out.fragPos; | ||
|
||
gl_Position = projection * view * model * vec4(in_position, 1.0); | ||
} | ||
)"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
R"( | ||
#version 420 core | ||
|
||
in vec2 texCoord; | ||
layout(binding = 1) uniform sampler2D groundTexture; | ||
|
||
out vec4 fragColor; | ||
|
||
void main() { | ||
fragColor = texture(groundTexture, texCoord*500); | ||
} | ||
)" |
Oops, something went wrong.