-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--[PBR Update 2 of 3] PBR rewrite-motivated default lighting and IBL fix/reworking #2119
Conversation
One thing to note : any existing dataset that has lighting configs defined and is intended for PBR shading will probably need those lights adjusted. AFAIK ReplicaCAD is the only dataset currently that would need this rebalancing, but I'm not sure. @aclegg3 ? Edit : I've renormalized the lighting configs in ReplicaCAD Interactive to account for the changes in this PR and have made a new version of the dataset (1.6 I guess) with these changes. Just need to upload it to wherever it goes. |
src/esp/gfx/LightSetup.cpp
Outdated
LightPositionModel::Camera}, // forward | ||
{{0.0, -0.3, 1.0, 0.0}, | ||
{0.5, 0.5, 0.5}, | ||
LightPositionModel::Camera}, // backward (for glancing speculars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid emitting light from the camera by default here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done specifically so that surface details such as normal or clearcoat texture/specular can be readily seen in the new PBR shader regardless of camera orientation (i.e. demo screen captures).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I said below, I can remove these in favor of a custom lighting config added to /data that folks could just load up to take screen shots and such.
* TODO: this will be replaced by config-driven IBL asset loading and | ||
* registration | ||
*/ | ||
void initPbrImageBasedLighting(const std::string& hdriImageFilename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the current workflow to generate these cubemaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as this, only it is instantiated from ResourceManager constructor. This will fail if there's no context existing, which is what happens when enabled from python.
{0.5, 0.5, 0.5}, | ||
LightPositionModel::Camera}, // backward (for glancing speculars) | ||
|
||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just so everyone is aware -- this is 7 lights instead of 5, which makes the fragment shader roughly as much as 40% more computationally expensive.
Personally I don't think that many lights is needed, even a three-point lighting was often enough to get a balanced output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was aware of the potential impact of these two additional camera-related lights, but their intention is specifically to give easily visualized specular/textural response for those materials that have texture-based surface normals, clearcoat texture and cc normal texture and anisotropy (so far).
If folks think this is too expensive, I can remove the two camera facing lights, and instead provide a lighting config that would define the lights in this manner that folks making demos could consume.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is also pretty easy to just author a new light config with fewer lights if the default is considered too computationally expensive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you know how it usually goes -- people will treat the default as the "normal perf", completely unaware that it could get faster with some tweaks.
Same as they treated the extraordinary light setup that was here before as "this is how magnum renders things".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that one directional light and an ambient light would suffice as a default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A single directional light will not look good at all for PBR scenes (I've tried it), and ambient light is neither used nor useful in PBR, since it lacks a light vector. Of course it probably will be fine with Phong lighting, so perhaps we should set up a different default for Phong?
At least for PBR, I would suggest the 5 base global directional lights I have in the current default setup (minus the camera-relative ones).
I pushed up a 4-light setup that seems to work pretty well for Phong and PBR (both old/current and new).
9d58dfe
to
5486123
Compare
Default lights should work well for both PBR and Phong shading. By moving the scaling value to the PBR shader, the lights can now be agnostic to shader.
The PBR 2.0 shader refactor will remove the hardcoded scaling by a change of units conversion.
By having the main lights global, constructive interference (i.e. the lights getting brighter because of overlap) is avoided when turning the camera. The camera-relative backwards light makes sure there's always a glancing specular when looking at horizontal clearcoat/specular/metallic object surfaces. Also, this has a better mix of direct and indirect lighting when IBL is active
Having the IBL env map loaded in the ResourceManager constructor was failing since there usually wasn't a GL context built yet, which was needed to instantiate the shader. This is just a stop-gap measure so that IBL can be invoked successfully. Much engineering needs to be done for IBL to be fully ready for prime time.
NOTE : Some of these images will need to be updated again with the full PBR fragment shader rewrite.
9cfc2aa
to
16a3900
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. We'll merge once ReplicaCAD update is ready.
Motivation and Context
As part of the ongoing PBR shader rewrite/functional expansion effort, this PR contains changes that were made to the default lighting configurations, as well as providing a few fixes. Specifically :
NOTE : Many of these changes were driven by the new PBR shader, and so may not appear ideal with the current shader.
How Has This Been Tested
Existing c++ and python tests pass, with the addition of new test images to account for lighting changes.
Types of changes
Checklist