Browse Source

add matching lights structure in test shader

main
cinnaboot 5 years ago
parent
commit
01cb752a70
  1. 28
      data/full_lighting.frag

28
data/full_lighting.frag

@ -20,14 +20,14 @@ struct PointLight
{
vec3 pos;
vec3 color;
float intensity;
uint intensity;
};
struct DirectionalLight
{
vec3 direction;
vec3 color;
float intensity;
uint intensity;
};
// FIXME: probably want a buffer-backed UBO for lights in case we have more
@ -35,14 +35,34 @@ struct DirectionalLight
//uniform PointLight lights[32];
// FIXME: hard-coded values for testing
const DirectionalLight dl1 =
DirectionalLight(vec3(-2, 1, 3), vec3(1,1,1), 1);
DirectionalLight(vec3(-2, 1, 3), vec3(1,1,1), 1u);
const vec4 ambient_color = vec4(0.1, 0.1, 0.1, 1);
const PointLight pl1 = PointLight(vec3(-20, 10, 30), vec3(1, 1, 1), 800);
const PointLight pl1 = PointLight(vec3(-20, 10, 30), vec3(1, 1, 1), 800u);
///
const uint NUM_LIGHTS = 32u;
layout (std140) uniform lights
{
uint active_p_lights;
uint max_p_lights;
uint active_d_lights;
uint max_d_lights;
PointLight p_lights[NUM_LIGHTS];
DirectionalLight d_lights[NUM_LIGHTS];
};
void main()
{
for (uint i = 0u; i < NUM_LIGHTS; i++) {
if (p_lights[i].pos.x > 0)
color.r = 128;
}
#if 1 // directional light
vec3 light_direction = normalize(dl1.direction);
float diffuse_factor = clamp(dot(frag_normal, light_direction), 0, 1);

Loading…
Cancel
Save