Fix/scale HDRI lighting by render.light.intensity - #3433
Conversation
|
\ci full |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3433 +/- ##
==========================================
+ Coverage 97.04% 97.12% +0.07%
==========================================
Files 216 216
Lines 18808 19041 +233
==========================================
+ Hits 18253 18494 +241
+ Misses 555 547 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
d926d1f to
0da41ff
Compare
|
Hello @Meakk, let me know if any changes are required. |
mwestphal
left a comment
There was a problem hiding this comment.
- Design needs improvements
- Missing test
- Missing doc update
Let us know if you have any questions!
What do you mean by that ? |
d7f0076 to
62d09c3
Compare
Design: moved the shader change into vtkF3DRenderPass (for GLES too), and update the uniform from UpdateLights instead of every frame in the mapper. I had HDRI baseline cases locally, but they were flaky on CI (cache path + GPU-specific baselines), so I dropped them. Happy to add a focused test if you have a preferred p |
that was about an earlier attempt to add HDRI regression images to So I removed those test cases from this PR. The existing light-intensity tests still pass, and I verified the HDRI behavior manually, if there is some other workaround pattern let me know pls |
We definitely need a test, please add one and we will see how it goes. |
|
The design looks correct :) |
|
@Meakk test changes are implemented, open for review :) |
|
@midaksh it looks like you are using AI to generate content in this pull request, please update your AI usage in the PR description and keep it accurate at all time at the risk of being banned. Also remove all mentions of co-authoring from AI agents, you are the sole owner of the code you submit, not the AI agent you use. |
Hi @mwestphal no AI generated code was pushed in any commits, there were just the commits that were pushed via Cursor all the code, testing and design/structure was done by me, I will update all that is needed and remove the automated co-auther thanks. |
You may want to fix that in your setup. |
When render.light.intensity is set (via L / Shift+L or the console), the HDRI image-based lighting (diffuse irradiance + specular reflections) was not affected, making it appear disconnected from all other lights. Fix by injecting an IBLIntensity uniform into the PBR fragment shader: - Shader substitution is done in vtkF3DRenderPass::PostReplaceShaderValues so it applies to both the standard OpenGL mapper and the GLES mapper used for web and Android builds. - IBLIntensity is pushed to each actor's fragment custom uniforms inside vtkF3DRenderer::UpdateLights, in the same !LightIntensitiesConfigured block that already scales the explicit VTK lights, so the uniform is updated only when the intensity actually changes — not every frame. - Both doc/user and doc/libf3d option descriptions updated to remove the "(except HDRI)" caveat. Closes f3d-app#3312
Add TestHDRILightIntensityZero and TestHDRILightIntensityBrighter to verify that render.light.intensity=0.0 blackens the HDRI ambient contribution and that render.light.intensity=5.0 brightens it. Both tests use the same suzanne.ply + shanghai_bund_1k.hdr setup and the same 0.07 threshold as TestHDRI to tolerate LUT precision differences on GLES. DEPENDS TestHDRI ensures the LUT cache is warm before either test runs. Fixes f3d-app#3312
65de868 to
8ec5f44
Compare
I have removed the co-auther also took your advice and changed the set up thanks :) |
| // VTK's //VTK::CustomUniforms::Dec mechanism then declares the uniform in the | ||
| // GLSL shader source. The actual GPU upload (glUniform1f) is already performed | ||
| // each frame by VTK's SetCustomUniforms, so this dict update is negligible. | ||
| // see https://github.com/f3d-app/f3d/issues/3312 |
Describe your changes
When HDRI ambient lighting is enabled (
-f/render.hdri.ambient), changingrender.light.intensity(console,L/Shift+L) only scaled the explicit VTK lights. The HDRI image-based lighting contribution in the PBR shader was left unchanged, so at intensity0the model could still look lit by the HDRI.This PR scales the IBL diffuse + specular terms by the same factor. The shader substitution is done in
vtkF3DRenderPass::PostReplaceShaderValues. TheIBLIntensityuniform is declared via VTK's//VTK::CustomUniforms::Decmechanism and is pushed to every actor invtkF3DRenderer::UpdateLightseach frame, so newly added actors always have it before their shader is compiled.Tests: Added
TestHDRILightIntensityZero(--light-intensity=0.0) andTestHDRILightIntensityBrighter(--light-intensity=5.0), using the samesuzanne.ply+shanghai_bund_1k.hdrsetup asTestHDRI, withDEPENDS TestHDRIand threshold0.07.Before (
master, bug)At intensity
0the figure is still lit by the HDRI.After (this branch, fixed)
At intensity
0the figure is black. At1it matches the previous default.At
5it is clearly brighter.How to test
open console(
Esc):With the console closed, L / Shift+L also change HDRI lighting live (same as explicit lights). You can confirm the value with:
Issue ticket number and link if any
Fixes: #3312
Checklist for finalizing the PR
.github/workflows/versions.json, I have updateddocker_timestampAI Disclosure
...
Continuous integration
Please write a comment to run CI, eg:
\ci fast.See here for more info.