-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UPBGE: Implement dynamic object ligthing layer. (#734)
Previously the ligthing of the objects based on a layer was fixed at the conversion time by the construction of BL_BlenderShader with the member m_lightLayer. Also because of the blender material managment the object layer was used only when binding the material and not when binding object dependent uniforms. The situation is changed firstly because the usage of one layer for all the object using the same material is totally wrong. Secondly the layers were not dynamic per object. To solve this situation the fastest way is to expose a layer into the shader, the function lamp_visible is designed for. It receives the lamp layer, object layer, lamp color and lamp energy and updates out color and energy if the lamp layer mask the object layer, to avoid branching the test computes a value of 0 or 1 and multiply the color and energy by it. The object layer is defined as a material builtin uniform and each GPULamp holds a dynlayer used as a dynamic uniform. At each call to GPU_material_bind_uniforms the object layer is updated. Concerning the lamps the dynlayer value is updated in a preparing stage before rendering any material, this stage intents to update the textures and the lamps. The main caller is RAS_BucketManager::PrepareBuckets calling for each material the Prepare function redirected to BL_BlenderShader::UpdateLights. This last function is calling GPU_material_update_lamps which over all lamps update the "dyn" value for color and matrices. Inside GPU_material_bind the lamp layer is computed. As it is not the only way to decide of the visibility of a lamp, if the lamp is hidden or the layer is set to 0, else if the lamp is not using a "layer only" option then all layers are enabled, else if the layer is not in the scene layer the layer is set to 0 else to the actual lamp object layer. As GPU_material_bind_uniforms now use the object layer, RAS_MeshUser store the layer of the object to allow BL_BlenderShader to get this value and send it to the GPU_ function. In the same time the calls to SetFrontFace are reduced to only updating when the object node transform changed. No performance win neither loss were noticed.
- Loading branch information
1 parent
ce3a765
commit c024480
Showing
22 changed files
with
233 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.