-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
Remove material.ambient, no need for a secondary surface color just for ambient light #5809
Conversation
I've had a look and everything seems fine. |
@mrdoob Remember that not all users are interested in physically-based shading. Removing the @bhouston Here are some errors I have noticed so far: In the Phong shader, you cannot add the terms in the following equation because they have different units.
Also in
|
@WestLangley wrote:
I think that before it was I do fix up this particular line of the phong shader fairly well in this separate PR: (Although I can clean up the totalSpecularLight term in the above other PR as it is actually already pre-multiplied by specular, which can make it seem like there is a unit issue when there isn't.) |
Have a great Christmas all!, especially @mrdoob and the ever vigilant @WestLangley! I am out for the evening, and the rest of the week. Will be back for sure Monday. |
@bhouston Please check again. It should be a simple change to substitute |
@WestLangley Please note that in this line here, ambientLightColor was double modulated, it was a bug. I removed the modulation by ambient: https://github.com/mrdoob/three.js/pull/5809/files#diff-3d33ad8ea54d86cc060ca7b09c39d896R276 I fix the majority of the issues with diffuse and gl_FragColor, and there are quite a few in the other PR. Do you want me to back port all those fixes into this PR? i can do that, but it will make this PR unweildy. |
@WestLangley I will add back the double modulation issue so it will be more of a replace of ambient with diffuse in this PR. I think that will get this past review - while the larger fixes to issues with gl_FragColor will remain in the other PR. |
I do not believe it was a bug. I believe you have introduced a bug. Forking this PR, if I set Here is the change you made: Before
after
To try to prevent a lot of back-and forth, Also, in three.js, the diffuse reflectance of the material is defined to be (pseudo code):
Similarly (prior to this PR) for the ambient reflectance:
After this PR, the ambient reflectance should be the same as the diffuse reflectance:
So the radiance due to ambient light is
Can you please explain how or where in the existing code, " P.S. Yes, emissive is not handled correctly in the current code. And yes, your idea of refactoring the code to fix how |
@WestLangley I've made the change you requested. :) My reasoning is that if there is an "ambient" surface color, it shouldn't be modulated by the diffuse map. But you believe it should. That is okay. It was the same issue I saw with the emissive being modulated by the diffuse map -- it seemed strange/incorrect. But I think when one has non-physical models (such as a separate surface modulation color for incoming ambient light), it is easy to argue about the correct way to implement it. |
@bhouston I have found several more bugs introduced by this PR.
You can see these bugs by setting What you have effectively done is set the ambient reflectance to It should be the same as diffuse. |
Nice catches @WestLangley. I'm made those requested changes. |
@bhouston Would you mind tracking down any remaining issues in this PR yourself? Code reviewing and testing this PR is taking me a lot of time, and with all due respect, you should be demonstrating that the PR is correct. Instead, I must demonstrate that it is not. Please see the Wiki article How to Contribute to three.js. I think you have a lot of good ideas, and I, too, want to see your good ideas implemented in a timely and efficient manner. : - ) |
@WestLangley Thanks for your time! I do appreciate it. I do think this PR is ready to go now. |
@WestLangley I am trying to make everything change as a separate PR (that is why I've made 7), and to make them as atomic as possible. I am trying as best to respond to your feedback on how to proceed. Maybe we could try to split the PR review across multiple different people so the load isn't all on you? You can say which ones interest you, if any, and I can try to pull in others to review the others. In a few days, I'll try to get the screenshot tool working, but its coverage will necessarily be less broad than all examples, although it will have deeper coverage on the main shaders. |
@bhouston That sounds good. I will gladly let others more knowledgeable than myself provide feedback on code design and refactoring. |
@repsac do you have any thoughts on this? |
Well. I like both the code and mental simplification. So lets do it! |
Remove material.ambient, no need for a secondary surface color just for ambient light
Wohoo! Thanks @mrdoob! |
Per discussion here: #5741 (comment)
Now it should be mentioned that sometimes
material.ambient
is considered to be a per-material incoming non-directional light intensity (sometimes calledmaterial.selfIllumination
, but not to be confused withmaterial.emissive
) rather than as a surface color specifically for ambient light as it is treated now If we wanted to go that route, we would modify the shading equation and leavematerial.ambient
around, and it would be additive with ambientLightColor, both of which would then be modulated by thematerial.color
.I am okay with either route.