Skip to content

Commit d08d098

Browse files
updated formatting and fixed minors issues (#412)
1 parent c327fb0 commit d08d098

File tree

154 files changed

+1967
-2916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+1967
-2916
lines changed

.clang-format

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,40 @@ Language: Cpp
22
BasedOnStyle: Microsoft
33
AccessModifierOffset: -4
44
AlignAfterOpenBracket: AlwaysBreak
5-
AlignConsecutiveMacros: true # Only available in clang-format-10
6-
AlignConsecutiveAssignments: Consecutive
7-
AlignConsecutiveDeclarations: Consecutive
5+
BracedInitializerIndentWidth: 0
6+
AlignConsecutiveMacros: # Only available in clang-format-10
7+
Enabled: true
8+
AcrossEmptyLines: true
9+
AcrossComments: true
10+
AlignConsecutiveAssignments:
11+
Enabled: true
12+
AcrossEmptyLines: true
13+
AcrossComments: true
14+
AlignCompound: true
15+
# AlignFunctionDeclarations: true
16+
# AlignFunctionPointers: true
17+
PadOperators: true
18+
AlignConsecutiveDeclarations:
19+
Enabled: true
20+
AcrossEmptyLines: true
21+
AcrossComments: true
22+
# AlignFunctionDeclarations: true
23+
# AlignFunctionPointers: true
24+
PadOperators: true
825
AlignEscapedNewlines: Left
926
AlignOperands: true
1027
AlignTrailingComments: true
11-
# AlignArrayOfStructures: Left
28+
AlignEscapedNewlinesLeft: false
29+
# AlignConsecutiveFields: true
30+
AlignArrayOfStructures: Right
31+
1232
# AllowAllArgumentsOnNextLine: true # Only available in clang-format-10
1333
AllowAllConstructorInitializersOnNextLine: false # Only available in clang-format-10
1434
AllowAllParametersOfDeclarationOnNextLine: false # Only available in clang-format-10
1535
AllowShortBlocksOnASingleLine: Empty # Only available in clang-format-10
1636
AllowShortCaseLabelsOnASingleLine: false
1737
AllowShortFunctionsOnASingleLine: Empty
18-
AllowShortLambdasOnASingleLine: Empty # Only available in clang-format-10
38+
AllowShortLambdasOnASingleLine: All # Only available in clang-format-10
1939
AllowShortIfStatementsOnASingleLine: Never
2040
AllowShortLoopsOnASingleLine: false
2141
AlwaysBreakAfterDefinitionReturnType: None
@@ -50,7 +70,7 @@ BreakConstructorInitializersBeforeComma: false
5070
BreakConstructorInitializers: BeforeColon
5171
BreakAfterJavaFieldAnnotations: false
5272
BreakStringLiterals: true
53-
ColumnLimit: 180
73+
ColumnLimit: 570
5474
CommentPragmas: '^ IWYU pragma:'
5575
CompactNamespaces: false
5676
ConstructorInitializerAllOnOneLineOrOnePerLine: false
@@ -122,4 +142,3 @@ SpacesInSquareBrackets: false
122142
Standard: c++20
123143
TabWidth: 4
124144
UseTab: Never
125-

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ To only build the Launcher only, you can specify `-LauncherOnly` which will skip
7777
### Important Notes:
7878
- Setting `-RunBuilds` to `$false` will result to *only* generate the build directory.
7979
- Omitting `-Configuration` will result to generate and build for both `Debug` and `Release` versions.
80-
- Specifying `-ForceShaderRebuild` option will force the engine's shaders rebuilding.
8180

8281
## Dependencies
8382

Resources/Shaders/deferred_lighting.frag

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,97 +2,98 @@
22
#extension GL_GOOGLE_include_directive : require
33
#include "fragment_common.glsl"
44

5-
layout (location = 0) in vec2 TexCoord;
6-
layout (location = 1) in vec4 ViewPos;
5+
layout(location = 0) in vec2 TexCoord;
6+
layout(location = 1) in vec4 ViewPos;
77

8-
layout (std140, set = 0, binding = 6) readonly buffer DirectionalLightSB
8+
layout(std140, set = 0, binding = 6) readonly buffer DirectionalLightSB
99
{
10-
uint Count;
10+
uint Count;
1111
DirectionalLight Data[];
12-
} DirectionalLightBuffer;
12+
}
13+
DirectionalLightBuffer;
1314

