Skip to content

Commit 4eec634

Browse files
authored
StandardPBR is now Standard ->no more blinn-phong/lambert (#538)
* StandardPBR is now Standard ->no more blinn-phong/lambert * Removed lambert shader/material creation from asset browser * Cleaned up standard shader
1 parent dcb8b59 commit 4eec634

File tree

14 files changed

+225
-544
lines changed

14 files changed

+225
-544
lines changed

Resources/Editor/Models/Camera.fbx

-47.1 KB
Binary file not shown.

Resources/Engine/Materials/Default.ovmat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<root>
2-
<shader>:Shaders\StandardPBR.ovfx</shader>
2+
<shader>:Shaders\Standard.ovfx</shader>
33
<settings>
44
<support_orthographic>true</support_orthographic>
55
<support_perspective>true</support_perspective>

Resources/Engine/Shaders/Lambert.ovfx

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

Resources/Engine/Shaders/Lighting/BlinnPhong.ovfxh

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

Resources/Engine/Shaders/Lighting/Lambert.ovfxh

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

Resources/Engine/Shaders/Lighting/PBR.ovfxh

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,53 @@
1+
#include ":Shaders/Common/Buffers/LightsSSBO.ovfxh"
2+
#include ":Shaders/Common/Constants.ovfxh"
13
#include ":Shaders/Common/Physics.ovfxh"
24
#include ":Shaders/Common/Utils.ovfxh"
3-
#include ":Shaders/Common/Constants.ovfxh"
4-
#include ":Shaders/Common/Buffers/LightsSSBO.ovfxh"
5-
#include ":Shaders/Lighting/Shared.ovfxh"
5+
#include ":Shaders/Lighting/Shadow.ovfxh"
6+
7+
float LuminosityFromAttenuation(mat4 light, vec3 fragPos)
8+
{
9+
const vec3 lightPosition = light[0].rgb;
10+
const float constant = light[0][3];
11+
const float linear = light[1][3];
12+
const float quadratic = light[2][3];
13+
14+
const float distanceToLight = length(lightPosition - fragPos);
15+
const float attenuation = (constant + linear * distanceToLight + quadratic * (distanceToLight * distanceToLight));
16+
17+
return 1.0 / attenuation;
18+
}
19+
20+
vec3 ComputeAmbientBoxLight(mat4 light, vec3 fragPos)
21+
{
22+
const vec3 lightPosition = light[0].rgb;
23+
const vec3 lightColor = UnPack(light[2][0]);
24+
const float intensity = light[3][3];
25+
const vec3 size = vec3(light[0][3], light[1][3], light[2][3]);
26+
27+
return IsPointInAABB(fragPos, lightPosition, size) ? lightColor * intensity : vec3(0.0);
28+
}
29+
30+
vec3 ComputeAmbientSphereLight(mat4 light, vec3 fragPos)
31+
{
32+
const vec3 lightPosition = light[0].rgb;
33+
const vec3 lightColor = UnPack(light[2][0]);
34+
const float intensity = light[3][3];
35+
const float radius = light[0][3];
36+
37+
return IsPointInSphere(fragPos, lightPosition, radius) ? lightColor * intensity : vec3(0.0);
38+
}
639

740
float DistributionGGX(vec3 N, vec3 H, float roughness)
841
{
942
float a = roughness * roughness;
1043
float a2 = a * a;
1144
float NdotH = max(dot(N, H), 0.0);
1245
float NdotH2 = NdotH * NdotH;
13-
46+
1447
float num = a2;
1548
float denom = (NdotH2 * (a2 - 1.0) + 1.0);
1649
denom = PI * denom * denom;
17-
50+
1851
return num / denom;
1952
}
2053

@@ -25,7 +58,7 @@ float GeometrySchlickGGX(float NdotV, float roughness)
2558

2659
float num = NdotV;
2760
float denom = NdotV * (1.0 - k) + k;
28-
61+
2962
return num / denom;
3063
}
3164
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness)
@@ -34,33 +67,13 @@ float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness)
3467
float NdotL = max(dot(N, L), 0.0);
3568
float ggx2 = GeometrySchlickGGX(NdotV, roughness);
3669
float ggx1 = GeometrySchlickGGX(NdotL, roughness);
37-
70+
3871
return ggx1 * ggx2;
3972
}
4073

4174
vec3 FresnelSchlick(float cosTheta, vec3 F0)
4275
{
4376
return F0 + (1.0 - F0) * pow(1.0 - cosTheta, 5.0);
44-
}
45-
46-
vec3 ComputeAmbientBoxLight(mat4 light, vec3 fragPos)
47-
{
48-
const vec3 lightPosition = light[0].rgb;
49-
const vec3 lightColor = UnPack(light[2][0]);
50-
const float intensity = light[3][3];
51-
const vec3 size = vec3(light[0][3], light[1][3], light[2][3]);
52-
53-
return IsPointInAABB(fragPos, lightPosition, size) ? lightColor * intensity : vec3(0.0);
54-
}
55-
56-
vec3 ComputeAmbientSphereLight(mat4 light, vec3 fragPos)
57-
{
58-
const vec3 lightPosition = light[0].rgb;
59-
const vec3 lightColor = UnPack(light[2][0]);
60-
const float intensity = light[3][3];
61-
const float radius = light[0][3];
62-
63-
return IsPointInSphere(fragPos, lightPosition, radius) ? lightColor * intensity : vec3(0.0);
6477
}
6578

6679
vec3 PBRLightingModel(vec3 albedo, float metallic, float roughness, float ao, vec3 normal, vec3 viewPos, vec3 fragPos, sampler2D shadowMap, mat4 lightSpaceMatrix)
@@ -72,7 +85,7 @@ vec3 PBRLightingModel(vec3 albedo, float metallic, float roughness, float ao, ve
7285
const vec3 V = normalize(viewPos - fragPos);
7386

7487
const vec3 F0 = mix(vec3(0.04), albedo, metallic);
75-
88+
7689
// reflectance equation
7790
vec3 Lo = vec3(0.0);
7891
vec3 ambientSum = vec3(0.0);

Resources/Engine/Shaders/Lighting/Shared.ovfxh renamed to Resources/Engine/Shaders/Lighting/Shadow.ovfxh

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
float LuminosityFromAttenuation(mat4 light, vec3 fragPos)
2-
{
3-
const vec3 lightPosition = light[0].rgb;
4-
const float constant = light[0][3];
5-
const float linear = light[1][3];
6-
const float quadratic = light[2][3];
7-
8-
const float distanceToLight = length(lightPosition - fragPos);
9-
const float attenuation = (constant + linear * distanceToLight + quadratic * (distanceToLight * distanceToLight));
10-
11-
return 1.0 / attenuation;
12-
}
13-
141
float SampleShadow(sampler2D shadowMap, vec3 projCoords, float bias)
152
{
163
float depth = texture(shadowMap, projCoords.xy).r;

0 commit comments

Comments
 (0)