-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
Feature implementation: specularLight #3843
Feature implementation: specularLight #3843
Conversation
shouldn't this be called the name is there an issue associated with this? https://github.com/processing/p5.js/tree/master/developer_docs#how-to-contribute |
This method intends to distinguish the specular and diffuse quantities from the |
Hi @sanketsingh24 and @aferriss just a heads up that the transition to ES6 is happening this week. See this post for a brief overview.. It is okay if this PR doesn't get through in time to be incorporated into that shift, at this point I think it unlikely, but just be prepared for a rather large rebase to fix merge conflicts. I think it will be manageable but just wanted you to be prepared. Also I understand that this is part of Summer of Code, so the issue-opening protocol didn't quite make sense here since a proposal was already written, but these things are never set in stone, so perhaps some more info about the intention of this feature could be posted along with some screenshots and how it relates to processing's lighting features such as lightSpecular. This kind of accompanying information could be helpful in allowing other contributors to offer opinions about API. Thanks! |
specularLight(color)What this method does is differentiates the specular and diffuse components from the pre-existing lighting methods, which improves the customizability of the sketch. The default value is Artists will be able to emulate something like this now- function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
setAttributes('perPixelLighting', true);
noStroke();
}
function draw() {
background(0);
shininess(10);
ambientLight(50);
specularLight(250, 0, 0);
pointLight(255, 0, 0, 0, -100, 100);
specularLight(0, 250, 0);
pointLight(0, 255, 0, 0, 100, 100);
specularMaterial(255);
sphere(80);
} Whereas, this was the previous behavior I think it is very close in behaviour to Processing's |
@stalgiag Thanks for the heads up re: ES6 changes! @sanketsingh24 and I spoke about this and feel comfortable making the changes needed to resolve any merge conflicts. I also wanted to chime in with my understanding of the
The color parameters passed to
The proposed function A white specular highlight is what we expect in most circumstances but there are times when the specular highlights should not be white. For instance, many metals reflect specular colors tinted towards their material colors. Additionally, you might just want to render funky things. We have chosen to implement this in such a way that each light can have it's own specular highlight color (up to the max 8 lights that the renderer supports) rather than just one global specular highlight color. If you omit a call to Calls to Also to @Spongman 's point above, I also agree that the names of these functions are confusing and wonder if there is a better name for this. @sanketsingh24 If you could make a few more variations and examples of using different combinations of colors and lights as I've done above I think that might help make this a little more clear. |
@stalgiag @Spongman Just wanted to check in to see if you all had any feedback on this PR. It would be great to get this merged since most of the rest of our GSOC work is tied together with this function. @sanketsingh24 And I decided that renaming to I feel good about the state of this but thought I would check in to see if anyone else had thoughts. |
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 looks great! Thank you @sanketsingh24.
I think this should be merged. I really like the naming with diffuse and specular here. Verbose and clear is the preference with this codebase in my opinion. This PR does bring up general feelings that I have about how we are storing the state of the lighting. My personal feelings are that the lighting state should be consolidated into a single property belonging to the renderer, with more of a hierarchy. Something like:
lighting = {
active: true,
directional: { diffuseColors: [], specularColors: [], directions: []},
point etc
}
This might be personal preference. I just feel like the lighting state is spread out between a ton of different properties all of which need to be reset individually, and which teeter on the boolean that enables or disables lighting entirely. Anyways! That is mostly unrelated to this PR and definitely didn't start here, but this just reminded me of that concern.
Great work!
Thanks for the vote of confidence @stalgiag ! I'm going to merge but if anyone has further suggestions re: naming or clarification of this function down the road please feel free to reach out. |
Implemented specularLight()
This function separates the diffuse and specular quantities of
pointLight()
anddirectionalLight()
. Defaults to (255,255,255) so that this does not become a breaking change.See manual tests
/webgl/lights/specularLight/
and/webgl/material/specular_ambient/
.Work done-
uDirectionalSpecularColors
anduPointLightSpecularColors
uniform in both shadersspecularLight()
in /src/webgl/light.js/webgl/lights/specularLight/
To do-
@aferriss