aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders
diff options
context:
space:
mode:
authorLibravatar Silas Bartha <[email protected]>2024-11-26 16:32:19 -0500
committerLibravatar Silas Bartha <[email protected]>2024-11-26 16:32:19 -0500
commit8b5a8ce1efeedb4333e8f10364f6b916bd10c5d9 (patch)
tree97d2f93b3f942b934e58436f67d771a15168f9c8 /assets/shaders
parentafa8cad4cf778673633f95885f5da095ba96039f (diff)
Tue Nov 26 04:32:19 PM EST 2024
Diffstat (limited to 'assets/shaders')
-rw-r--r--assets/shaders/blacklight_material.wgsl9
1 files changed, 5 insertions, 4 deletions
diff --git a/assets/shaders/blacklight_material.wgsl b/assets/shaders/blacklight_material.wgsl
index 8807404..5879737 100644
--- a/assets/shaders/blacklight_material.wgsl
+++ b/assets/shaders/blacklight_material.wgsl
@@ -3,9 +3,9 @@
struct BlackLight {
position: vec3<f32>,
direction: vec3<f32>,
- color: vec4<f32>,
range: f32,
- radius: f32,
+ inner_angle: f32,
+ outer_angle: f32,
}
@group(2) @binding(0) var<storage> lights: array<BlackLight>;
@@ -21,8 +21,9 @@ fn fragment(
for (var i = u32(0); i < arrayLength(&lights); i = i+1) {
let light = lights[i];
let light_distance_squared = distance_squared(in.world_position.xyz, light.position);
- let light_arccosine = abs(acos(dot(normalize(light.direction), normalize(in.world_position.xyz - light.position)))) * radians(180.0);
- final_color = saturate(final_color + base_color * (inverse_falloff_radius(light_distance_squared / (light.range * light.range), 0.5) * inverse_falloff_radius(light_arccosine, 0.9)));
+ let light_arccosine = abs(acos(dot(normalize(light.direction), normalize(in.world_position.xyz - light.position))));
+ let angle_inner_factor = light.inner_angle/light.outer_angle;
+ final_color = saturate(final_color + base_color * (inverse_falloff_radius(light_distance_squared / (light.range * light.range), 0.5) * inverse_falloff_radius(light_arccosine / light.outer_angle, angle_inner_factor)));
}
return final_color;
}