Optimize IMB_alpha_under_color_float Function for Improved Clarity and Performance #112882

Closed
glitchy-virophage wants to merge 2 commits from (deleted):glitchy-virophage-patch-1 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
First-time contributor

Overview:

This pull request aims to optimize the IMB_alpha_under_color_float function in Blender by enhancing both its clarity and performance. The function is responsible for alpha compositing a rectangular region of floating-point pixel values with a specified background color. The optimization includes code improvements for readability while retaining the functionality.

Changes:

Improved Variable Names: The code now uses more descriptive variable names for increased readability.

Code Structure: Replaced the while loop with a for loop for better code organization.

Alpha Compositing Clarity: Replaced the custom madd_v3_v3fl function with explicit alpha compositing calculations for each color channel (R, G, B) to make the code more explicit.

Alpha Reset: Ensures that the alpha channel of each pixel is set to 1.0 after compositing, indicating full opacity.

Benchmark Results:

Benchmarking was performed using a high-quality model rendering scenario. Before the optimization, rendering the model took approximately 6 minutes and 21 seconds. After applying these changes, the rendering time reduced to just 4 minutes and 12 seconds. This substantial improvement demonstrates the positive impact of the optimization on performance.

Explanation:

The original function's purpose remains unchanged: it performs alpha compositing on a rectangular region of pixels with a given background color, accounting for pixel transparency. The optimization enhances code readability and maintainability while significantly improving rendering performance.

Testing:

This change has been tested by running relevant Blender tests, including scenarios with different input images, pixel dimensions, and background colors. The output images have been visually inspected to ensure that the compositing operation remains correct.

Performance Impact:

The benchmark results clearly indicate a substantial reduction in rendering time, from 6 minutes and 21 seconds to 4 minutes and 12 seconds, which can lead to faster workflows and more efficient resource utilization when working with high-quality models in Blender.

Related Issues:

This pull request is related to issue #[issue_number], where improvements to the IMB_alpha_under_color_float function were discussed.

Reviewer Checklist:

Verify that the code changes do not alter the core functionality of the IMB_alpha_under_color_float function.
Confirm that the code is well-documented and adheres to coding standards.
Assess the impact on code readability and maintainability.
Verify that the provided explanations and testing results are accurate.

 Optionally, conduct additional testing or performance profiling.

Additional Comments:

This optimization contributes to the overall codebase maintainability and provides a significant performance boost in rendering times. Feedback and suggestions are welcome.

Overview: This pull request aims to optimize the IMB_alpha_under_color_float function in Blender by enhancing both its clarity and performance. The function is responsible for alpha compositing a rectangular region of floating-point pixel values with a specified background color. The optimization includes code improvements for readability while retaining the functionality. Changes: Improved Variable Names: The code now uses more descriptive variable names for increased readability. Code Structure: Replaced the while loop with a for loop for better code organization. Alpha Compositing Clarity: Replaced the custom madd_v3_v3fl function with explicit alpha compositing calculations for each color channel (R, G, B) to make the code more explicit. Alpha Reset: Ensures that the alpha channel of each pixel is set to 1.0 after compositing, indicating full opacity. Benchmark Results: Benchmarking was performed using a high-quality model rendering scenario. Before the optimization, rendering the model took approximately 6 minutes and 21 seconds. After applying these changes, the rendering time reduced to just 4 minutes and 12 seconds. This substantial improvement demonstrates the positive impact of the optimization on performance. Explanation: The original function's purpose remains unchanged: it performs alpha compositing on a rectangular region of pixels with a given background color, accounting for pixel transparency. The optimization enhances code readability and maintainability while significantly improving rendering performance. Testing: This change has been tested by running relevant Blender tests, including scenarios with different input images, pixel dimensions, and background colors. The output images have been visually inspected to ensure that the compositing operation remains correct. Performance Impact: The benchmark results clearly indicate a substantial reduction in rendering time, from 6 minutes and 21 seconds to 4 minutes and 12 seconds, which can lead to faster workflows and more efficient resource utilization when working with high-quality models in Blender. Related Issues: This pull request is related to issue #[issue_number], where improvements to the IMB_alpha_under_color_float function were discussed. Reviewer Checklist: Verify that the code changes do not alter the core functionality of the IMB_alpha_under_color_float function. Confirm that the code is well-documented and adheres to coding standards. Assess the impact on code readability and maintainability. Verify that the provided explanations and testing results are accurate. Optionally, conduct additional testing or performance profiling. Additional Comments: This optimization contributes to the overall codebase maintainability and provides a significant performance boost in rendering times. Feedback and suggestions are welcome.
glitchy-virophage added 1 commit 2023-09-26 02:28:52 +02:00
Optimize IMB_alpha_under_color_float for performance and clarity
Iliya Katushenock added the
Interest
Images & Movies
label 2023-09-26 11:00:25 +02:00
Iliya Katushenock added this to the Core project 2023-09-26 11:00:47 +02:00
Author
First-time contributor

i did more testing this time not on performance mode, the original averaged out at 10 minutes and the modified build averaged at 5 minutes, i will do further tests using a different 3d model to see if this one happened to use this function alot more than most models

i did more testing this time not on performance mode, the original averaged out at 10 minutes and the modified build averaged at 5 minutes, i will do further tests using a different 3d model to see if this one happened to use this function alot more than most models
glitchy-virophage added 1 commit 2023-09-28 07:02:53 +02:00
i forgot to remove that, as it causes an error
Author
First-time contributor

in the previous version this const caused a build error and i accidentally copied the old one with the const

in the previous version this const caused a build error and i accidentally copied the old one with the const
Author
First-time contributor

ummmm, something is wrong, i tried reverting the function changes and the rendering was around 6 minutes, i havent changed anything else but it is faster than the installed one

ummmm, something is wrong, i tried reverting the function changes and the rendering was around 6 minutes, i havent changed anything else but it is faster than the installed one
Author
First-time contributor

after looking, that only difference i could think of was that i use make release which uses optimization flags, but i thought releases of blender would use make release, i will test this out

after looking, that only difference i could think of was that i use make release which uses optimization flags, but i thought releases of blender would use make release, i will test this out

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#112882
No description provided.