LibSoftGPU: Transform normals during T&L stage
As well as Vertex Positions, the normals also need to be transformed into eye-space so that lighting can be applied correctly.
This commit is contained in:
parent
4035532ee8
commit
5a1f559ed9
Notes:
sideshowbarker
2024-07-17 21:06:18 +09:00
Author: https://github.com/Quaker762 Commit: https://github.com/SerenityOS/serenity/commit/5a1f559ed93 Pull-request: https://github.com/SerenityOS/serenity/pull/11764 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/gmta Reviewed-by: https://github.com/linusg Reviewed-by: https://github.com/sunverwerth ✅
1 changed files with 5 additions and 0 deletions
|
@ -636,6 +636,11 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
|
|||
triangle.vertices[1].eye_coordinates = model_view_transform * triangle.vertices[1].position;
|
||||
triangle.vertices[2].eye_coordinates = model_view_transform * triangle.vertices[2].position;
|
||||
|
||||
// Transform the vertex normals into eye-space
|
||||
triangle.vertices[0].normal = transform_direction(model_view_transform, triangle.vertices[0].normal);
|
||||
triangle.vertices[1].normal = transform_direction(model_view_transform, triangle.vertices[1].normal);
|
||||
triangle.vertices[2].normal = transform_direction(model_view_transform, triangle.vertices[2].normal);
|
||||
|
||||
// Transform eye coordinates into clip coordinates using the projection transform
|
||||
triangle.vertices[0].clip_coordinates = projection_transform * triangle.vertices[0].eye_coordinates;
|
||||
triangle.vertices[1].clip_coordinates = projection_transform * triangle.vertices[1].eye_coordinates;
|
||||
|
|
Loading…
Add table
Reference in a new issue