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

[WIP] Export: use nodes for Alpha clipping #2152

Closed
wants to merge 1 commit into from
Closed

[WIP] Export: use nodes for Alpha clipping #2152

wants to merge 1 commit into from

Conversation

scurest
Copy link
Contributor

@scurest scurest commented Mar 10, 2024

Does #2111 for the exporter.
Uses nodes to determine the alpha mode and cutoff.

To export OPAQUE materials, just set Alpha to 1.

To export MASK materials, use either round(alpha) or 1-(alpha < cutoff).

(Constant 0 Alpha also exports as MASK.)

Other setups use BLEND.


Implemented by adding a gather_alpha_info function that parses all the info from nodes hanging off the Alpha socket except the texture. There are several utility functions to support it.

This should also solve #2110 for Alpha color attributes (not RGB colors).

Tested lightly for both Principled and unlit with stuff like

@julienduroure
Copy link
Collaborator

Hello,
Thanks!
Did you see you have some failed tests
You may have adjust some test, and to merge your 2 PR importer/exporter to get roundtrips right.

@scurest
Copy link
Contributor Author

scurest commented Mar 11, 2024

The failures are just roundtrip tests, which is expected. They will pass when both import and export PRs are merged.

I'm not planning on putting everything in one mega-PR.

@julienduroure
Copy link
Collaborator

Closing, as we created a single PR with all alpha clipping stuff: #2155

@scurest scurest deleted the export-alpha-clip branch March 11, 2024 16:57
if info['alphaColorAttrib'] is None:
attr = get_color_attrib(alpha_nav)
if attr is not None:
info['alphaColorAttr'] = attr
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just found a typo here, should be 'alphaColorAtttrib'


attr = detect_multiply_by_color_attrib(alpha_nav)
if attr is not None:
info['alphaColorAttr'] = attr
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just found a typo here, should be 'alphaColorAtttrib'

prev.node.type == 'MIX' and
prev.node.data_type == 'RGBA' and
prev.node.blend_type == 'MULTIPLY' and
prev.get_constant('Fac') == 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo here: Should be 'Factor'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants