mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 19:47:17 +02:00
LibGL+LibSoftGPU: Implement normalization of normals
* LibGL now supports the `GL_NORMALIZE` capability * LibSoftGPU transforms and normalizes the vertices' normals Normals are heavily used in texture coordinate generation, to be implemented in a future commit.
This commit is contained in:
committed by
Andreas Kling
parent
e056cf7e3f
commit
3a5f69b6f3
Notes:
sideshowbarker
2024-07-17 21:56:38 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/3a5f69b6f38 Pull-request: https://github.com/SerenityOS/serenity/pull/11496 Reviewed-by: https://github.com/sunverwerth ✅
@@ -524,7 +524,8 @@ DeviceInfo Device::info() const
|
||||
};
|
||||
}
|
||||
|
||||
void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const& transform, FloatMatrix4x4 const& texture_matrix, Vector<Vertex> const& vertices, Vector<size_t> const& enabled_texture_units)
|
||||
void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const& transform, FloatMatrix3x3 const& normal_transform,
|
||||
FloatMatrix4x4 const& texture_transform, Vector<Vertex> const& vertices, Vector<size_t> const& enabled_texture_units)
|
||||
{
|
||||
// At this point, the user has effectively specified that they are done with defining the geometry
|
||||
// of what they want to draw. We now need to do a few things (https://www.khronos.org/opengl/wiki/Rendering_Pipeline_Overview):
|
||||
@@ -675,8 +676,17 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
|
||||
continue;
|
||||
}
|
||||
|
||||
if (area > 0) {
|
||||
if (area > 0)
|
||||
swap(triangle.vertices[0], triangle.vertices[1]);
|
||||
|
||||
// Transform normals
|
||||
triangle.vertices[0].normal = normal_transform * triangle.vertices[0].normal;
|
||||
triangle.vertices[1].normal = normal_transform * triangle.vertices[1].normal;
|
||||
triangle.vertices[2].normal = normal_transform * triangle.vertices[2].normal;
|
||||
if (m_options.normalization_enabled) {
|
||||
triangle.vertices[0].normal.normalize();
|
||||
triangle.vertices[1].normal.normalize();
|
||||
triangle.vertices[2].normal.normalize();
|
||||
}
|
||||
|
||||
submit_triangle(triangle, enabled_texture_units);
|
||||
|
||||
Reference in New Issue
Block a user