mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGL+LibSoftGPU: Calculate spotlight cutoff angle as degrees
We were storing the radians but never using that value in the GPU. We now directly use the degrees value.
This commit is contained in:
parent
8c28d167c9
commit
9d4c2f6308
Notes:
sideshowbarker
2024-07-17 20:59:47 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/9d4c2f63089 Pull-request: https://github.com/SerenityOS/serenity/pull/11851 Reviewed-by: https://github.com/Quaker762 ✅ Reviewed-by: https://github.com/sunverwerth ✅
3 changed files with 1 additions and 6 deletions
|
@ -3007,7 +3007,6 @@ void SoftwareGLContext::sync_light_state()
|
|||
light.spotlight_direction = current_light_state.spotlight_direction;
|
||||
light.spotlight_exponent = current_light_state.spotlight_exponent;
|
||||
light.spotlight_cutoff_angle = current_light_state.spotlight_cutoff_angle;
|
||||
light.spotlight_cutoff_angle_rads = current_light_state.spotlight_cutoff_angle_rads;
|
||||
light.constant_attenuation = current_light_state.constant_attenuation;
|
||||
light.linear_attenuation = current_light_state.linear_attenuation;
|
||||
light.quadratic_attenuation = current_light_state.quadratic_attenuation;
|
||||
|
@ -3119,7 +3118,6 @@ void SoftwareGLContext::gl_lightf(GLenum light, GLenum pname, GLfloat param)
|
|||
break;
|
||||
case GL_SPOT_CUTOFF:
|
||||
light_state.spotlight_cutoff_angle = param;
|
||||
light_state.spotlight_cutoff_angle_rads = param * (AK::Pi<float> / 180.0f);
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -3165,7 +3163,6 @@ void SoftwareGLContext::gl_lightfv(GLenum light, GLenum pname, GLfloat const* pa
|
|||
break;
|
||||
case GL_SPOT_CUTOFF:
|
||||
light_state.spotlight_cutoff_angle = *params;
|
||||
light_state.spotlight_cutoff_angle_rads = *params * (AK::Pi<float> / 180.0f);
|
||||
break;
|
||||
case GL_SPOT_DIRECTION: {
|
||||
FloatVector4 direction_vector = { params[0], params[1], params[2], 0.0f };
|
||||
|
|
|
@ -698,7 +698,7 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
|
|||
if (light.spotlight_cutoff_angle != 180.0f) {
|
||||
const auto spotlight_direction_normalized = light.spotlight_direction.normalized();
|
||||
const auto light_to_vertex_dot_normalized_spotlight_direction = spotlight_direction_normalized.dot(FloatVector3(vertex_to_light.x(), vertex_to_light.y(), vertex_to_light.z()));
|
||||
const auto cos_spotlight_cutoff = AK::cos<float>(light.spotlight_cutoff_angle);
|
||||
const auto cos_spotlight_cutoff = AK::cos<float>(light.spotlight_cutoff_angle * AK::Pi<float> / 180.f);
|
||||
|
||||
if (light_to_vertex_dot_normalized_spotlight_direction >= cos_spotlight_cutoff)
|
||||
spotlight_factor = AK::pow<float>(light_to_vertex_dot_normalized_spotlight_direction, light.spotlight_exponent);
|
||||
|
|
|
@ -28,8 +28,6 @@ struct Light {
|
|||
float constant_attenuation { 1.0f }; // This is referred to `k0i` in the OpenGL spec
|
||||
float linear_attenuation { 0.0f }; // This is referred to `k1i` in the OpenGL spec
|
||||
float quadratic_attenuation { 0.0f }; // This is referred to `k2i` in the OpenGL spec
|
||||
|
||||
float spotlight_cutoff_angle_rads { AK::Pi<float> / 180.0f };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue