trying to add better lighting
This commit is contained in:
1 parent
2b1fa60212
commit
ce888f5ac0
17 files changed
+129
-12362
No files matched your search
@@ -3,21 +3,61 @@ out vec4 fragColor;
|
||||
|
||||
|
||||
//uniform float light_power;
|
||||
//uniform vec3 lightColor;
|
||||
//uniform vec3 objectColor;
|
||||
//uniform vec3 viewPos;
|
||||
uniform vec3 lightColor;
|
||||
uniform vec3 objectColor;
|
||||
//uniform vec3 view_pos;
|
||||
|
||||
// in vec3 FragPos;
|
||||
//in vec3 Normal;
|
||||
//in vec3 LightPos;
|
||||
in vec3 FragPos;
|
||||
in vec3 Normal;
|
||||
in vec3 LightPos;
|
||||
|
||||
// const float light_power = 12.0;
|
||||
const float ambientStrength = 0.2;
|
||||
const float light_power = 12.0;
|
||||
const float ambientStrength = 0.1;
|
||||
const float shininess = 64.0;
|
||||
const float screenGamma = 2.2; // Assume the monitor is calibrated to the sRGB color space
|
||||
|
||||
void main()
|
||||
{
|
||||
fragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
// FragColor = vec4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
// fragColor = vec4(dot(LightPos, Normal) * lightColor, 1.0);
|
||||
vec3 norm = normalize(Normal);
|
||||
vec3 lightDir = normalize(LightPos - FragPos);
|
||||
|
||||
float diff = max(dot(norm, lightDir), 0.0);
|
||||
vec3 diffuse = diff * lightColor;
|
||||
|
||||
vec3 ambient = ambientStrength * lightColor;
|
||||
|
||||
fragColor = vec4((ambient + diffuse) * objectColor, 1.0);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user