14-
layout (std140, set = 0, binding = 7) readonly buffer PointLightSB
15+
layout(std140, set = 0, binding = 7) readonly buffer PointLightSB
1516
{
16-
uint Count;
17+
uint Count;
1718
PointLight Data[];
18-
} PointLightBuffer;
19+
}
20+
PointLightBuffer;
1921

20-
layout (std140, set = 0, binding = 8) readonly buffer SpotLightSB
22+
layout(std140, set = 0, binding = 8) readonly buffer SpotLightSB
2123
{
22-
uint Count;
24+
uint Count;
2325
SpotLight Data[];
24-
} SpotLightBuffer;
25-
26-
layout (set = 0, binding = 10) uniform sampler2D AlbedoSampler;
27-
layout (set = 0, binding = 11) uniform sampler2D PositionSampler;
28-
layout (set = 0, binding = 12) uniform sampler2D NormalSampler;
29-
layout (set = 0, binding = 13) uniform sampler2D SpecularSampler;
30-
26+
}
27+
SpotLightBuffer;
3128

32-
layout (location = 0) out vec4 OutColor;
29+
layout(set = 0, binding = 10) uniform sampler2D AlbedoSampler;
30+
layout(set = 0, binding = 11) uniform sampler2D PositionSampler;
31+
layout(set = 0, binding = 12) uniform sampler2D NormalSampler;
32+
layout(set = 0, binding = 13) uniform sampler2D SpecularSampler;
3333

34+
layout(location = 0) out vec4 OutColor;
3435

3536
vec3 ComputeDirectionalLight(DirectionalLight light, vec3 normal, vec3 viewDir, vec3 albedoMap, vec3 specularMap)
3637
{
37-
vec3 direction = light.Direction.xyz;
38+
vec3 direction = light.Direction.xyz;
3839

39-
vec3 lightDir = normalize(direction);
40-
vec3 ambient = light.Ambient.xyz * albedoMap;
40+
vec3 lightDir = normalize(direction);
41+
vec3 ambient = light.Ambient.xyz * albedoMap;
4142

42-
float diff = max(dot(normal, lightDir), 0.0);
43-
vec3 diffuse = diff * light.Diffuse.xyz * albedoMap;
43+
float diff = max(dot(normal, lightDir), 0.0);
44+
vec3 diffuse = diff * light.Diffuse.xyz * albedoMap;
4445

45-
vec3 reflectDir = reflect(-lightDir, normal);
46-
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 16);
47-
vec3 specular = spec * light.Specular.xyz * specularMap;
46+
vec3 reflectDir = reflect(-lightDir, normal);
47+
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 16);
48+
vec3 specular = spec * light.Specular.xyz * specularMap;
4849

4950
return vec3(ambient + diffuse + specular);
5051
}
5152

