massive refactor

This commit is contained in:
JISAUAY committed 2024-09-24 17:00:18 -05:00
1 parent 26c0f433ae
commit e71a1a9b0b
14 files changed
+442 -275

No files matched your search

+7 -36
View File
@@ -2,14 +2,14 @@
out vec4 FragColor;
uniform float light_power;
uniform vec3 lightColor;
uniform vec3 objectColor;
uniform vec3 viewPos;
//uniform float light_power;
//uniform vec3 lightColor;
//uniform vec3 objectColor;
//uniform vec3 viewPos;
in vec3 FragPos;
in vec3 Normal;
in vec3 LightPos;
//in vec3 Normal;
//in vec3 LightPos;
// const float light_power = 12.0;
const float ambientStrength = 0.2;
@@ -18,35 +18,6 @@ const float screenGamma = 2.2; // Assume the monitor is calibrated to the sRGB c
void main()
{
// FragColor = vec4(1.0f, 0.0f, 0.0f, 1.0f);
vec3 lightDir = LightPos - FragPos;
float distance = length(lightDir);
vec3 norm = normalize(Normal);
vec3 ambient = ambientStrength * lightColor;
distance = distance * distance;
lightDir = normalize(lightDir);
float lambertian = max(dot(norm, lightDir), 0.0);
vec3 diffuse = lambertian * lightColor;
float specular = 0.0;
if (lambertian > 0.0)
{
vec3 viewDir = normalize(-FragPos);
vec3 halfDir = normalize(lightDir + viewDir);
float specAngle = max(dot(halfDir, norm), 0.0);
specular = pow(specAngle, shininess);
}
vec3 colorLinear = (ambient + (diffuse * light_power) + (specular * light_power)) * objectColor;
// vec3 colorGammaCorrected = pow(colorLinear, vec3(1.0 / screenGamma));
FragColor = vec4(colorLinear, 1.0);
// vec3 norm = normalize(Normal);
FragColor = vec4(1.0f, 0.0f, 0.0f, 1.0f);
}
+11 -10
View File
@@ -1,22 +1,23 @@
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
// layout (location = 1) in vec3 aNormal;
//layout (location = 1) in vec3 aColor;
uniform mat4 model;
uniform mat4 view;
// uniform mat4 model;
// uniform mat4 view;
uniform mat4 projection;
uniform vec3 lightPos;
// uniform vec3 lightPos;
out vec3 FragPos;
out vec3 Normal;
out vec3 LightPos;
// out vec3 Normal;
// out vec3 LightPos;
void main()
{
gl_Position = projection * view * model * vec4(aPos, 1.0);
FragPos = vec3(view * model * vec4(aPos, 1.0));
Normal = mat3(transpose(inverse(view * model))) * aNormal;
LightPos = vec3(view * vec4(lightPos, 1.0));
// * view * model
gl_Position = projection * vec4(aPos, 1.0);
FragPos = vec3(vec4(aPos, 1.0));
// Normal = mat3(transpose(inverse(view * model))) * aNormal;
// LightPos = vec3(view * vec4(lightPos, 1.0));
}