-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Feature Implemeted -- Multiple Material support for geometry #5774
Conversation
Thanks @ShenpaiSharma. I am inviting the GSoC mentor @calebfoss to review this PR. |
Awesome work, @ShenpaiSharma! I'm thinking it would be helpful to update the inline documentation a bit to clarify that specular, emissive, ambient, and fill can be combined, but normal cannot. Perhaps in normalMaterial, we can add a sentence to the effect of "This material cannot be combined with other materials and will override the current material settings." In ambientMaterial, I think it would clarify to revise "Sets the current material as an ambient material of the given color. The ambientMaterial() color is the color the object will reflect under any lighting." to something like "Sets the ambient color of the current material. Objects will reflect this color under any lighting. The ambient color is combined with the current fill color as well as colors set with emissiveMaterial() and specularMaterial()." And similar adjustments to emissiveMaterial and specularMaterial. Also something I'd be interested to hear more thoughts on before merging this PR:
|
Congrats @ShenpaiSharma!
I think that early on we discussed adding the word "material" to match more present-day tools that use shaders (Unity, three.js, etc) so that people familiar with other platforms would have a consistent search term. This vocabulary was less common in the early days of Processing, so I think it's ok not to match here! Curious what others think. |
I might be wrong, but aren't these function calls affected by calls to push() and pop() ? Do you think that's not enough of a handle to help people control turning on and off material properties? |
@kjhollen, thanks for that insight! Sounds like leaving the method names as is would be more clear, particularly with the adjustments to documentation.
@aferriss, that's correct! My thinking is that stroke() and fill() are also affected by push() and pop(), but we still have noStroke() and noFill(). That being said, push() and pop() may be more familiar to folks using webGL mode, since they'll need to use transformations to position models anyway. Here's an example of drawing two spheres without using push() and pop(), one with specularMaterial and one without: |
@calebfoss Thanks for the context and the example! I definitely see the value in what you're proposing and it makes sense to me. Might be worth starting another thread with this proposal just to keep things clean here, since I don't think your proposed feature would be a blocking issue for this PR. |
For the previous behavior, it felt nice to break from Processing and use "material" for the reasons that @kjhollen listed here. Though now that these methods don't switch the set of shaders used for rendering, the word 'material' at the end feels less accurate because they aren't changing what I would think of as the material but instead setting attributes of a single material. It almost feels like if we keep the term 'material' then the sequence should be reversed to communicate that the material is being modified not swapped (ie: btw great work @ShenpaiSharma !! |
Thanks, @aferriss! Happy to get that started once this is merged.
@stalgiag, thanks for these thoughts! Yes, I think if I were seeing specularMaterial() for the first time, I would assume that the renderer would now use a new, shiny material, which is exactly what it's been doing until this feature. So I was a bit concerned if we change these methods' behaviors without changing their names, that might cause some confusion. So here's what these variations look like when producing this example: A
B
C
While I certainly see the value in being consistent with other tools (as @kjhollen referenced) and in being consistent with how things have been named already, looking at these options, I think C reads the most clear. A bonus benefit if we do decide to add new methods to turn these off is that |
89506b2
to
b1baa59
Compare
Being mindful of the GSoC project timeframe, I don't think it's essential to change the method names immediately as a condition of this merge. We could decide to open a new issue and track renaming the functions as future work, as I think there's a little more to do beyond just changing the method names. For example, can we deprecate the methods as they exist now, so that we don't break anyone's code on short notice? Would we want some custom friendly error messages that indicate that the method name was/is changing? In terms of methods for turning off types of materials, we do also have Is there any additional discussion needed before merging this PR? I know @aceslowman is eager to use these new features in a web GL tutorial. Please let me know if I can help with any further review! |
@kjhollen this makes sense, and thank you for the additional info. This is now merged, and I'm happy to open up renaming conversations in a new thread. Sorry for holding things up! Congratulations and thank you, @ShenpaiSharma !!! |
thanks @calebfoss and congrats @ShenpaiSharma!! 🥳 |
Great work @ShenpaiSharma ! |
Wonderful work @ShenpaiSharma and @calebfoss 🎉 |
Resolves #3806 #5308
Changes:
Implemented a few new uniforms (uSpecularMatColor, uAmbientMatColor, uEmissiveMatColor) which store the RGB colors for different materials and fill the geometry with different color properties and thus contributing separately to the lighting of the surface.
So finally, we have decided to move away from the current overwriting of fill colors to the geometry, towards the approach that Processing uses where the material has different color properties (ambient, emissive, specular) that all contribute separately to the lighting of the surface.
Screenshots of the change:
Before:
Code
After:
Code
PR Checklist
npm run lint
passes