|
@@ -165,7 +165,7 @@ uniform vec3 light_direction;
|
|
|
uniform vec3 light_position;
|
|
|
|
|
|
uniform float light_range;
|
|
|
-uniform vec4 light_attenuation;
|
|
|
+uniform float light_attenuation;
|
|
|
|
|
|
// spot
|
|
|
uniform float light_spot_attenuation;
|
|
@@ -463,10 +463,15 @@ VERTEX_SHADER_CODE
|
|
|
|
|
|
float normalized_distance = light_length / light_range;
|
|
|
|
|
|
- float omni_attenuation = pow(1.0 - normalized_distance, light_attenuation.w);
|
|
|
+ if (normalized_distance < 1.0) {
|
|
|
|
|
|
- vec3 attenuation = vec3(omni_attenuation);
|
|
|
- light_att = vec3(omni_attenuation);
|
|
|
+ float omni_attenuation = pow(1.0 - normalized_distance, light_attenuation);
|
|
|
+
|
|
|
+ vec3 attenuation = vec3(omni_attenuation);
|
|
|
+ light_att = vec3(omni_attenuation);
|
|
|
+ } else {
|
|
|
+ light_att = vec3(0.0);
|
|
|
+ }
|
|
|
|
|
|
L = normalize(light_vec);
|
|
|
|
|
@@ -478,17 +483,30 @@ VERTEX_SHADER_CODE
|
|
|
float light_length = length(light_rel_vec);
|
|
|
float normalized_distance = light_length / light_range;
|
|
|
|
|
|
- float spot_attenuation = pow(1.0 - normalized_distance, light_attenuation.w);
|
|
|
- vec3 spot_dir = light_direction;
|
|
|
+ if (normalized_distance < 1.0) {
|
|
|
+
|
|
|
+ float spot_attenuation = pow(1.0 - normalized_distance, light_attenuation);
|
|
|
+ vec3 spot_dir = light_direction;
|
|
|
+
|
|
|
+ float spot_cutoff = light_spot_angle;
|
|
|
|
|
|
- float spot_cutoff = light_spot_angle;
|
|
|
+ float angle = dot(-normalize(light_rel_vec), spot_dir);
|
|
|
|
|
|
- float scos = max(dot(-normalize(light_rel_vec), spot_dir), spot_cutoff);
|
|
|
- float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - spot_cutoff));
|
|
|
+ if (angle > spot_cutoff) {
|
|
|
|
|
|
- spot_attenuation *= 1.0 - pow(spot_rim, light_spot_attenuation);
|
|
|
+ float scos = max(angle, spot_cutoff);
|
|
|
+ float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - spot_cutoff));
|
|
|
+
|
|
|
+ spot_attenuation *= 1.0 - pow(spot_rim, light_spot_attenuation);
|
|
|
+
|
|
|
+ light_att = vec3(spot_attenuation);
|
|
|
+ } else {
|
|
|
+ light_att=vec3(0.0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ light_att=vec3(0.0);
|
|
|
+ }
|
|
|
|
|
|
- light_att = vec3(spot_attenuation);
|
|
|
L = normalize(light_rel_vec);
|
|
|
|
|
|
#endif
|
|
@@ -814,7 +832,7 @@ uniform vec3 light_direction;
|
|
|
// omni
|
|
|
uniform vec3 light_position;
|
|
|
|
|
|
-uniform vec4 light_attenuation;
|
|
|
+uniform float light_attenuation;
|
|
|
|
|
|
// spot
|
|
|
uniform float light_spot_attenuation;
|
|
@@ -1267,6 +1285,7 @@ void main() {
|
|
|
float clearcoat_gloss = 0.0;
|
|
|
float anisotropy = 0.0;
|
|
|
vec2 anisotropy_flow = vec2(1.0, 0.0);
|
|
|
+ float sss_strength = 0.0; //unused
|
|
|
|
|
|
float alpha = 1.0;
|
|
|
float side = 1.0;
|
|
@@ -1474,10 +1493,14 @@ FRAGMENT_SHADER_CODE
|
|
|
float light_length = length(light_vec);
|
|
|
|
|
|
float normalized_distance = light_length / light_range;
|
|
|
+ if (normalized_distance < 1.0) {
|
|
|
|
|
|
- float omni_attenuation = pow(1.0 - normalized_distance, light_attenuation.w);
|
|
|
+ float omni_attenuation = pow(1.0 - normalized_distance, light_attenuation);
|
|
|
|
|
|
- light_att = vec3(omni_attenuation);
|
|
|
+ light_att = vec3(omni_attenuation);
|
|
|
+ } else {
|
|
|
+ light_att = vec3(0.0);
|
|
|
+ }
|
|
|
L = normalize(light_vec);
|
|
|
|
|
|
#endif
|
|
@@ -1643,17 +1666,25 @@ FRAGMENT_SHADER_CODE
|
|
|
float light_length = length(light_rel_vec);
|
|
|
float normalized_distance = light_length / light_range;
|
|
|
|
|
|
- float spot_attenuation = pow(1.0 - normalized_distance, light_attenuation.w);
|
|
|
- vec3 spot_dir = light_direction;
|
|
|
-
|
|
|
- float spot_cutoff = light_spot_angle;
|
|
|
+ if (normalized_distance < 1.0) {
|
|
|
+ float spot_attenuation = pow(1.0 - normalized_distance, light_attenuation);
|
|
|
+ vec3 spot_dir = light_direction;
|
|
|
|
|
|
- float scos = max(dot(-normalize(light_rel_vec), spot_dir), spot_cutoff);
|
|
|
- float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - spot_cutoff));
|
|
|
+ float spot_cutoff = light_spot_angle;
|
|
|
+ float angle = dot(-normalize(light_rel_vec), spot_dir);
|
|
|
|
|
|
- spot_attenuation *= 1.0 - pow(spot_rim, light_spot_attenuation);
|
|
|
+ if (angle > spot_cutoff) {
|
|
|
+ float scos = max(angle, spot_cutoff);
|
|
|
+ float spot_rim = max(0.0001, (1.0 - scos) / (1.0 - spot_cutoff));
|
|
|
+ spot_attenuation *= 1.0 - pow(spot_rim, light_spot_attenuation);
|
|
|
|
|
|
- light_att = vec3(spot_attenuation);
|
|
|
+ light_att = vec3(spot_attenuation);
|
|
|
+ } else {
|
|
|
+ light_att = vec3(0.0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ light_att = vec3(0.0);
|
|
|
+ }
|
|
|
|
|
|
L = normalize(light_rel_vec);
|
|
|
|