Skip to content

Adding light position configurability for surface and mesh3d, and general lighting configurability for the latter #556

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

Merged
merged 10 commits into from
May 26, 2016

Conversation

monfera
Copy link
Contributor

@monfera monfera commented May 20, 2016

Part of the fix to #552

The fix isn't actually to the 'plotly.js' repo, but rather, the dependencies are changed such that epsilon values can be passed on to them. The alternative fix in the dependencies (changing the epsilon in the normals repo) was deemed less good because the epsilon is better be configurable in the dependencies.

PRs in dependent issues:
mikolalysenko/normals#2
gl-vis/gl-mesh3d#5

The other part of the fix is even less to do with plotly.js (except bumping the dependency version number): gl-vis/gl-mesh3d@b901f89

Adding epsilon configuration in order to pass it on to newly modified dependencies that now take these new params. The default values are set such that 3D mesh models with minute triangles are also properly included in the GL specular light reflection calculation.

WIP because:

  • it assumes the PR acceptance, merge in and npm update of a dependency; which in turn assumes a similar change to its own dependency
  • attribute and image test cases are not yet added
  • anything I forgot?

@monfera monfera changed the title Adding epsilon configuration [WIP] [WIP] Adding epsilon configuration May 20, 2016
@monfera
Copy link
Contributor Author

monfera commented May 20, 2016

As of now, the CI check obviously fails for the reason that the package dependencies haven't yet been bumped and pushed to the NPM repo so it doesn't find gl-mesh3d v1.1.0.

@monfera
Copy link
Contributor Author

monfera commented May 20, 2016

@monfera monfera changed the title [WIP] Adding epsilon configuration [WIP] Adding epsilon and light position configuration May 24, 2016
@@ -182,6 +206,20 @@ module.exports = {
min: 0.00,
max: 5.00,
dflt: 0.2
},
vertexnormalsepsilon: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe vertexnormal and facenormal would suffice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etpinard it's quite specific to to the epsilon error terms in the normals calculation and these names would be suggestive of passing on the normals directly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Agreed. I won't be the most used attribute nor is it the most obvious ; might as well be verbose. 👍

@etpinard
Copy link
Contributor

@monfera looks like your patch led to image test diffs:

image

Is that on purpose?

@etpinard
Copy link
Contributor

etpinard commented May 25, 2016

@monfera great work 🎉

Thanks for bringing our mesh3d trace type up to its full potential.

Before merging this in:

  • agree on vertex normal and face normal epsilon attribute names
  • update the baseline images that generated diffs
  • add a image test mock showing off custom lightposition, and vertex/face normal epsilions.
  • add description fields to all added attributes

@monfera
Copy link
Contributor Author

monfera commented May 25, 2016

@etpinard yes, I knew about the image diff but haven't yet pushed the commit for its solution. Also I agree with your list and push commits, and pls. see my reply on the naming.

@monfera monfera force-pushed the fix-brain branch 2 times, most recently from 2386922 to 10a2ca7 Compare May 25, 2016 16:40
},
roughness: {
valType: 'number',
role: 'style',
min: 0.00,
max: 1.00,
dflt: 0.5
dflt: 0.5,
description: 'Alters specular reflection; the rougher the surface, the wider and less contrasty the shine.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. These descriptions are great. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇

@etpinard
Copy link
Contributor

Yes yes. The new Snowden image is incredible:

image

@monfera monfera changed the title [WIP] Adding epsilon and light position configuration Adding epsilon and light position configuration May 25, 2016
@monfera
Copy link
Contributor Author

monfera commented May 25, 2016

The included test doesn't yet cover specular reflection yet. Snowden head shows the effects of the diffuse and ambient parameters, and the mesh color parameter is also exercised.
image

@monfera
Copy link
Contributor Author

monfera commented May 26, 2016

@etpinard regarding the coercion of vertexnormalsepsilon and facenormalsepsilon: these turn out not to be used by the underlying gl-surface3d so I'm making it specific to mesh3d, in line with your original PR suggestion.

I added commits to this PR such that the directional light position is being sent to gl-surface3d, see the numerous surface png diffs, most of which are superficial (changed reflection due to different light position - formerly, the default in gl-surface3d prevailed, and now the plotly.js default prevails, which was taken from gl-mesh3d to begin with.

The different lighting cast on the yield curve highlights an issue with the specific test case. I'll look into that but it is unrelated to this PR; even in the former image, the unexpected shady bands are somewhat visible.

@monfera
Copy link
Contributor Author

monfera commented May 26, 2016

Snowden in a different lighting and orientation:
image
image

@monfera
Copy link
Contributor Author

monfera commented May 26, 2016

@etpinard I didn't want to fiddle with your PR checklist above but I think they were covered by late yesterday, and today's commits made light positions work with surface too. The epsilon values weren't needed as it uses a different specular calculation method.

@monfera monfera changed the title Adding epsilon and light position configuration Adding light position configurability for surface and mesh3d, and general lighting configurability for the latter May 26, 2016
dflt: 1e-6, // even the brain model doesn't appear to need finer than this
description: 'Epsilon for face normals calculation avoids math issues arising from degenerate geometry.'
}
}, surfaceAtts.lighting),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@etpinard
Copy link
Contributor

@monfera

The different lighting cast on the yield curve highlights an issue with the specific test case.

Can you elaborate? If I understand correctly, lightning on surface trace isn't perfect yet?

@monfera monfera force-pushed the fix-brain branch 2 times, most recently from eddc43b to 2fc27f1 Compare May 26, 2016 15:43
@etpinard
Copy link
Contributor

@monfera Fantastic work.

You win the PR of the week 🏆

@etpinard etpinard merged commit 12c2d8c into plotly:master May 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants