Skip to content
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

Fix material docstrings, improved standard parameters and improved materials application support #488

Merged
merged 16 commits into from Sep 8, 2021

Conversation

guaje
Copy link
Contributor

@guaje guaje commented Aug 10, 2021

This PR includes many improvements for the material module. Among many things it:

@codecov
Copy link

codecov bot commented Aug 11, 2021

Codecov Report

Merging #488 (43f7d94) into master (b2512b9) will increase coverage by 0.46%.
The diff coverage is 86.48%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #488      +/-   ##
==========================================
+ Coverage   88.53%   89.00%   +0.46%     
==========================================
  Files          31       33       +2     
  Lines        6575     7092     +517     
  Branches      787      834      +47     
==========================================
+ Hits         5821     6312     +491     
- Misses        535      547      +12     
- Partials      219      233      +14     
Impacted Files Coverage Δ
fury/material.py 83.33% <86.48%> (+8.33%) ⬆️
fury/utils.py 85.85% <0.00%> (-0.70%) ⬇️
fury/layout.py 100.00% <0.00%> (ø)
fury/shaders/__init__.py 100.00% <0.00%> (ø)
fury/actors/peak.py 90.00% <0.00%> (ø)
fury/actors/tests/test_peak.py 97.95% <0.00%> (ø)
fury/shaders/base.py 91.54% <0.00%> (+0.16%) ⬆️
fury/primitive.py 92.13% <0.00%> (+0.35%) ⬆️
fury/actor.py 89.63% <0.00%> (+0.59%) ⬆️
fury/window.py 81.95% <0.00%> (+1.79%) ⬆️

Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

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

Hi @guaje,

Thank you for this fix. See below for some comments. It is almost ready to go.

fury/material.py Outdated
Comment on lines 22 to 23
warnings.warn('Your PBR effect can not be apply due to VTK version. '
'Please upgrade your VTK version (should be >= 9.0.0).')
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

@@ -60,22 +60,30 @@ def manifest_standard(actor, ambient_level=0, ambient_color=(1, 1, 1),
fragment level.

"""
prop = actor.GetProperty()
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need a try? which actor does not have this feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was added because contour_from_label was throwing an exception when trying to access the Property object. See test_material and test_manifest_standard.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, I will look into it

fury/material.py Outdated Show resolved Hide resolved
fury/material.py Outdated
Comment on lines 73 to 76
warnings.warn(
'Unknown interpolation. Ignoring "{}" interpolation option. '
'And using the default ("{}") option.'.format(
interpolation, 'gouraud'), UserWarning)
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure the warning will be written correctly this way. I need to test it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean? It's created according to this

Copy link
Contributor

Choose a reason for hiding this comment

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

As you can see below, the format does not work correctly (it does not work well with multiline) :

In [1]: from fury import actor, material

In [2]: act = actor.axes()

In [3]: material.manifest_standard(act, interpolation="test")
/Users/koudoro/Software/fury/fury/material.py:78: UserWarning: Unknown interpolation. Ignoring "test" interpolation option. And using the default ("gouraud") option.
  interpolation, 'gouraud'), UserWarning)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, I'll look into it.

fury/tests/test_material.py Outdated Show resolved Hide resolved
@skoudoro skoudoro added the type:Bug Fix Something isn't working label Sep 3, 2021
@pep8speaks
Copy link

pep8speaks commented Sep 6, 2021

Hello @guaje! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-09-07 21:56:56 UTC

Copy link
Contributor

@Garyfallidis Garyfallidis left a comment

Choose a reason for hiding this comment

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

@guaje I see that there is no tutorial in this PR. I suppose that this is on purpose?

fury/material.py Outdated Show resolved Hide resolved
fury/material.py Show resolved Hide resolved
fury/material.py Show resolved Hide resolved
npt.assert_array_almost_equal(actual, desired, decimal=2)

material.manifest_standard(test_actor)
window.record(scene, out_path=tmp_fname, size=(200, 200),
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting that you prefer using record than snapshot. Snapshot returns directly the framebuffer as a numpy array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I didn't think of it. However, I found this problem (#467) when using window.snapshot().

@Garyfallidis
Copy link
Contributor

@guaje Can you explain how I would have to change the following code to see the PBR effect?

from fury import actor, window, material


scene = window.Scene()

ax = actor.axes()

scene.add(ax)

material.manifest_pbr(ax, roughness=0.)

window.show(scene)

@guaje guaje changed the title [WIP] Fix material issues Fix material issues Sep 7, 2021
@guaje guaje marked this pull request as ready for review September 7, 2021 22:00
@guaje guaje changed the title Fix material issues Fix material docstrings and improving materials support Sep 8, 2021
@guaje guaje changed the title Fix material docstrings and improving materials support Fix material docstrings, improved standard parameters and improved materials application support Sep 8, 2021
@Garyfallidis
Copy link
Contributor

Thank you for this PR @guaje !
Please remember to update the tests after the snapshot function is resolved as reported here #467

@Garyfallidis
Copy link
Contributor

Garyfallidis commented Sep 8, 2021

Please also make another PR to improve manifest_pbr function to support actors that are created from primitives.

@Garyfallidis Garyfallidis merged commit dcfbfa1 into fury-gl:master Sep 8, 2021
@guaje guaje deleted the fix_material_doc branch September 9, 2021 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:Bug Fix Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mismatch in parameter and docstring in manifest_standard() in material module
4 participants