-
Notifications
You must be signed in to change notification settings - Fork 230
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
1 parent
8b39ca1
commit 79e51d7
Showing
17 changed files
with
465 additions
and
358 deletions.
There are no files selected for viewing
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 @@ | ||
const float PI = 3.14159265359; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
bool PointInAABB(vec3 p_Point, vec3 p_AabbCenter, vec3 p_AabbHalfSize) | ||
{ | ||
return | ||
( | ||
p_Point.x > p_AabbCenter.x - p_AabbHalfSize.x && p_Point.x < p_AabbCenter.x + p_AabbHalfSize.x && | ||
p_Point.y > p_AabbCenter.y - p_AabbHalfSize.y && p_Point.y < p_AabbCenter.y + p_AabbHalfSize.y && | ||
p_Point.z > p_AabbCenter.z - p_AabbHalfSize.z && p_Point.z < p_AabbCenter.z + p_AabbHalfSize.z | ||
); | ||
} | ||
|
||
bool PointInSphere(vec3 p_Point, vec3 p_SphereCenter, float p_SphereRadius) | ||
{ | ||
return distance(p_Point, p_SphereCenter) <= p_SphereRadius; | ||
} |
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,55 @@ | ||
vec2 TRANSFORM_TEX_COORDS(vec2 texCoords, vec2 tiling, vec2 offset) | ||
{ | ||
return vec2(mod(texCoords.x * tiling.x, 1), mod(texCoords.y * tiling.y, 1)) + offset; | ||
} | ||
|
||
vec2 APPLY_PARALLAX_MAPPING(vec2 texCoords, sampler2D heightMap, vec3 tangentViewPos, vec3 tangentFragPos, float heightScale) | ||
{ | ||
if (heightScale > 0) | ||
{ | ||
const vec3 viewDir = normalize(tangentViewPos - tangentFragPos); | ||
const vec2 parallax = viewDir.xy * heightScale * texture(heightMap, texCoords).r; | ||
return texCoords - vec2(parallax.x, 1.0 - parallax.y); | ||
} | ||
|
||
return texCoords; | ||
} | ||
|
||
bool IS_MASKED(sampler2D maskMap, vec2 texCoords) | ||
{ | ||
return texture(maskMap, texCoords).r == 0.0; | ||
} | ||
|
||
mat3 COMPUTE_TBN(mat4 model, vec3 normal, vec3 tangent, vec3 bitangent) | ||
{ | ||
return mat3( | ||
normalize(vec3(model * vec4(tangent, 0.0))), | ||
normalize(vec3(model * vec4(bitangent, 0.0))), | ||
normalize(vec3(model * vec4(normal, 0.0))) | ||
); | ||
} | ||
|
||
vec3 UnPack(float p_Target) | ||
{ | ||
return vec3 | ||
( | ||
float((uint(p_Target) >> 24) & 0xff) * 0.003921568627451, | ||
float((uint(p_Target) >> 16) & 0xff) * 0.003921568627451, | ||
float((uint(p_Target) >> 8) & 0xff) * 0.003921568627451 | ||
); | ||
} | ||
|
||
vec3 COMPUTE_NORMAL(bool enableNormalMapping, vec2 texCoords, vec3 normal, sampler2D normalMap, mat3 TBN) | ||
{ | ||
if (enableNormalMapping) | ||
{ | ||
normal = texture(normalMap, texCoords).rgb; | ||
normal = normalize(normal * 2.0 - 1.0); | ||
normal = normalize(TBN * normal); | ||
return normal; | ||
} | ||
else | ||
{ | ||
return normalize(normal); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,58 @@ | ||
#shader vertex | ||
#include ":Shaders/Vertex/Basic.ovfxh" | ||
#version 430 core | ||
|
||
#include ":Shaders/Common/Buffers/EngineUBO.ovfxh" | ||
#include ":Shaders/Common/Utils.ovfxh" | ||
|
||
layout (location = 0) in vec3 geo_Pos; | ||
layout (location = 1) in vec2 geo_TexCoords; | ||
layout (location = 2) in vec3 geo_Normal; | ||
|
||
out VS_OUT | ||
{ | ||
vec3 FragPos; | ||
vec2 TexCoords; | ||
vec3 Normal; | ||
} vs_out; | ||
|
||
void main() | ||
{ | ||
vs_out.FragPos = vec3(ubo_Model * vec4(geo_Pos, 1.0)); | ||
vs_out.TexCoords = geo_TexCoords; | ||
vs_out.Normal = normalize(mat3(transpose(inverse(ubo_Model))) * geo_Normal); | ||
|
||
gl_Position = ubo_Projection * ubo_View * vec4(vs_out.FragPos, 1.0); | ||
} | ||
|
||
#shader fragment | ||
#include ":Shaders/Fragment/Lambert.ovfxh" | ||
#version 430 core | ||
|
||
#include ":Shaders/Common/Buffers/EngineUBO.ovfxh" | ||
#include ":Shaders/Common/Utils.ovfxh" | ||
#include ":Shaders/Lighting/Lambert.ovfxh" | ||
|
||
in VS_OUT | ||
{ | ||
vec3 FragPos; | ||
vec2 TexCoords; | ||
vec3 Normal; | ||
} fs_in; | ||
|
||
uniform vec4 u_Diffuse = vec4(1.0, 1.0, 1.0, 1.0); | ||
uniform sampler2D u_DiffuseMap; | ||
uniform vec2 u_TextureTiling = vec2(1.0, 1.0); | ||
uniform vec2 u_TextureOffset = vec2(0.0, 0.0); | ||
|
||
out vec4 FRAGMENT_COLOR; | ||
|
||
void main() | ||
{ | ||
vec2 texCoords = TRANSFORM_TEX_COORDS(fs_in.TexCoords, u_TextureTiling, u_TextureOffset); | ||
|
||
const vec3 kLightPosition = vec3(-9000.0, 10000.0, 11000.0); | ||
const vec3 kLightDiffuse = vec3(1.0); | ||
const vec3 kLightAmbient = vec3(0.3); | ||
const vec3 lambert = Lambert(fs_in.FragPos, fs_in.Normal, kLightPosition, kLightDiffuse, kLightAmbient); | ||
|
||
FRAGMENT_COLOR = texture(u_DiffuseMap, texCoords) * u_Diffuse * vec4(lambert, 1.0); | ||
} |
Oops, something went wrong.