5253
vec3 ComputePointLight(PointLight light, vec3 normal, vec3 viewDir, vec4 fragPos, vec3 albedoMap, vec3 specularMap)
5354
{
54-
float dist = length(light.Position.xyz - fragPos.xyz);
55-
float attenuation = 1.0 / ( light.Constant + (light.Linear * dist) + (light.Quadratic * (dist * dist)) );
55+
float dist = length(light.Position.xyz - fragPos.xyz);
56+
float attenuation = 1.0 / (light.Constant + (light.Linear * dist) + (light.Quadratic * (dist * dist)));
5657

57-
vec3 lightDir = normalize(light.Position.xyz - fragPos.xyz);
58-
vec3 ambient = light.Ambient.xyz * albedoMap;
58+
vec3 lightDir = normalize(light.Position.xyz - fragPos.xyz);
59+
vec3 ambient = light.Ambient.xyz * albedoMap;
5960

60-
float diff = max(dot(normal, lightDir), 0.0);
61-
vec3 diffuse = diff * light.Diffuse.xyz * albedoMap;
61+
float diff = max(dot(normal, lightDir), 0.0);
62+
vec3 diffuse = diff * light.Diffuse.xyz * albedoMap;
6263

63-
vec3 reflectDir = reflect(-lightDir, normal);
64-
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 16); // todo : 16 should be replaced by material.shininess
65-
vec3 specular = spec * light.Specular.xyz * specularMap;
64+
vec3 reflectDir = reflect(-lightDir, normal);
65+
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 16); // todo : 16 should be replaced by material.shininess
66+
vec3 specular = spec * light.Specular.xyz * specularMap;
6667

67-
ambient *= attenuation;
68-
diffuse *= attenuation;
69-
specular *= attenuation;
68+
ambient *= attenuation;
69+
diffuse *= attenuation;
70+
specular *= attenuation;
7071

7172
return vec3(ambient + diffuse + specular);
7273
}
7374

7475
vec3 ComputeSpotLight(SpotLight light, vec3 normal, vec3 viewDir, vec3 fragPos, vec3 albedoMap, vec3 specularMap)
7576
{
76-
vec3 lightDir = normalize(light.Position.xyz - fragPos);
77-
vec3 direction = normalize(light.Direction.xyz);
78-
float theta = dot(lightDir, direction); // check if lighting is inside the spotlight cone
77+
vec3 lightDir = normalize(light.Position.xyz - fragPos);
78+
vec3 direction = normalize(light.Direction.xyz);
79+
float theta = dot(lightDir, direction); // check if lighting is inside the spotlight cone
7980

80-
if(theta > light.CutOff)
81+
if (theta > light.CutOff)
8182
{
82-
vec3 ambient = light.Ambient.xyz * albedoMap;
83+
vec3 ambient = light.Ambient.xyz * albedoMap;
8384

84-
float diff = max(dot(normal, lightDir), 0.0);
85-
vec3 diffuse = diff * light.Diffuse.xyz * albedoMap;
85+
float diff = max(dot(normal, lightDir), 0.0);
86+
vec3 diffuse = diff * light.Diffuse.xyz * albedoMap;
8687

87-
vec3 reflectDir = reflect(-lightDir, normal);
88-
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 16); // todo : 16 should be replaced by material.shininess
89-
vec3 specular = spec * light.Specular.xyz * specularMap;
88+
vec3 reflectDir = reflect(-lightDir, normal);
89+
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 16); // todo : 16 should be replaced by material.shininess
90+
vec3 specular = spec * light.Specular.xyz * specularMap;
9091

91-
float dist = length(light.Position.xyz - fragPos);
92-
float attenuation = 1.0 / ( light.Constant + (light.Linear * dist) + (light.Quadratic * (dist * dist)) );
92+
float dist = length(light.Position.xyz - fragPos);
93+
float attenuation = 1.0 / (light.Constant + (light.Linear * dist) + (light.Quadratic * (dist * dist)));
9394

94-
diffuse *= attenuation;
95-
specular *= attenuation;
95+
diffuse *= attenuation;
96+
specular *= attenuation;
9697

9798
return vec3(ambient + diffuse + specular);
9899
}
@@ -102,33 +103,32 @@ vec3 ComputeSpotLight(SpotLight light, vec3 normal, vec3 viewDir, vec3 fragPos,
102103
}
103104
}
104105

