assets/shaders/fragment/lighting.glsl in cyberarm_engine-0.23.0 vs assets/shaders/fragment/lighting.glsl in cyberarm_engine-0.24.0
- old
+ new
@@ -1,24 +1,25 @@
#version 330 core
-out vec4 FragColor;
+out vec4 frag_color;
@include "light_struct"
const int DIRECTIONAL = 0;
const int POINT = 1;
const int SPOT = 2;
-in vec2 outTexCoords;
-flat in Light outLight[1];
+flat in Light out_lights[7];
+in vec2 out_tex_coords;
+flat in int out_light_count;
uniform sampler2D diffuse, position, texcoord, normal, depth;
vec4 directionalLight(Light light) {
- vec3 norm = normalize(texture(normal, outTexCoords).rgb);
- vec3 diffuse_color = texture(diffuse, outTexCoords).rgb;
- vec3 fragPos = texture(position, outTexCoords).rgb;
+ vec3 norm = normalize(texture(normal, out_tex_coords).rgb);
+ vec3 diffuse_color = texture(diffuse, out_tex_coords).rgb;
+ vec3 frag_pos = texture(position, out_tex_coords).rgb;
- vec3 lightDir = normalize(light.position - fragPos);
+ vec3 lightDir = normalize(light.position - frag_pos);
float diff = max(dot(norm, lightDir), 0);
vec3 _ambient = light.ambient;
vec3 _diffuse = light.diffuse * diff;
vec3 _specular = light.specular;
@@ -57,7 +58,12 @@
return result;
}
void main() {
- FragColor = texture(diffuse, outTexCoords) * calculateLighting(outLight[0]);
-}
\ No newline at end of file
+ frag_color = vec4(0.0);
+
+ for(int i = 0; i < out_light_count; i++)
+ {
+ frag_color += texture(diffuse, out_tex_coords) * calculateLighting(out_lights[i]);
+ }
+}