1
0
Fork 0
fgdata/Shaders/lightspot-ALS.frag

70 lines
2.1 KiB
C++

// -*-C++-*-
uniform float eyerel_x1;
uniform float eyerel_y1;
uniform float eyerel_z1;
uniform float lightspot_r1;
uniform float lightspot_g1;
uniform float lightspot_b1;
uniform float eyerel_x2;
uniform float eyerel_y2;
uniform float eyerel_z2;
uniform float lightspot_r2;
uniform float lightspot_g2;
uniform float lightspot_b2;
uniform float eyerel_x3;
uniform float eyerel_y3;
uniform float eyerel_z3;
uniform float lightspot_r3;
uniform float lightspot_g3;
uniform float lightspot_b3;
uniform float eyerel_x4;
uniform float eyerel_y4;
uniform float eyerel_z4;
uniform float lightspot_r4;
uniform float lightspot_g4;
uniform float lightspot_b4;
uniform float eyerel_x5;
uniform float eyerel_y5;
uniform float eyerel_z5;
uniform float lightspot_r5;
uniform float lightspot_g5;
uniform float lightspot_b5;
uniform float lightspot_project1;
uniform float lightspot_project2;
uniform float lightspot_dir1;
uniform float lightspot_dir2;
uniform float lightspot_size1;
uniform float lightspot_size2;
uniform float lightspot_size3;
uniform float lightspot_size4;
uniform float lightspot_size5;
vec3 lightspot(vec3 relPos)
{
vec3 eye_rel = vec3 (eyerel_x1, eyerel_y1, eyerel_z1);
vec3 difference_vec = relPos - eye_rel;
mat2 rotMat = mat2 (cos(lightspot_dir1), sin(lightspot_dir1), -sin(lightspot_dir1), cos(lightspot_dir1));
difference_vec.xy = rotMat * difference_vec.xy;
difference_vec.x/= (1.0 + lightspot_project1);
float lightspot_arg = (1.0 - smoothstep(5.0, 15.0, length(difference_vec))) * (1.0 - 0.5* smoothstep(5.0, 15.0/(1.0+lightspot_project1), difference_vec.x));
vec3 lightspot_color = vec3 (lightspot_r1,lightspot_g1, lightspot_b1 ) * lightspot_arg;
eye_rel = vec3 (eyerel_x2, eyerel_y2, eyerel_z2);
lightspot_arg = (1.0 - smoothstep(0.0, 5.0, length(relPos - eye_rel)));
lightspot_color += vec3 (lightspot_r2,lightspot_g2, lightspot_b2 ) * lightspot_arg;
eye_rel = vec3 (eyerel_x3, eyerel_y3, eyerel_z3);
lightspot_arg = (1.0 - smoothstep(0.0, 5.0, length(relPos - eye_rel)));
lightspot_color += vec3 (lightspot_r3,lightspot_g3, lightspot_b3 ) * lightspot_arg;
return lightspot_color;
}