105-
106106
void main()
107107
{
108-
vec3 norm = texture( NormalSampler, TexCoord ).rgb;
109-
vec4 fragPos = texture( PositionSampler, TexCoord );
110-
vec3 albedo = texture( AlbedoSampler, TexCoord ).rgb;
111-
vec3 specular = texture( SpecularSampler, TexCoord ).rgb;
108+
vec3 norm = texture(NormalSampler, TexCoord).rgb;
109+
vec4 fragPos = texture(PositionSampler, TexCoord);
110+
vec3 albedo = texture(AlbedoSampler, TexCoord).rgb;
111+
vec3 specular = texture(SpecularSampler, TexCoord).rgb;
112112

113-
vec3 viewDir = normalize( ViewPos.xyz - fragPos.xyz);
113+
vec3 viewDir = normalize(ViewPos.xyz - fragPos.xyz);
114114

115115
vec3 lighting = vec3(0.0);
116-
for (uint i = 0; i < DirectionalLightBuffer.Count; ++i)
116+
for (uint i = 0; i < DirectionalLightBuffer.Count; ++i)
117117
{
118-
DirectionalLight directionalLight = DirectionalLightBuffer.Data[i];
119-
lighting += ComputeDirectionalLight(directionalLight, norm, viewDir, albedo, specular);
118+
DirectionalLight directionalLight = DirectionalLightBuffer.Data[i];
119+
lighting += ComputeDirectionalLight(directionalLight, norm, viewDir, albedo, specular);
120120
}
121121

122122
for (uint i = 0; i < PointLightBuffer.Count; ++i)
123123
{
124-
PointLight pointLight = PointLightBuffer.Data[i];
125-
lighting += ComputePointLight(pointLight, norm, viewDir, fragPos, albedo, specular);
124+
PointLight pointLight = PointLightBuffer.Data[i];
125+
lighting += ComputePointLight(pointLight, norm, viewDir, fragPos, albedo, specular);
126126
}
127127

128128
for (uint i = 0; i < SpotLightBuffer.Count; ++i)
129129
{
130-
SpotLight spotLight = SpotLightBuffer.Data[i];
131-
lighting += ComputeSpotLight(spotLight, norm, viewDir, fragPos.xyz, albedo, specular);
130+
SpotLight spotLight = SpotLightBuffer.Data[i];
131+
lighting += ComputeSpotLight(spotLight, norm, viewDir, fragPos.xyz, albedo, specular);
132132
}
133133

134134
OutColor = vec4(lighting, 1.0);

Resources/Shaders/deferred_lighting.vert

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
#extension GL_GOOGLE_include_directive : require
33
#include "vertex_common.glsl"
44

5-
layout (location = 0) out vec2 TexCoord;
6-
layout (location = 1) out vec4 ViewPos;
5+
layout(location = 0) out vec2 TexCoord;
6+
layout(location = 1) out vec4 ViewPos;
77

88
void main()
99
{
1010
DrawDataView dataView = GetDrawDataView();
1111

12-
vec4 worldPos = dataView.Transform * dataView.Vertex;
13-
ViewPos = Camera.Position;
14-
gl_Position = Camera.Projection * Camera.View * worldPos;
12+
vec4 worldPos = dataView.Transform * dataView.Vertex;
13+
ViewPos = Camera.Position;
14+
gl_Position = Camera.Projection * Camera.View * worldPos;
1515
// Convert gl_Position from NDC [-1, 1] to texture coordinates [0, 1]
16-
TexCoord = (gl_Position.xy / gl_Position.w) * 0.5 + 0.5;
16+
TexCoord = (gl_Position.xy / gl_Position.w) * 0.5 + 0.5;
1717
}

Resources/Shaders/depth_prepass_scene.vert

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
void main()
66
{
7-
DrawDataView dataView = GetDrawDataView();
8-
vec4 worldPosition = dataView.Transform * dataView.Vertex;
9-
gl_Position = Camera.Projection * Camera.View * worldPosition;
7+
DrawDataView dataView = GetDrawDataView();
8+
vec4 worldPosition = dataView.Transform * dataView.Vertex;
9+
gl_Position = Camera.Projection * Camera.View * worldPosition;
1010
}

Resources/Shaders/final_color.frag.txt

Lines changed: 0 additions & 56 deletions
This file was deleted.

Resources/Shaders/final_color.vert.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)