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

Substance Painter Integration #4283

Merged
merged 107 commits into from
May 3, 2023
Merged

Conversation

BigRoy
Copy link
Collaborator

@BigRoy BigRoy commented Jan 6, 2023

Brief description

This implements a part of #4205 by implementing a Substance Painter integration

Description

Status:

  • Implement Host
    • start substance with last workfile using AddLastWorkfileToLaunchArgs prelaunch hook
  • Implement Qt tools
  • Implement loaders
    • Implemented a Set project mesh loader (this is relatively special case because a Project will always have exactly one mesh - a Substance Painter project cannot exist without a mesh).
  • Implement project open callback
    • On project open it notifies the user if the loaded model is outdated
  • Implement publishing logic
    • Workfile publishing
    • Export Texture Sets
  • Support OCIO using Colorspace Management and Distribution #4195 (draft brach is set up - see comment)
    • Likely needs more testing on the OCIO front
  • Validate all outputs of the Export template are exported/generated
    • Allow validation to be optional (issue: there's no API method to detect what maps will be exported without doing an actual export to disk)
    • Support extracting/integration if not all outputs are generated
  • Support multiple materials/texture sets per instance
    • Add validator that can enforce only a single texture set output if studio prefers that.
  • Implement Export File Format (extensions) override in Creator
    • Add settings so Admin can choose which extensions are available.

Additional info

Substance Painter Qt Stylesheet

Substance Painter has quite a lot of styleSheet overrides on its own QApplication which do mess a bit with the one for the OpenPype tools as mentioned on Ynput discord - here's a rough stylesheet export of what Substance Painter applies.

Some style sheet changes were done in this PR to avoid the worst offenders to make the UI look quite similar to other DCCs - yet there are still some differences. And likely the changes made aren't done correctly either.

Having Qt Windows open during shutting down of Substance Painter will shut down incorrectly

If any of the Qt tools remain open when shuttig down Substance 3D Painter then the next time it'll launch it will start with a Bug Report pop-up saying "Substance 3D Painter didn't shut down correctly."

afbeelding

Not entirely sure how to best close down all OpenPype tool UIs on Substance Painter shutdown to avoid this issue.

This can also be reproduced by running this in Substance's Python Console without OpenPype:

from PySide2 import QtWidgets; import substance_painter.ui; dialog = QtWidgets.QDialog(parent=substance_painter.ui.get_main_window()); dialog.show()

Publishing gets slower over time

It seems that Substance Painter and printing/logging gets much slower over time when there are many logs present. This means that when you've published many times in one session you'll definitely notice the publishing being slower. This is solved by opening a Log window and clearing the log, then everything is much faster again.

A potential workaround to look for in the future is to either Clear the logs regularly or just print/log much much less information into Substance Painter itself and keep it solely to the Publisher UI as described here.

Testing notes:

I tested on Windows with Adobe Substance Painter 8.2.0 build 1987

Note: You might need to enable the OpenPype Integration plug-in at the top menu "Python > openpype_plugin"

afbeelding

  1. Launch Substance Painter
  2. Use the Loader to 'start' a project with e.g. an FBX or Alembic mesh using "Load Mesh" OR open your own New Project template and then use the Loader to replace the mesh to that.

@BigRoy BigRoy self-assigned this Jan 6, 2023
@BigRoy
Copy link
Collaborator Author

BigRoy commented Jan 6, 2023

Preview screenshots

afbeelding

afbeelding

afbeelding

@LiborBatek
Copy link
Member

maybe silly question...I have only Steam edition of the Painter. Do you think it will work anyway or we need proper Adobe package?

@BigRoy
Copy link
Collaborator Author

BigRoy commented Jan 6, 2023

maybe silly question...I have only Steam edition of the Painter. Do you think it will work anyway or we need proper Adobe package?

Good question. I have no idea actually - I suspect it should. Steam mentions it only has updates until end of 2022. Painter build 8.2.0 I tested with came out beginning of December 2022 so I suppose it would have that update too.

@LiborBatek
Copy link
Member

LiborBatek commented Jan 9, 2023

Ok, I have just my private (for my projects) steam edition and what worse its even old one :)

heres a scrncap:
image

I have configured it in OP settings and it starts normally via OP Launcher however the OP menu doesnt show up in UI...
image

Is it chance to get it working even in this older ver or complete scifi and I need at least 8.x version of Painter?

Let me know and I will resolve this with @mkolar if needed!

@BigRoy
Copy link
Collaborator Author

BigRoy commented Jan 9, 2023

Here are some previews of a very early WIP setup for publishing textures. Not fully functional yet:

create_textures_templates
create_textures_instance
extract_texture_sets

Be aware that there's still the Qt StyleSheet issue so the UI might be a bit odd here and there!!!

Still trying to find a better way in Substance Painter on how to get all available export preset in Python.

Also still trying to define the right "family" for publishing textures/images as a group, somewhat related to this Texture Sets publishing discussion. Would love input on this!

@BigRoy
Copy link
Collaborator Author

BigRoy commented Jan 9, 2023

@LiborBatek I believe it should work with that version too - however, you might need to enable the plugin first under the Python top menu entry. Does it show the plug-in there?

It's like this screenshot:

afbeelding

I'll look into ways of maybe forcing it to enabled on first run. E.g. check user preferences if there's anything regarding the preferred plugin load state - if not, then load it.

antirotor
antirotor previously approved these changes Apr 3, 2023
Copy link
Member

@antirotor antirotor left a comment

Choose a reason for hiding this comment

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

Looks cool. Can we test it @LiborBatek ?

@antirotor antirotor assigned LiborBatek and unassigned antirotor Apr 3, 2023
@LiborBatek
Copy link
Member

@antirotor we need license for Adobe Substance to test it....I have only my Steam edition of older Painter 7.4.3 which doesnt work with OP. No OpenPype plugin shown in the addon menu...

Will be on it asap....

Copy link
Member

@LiborBatek LiborBatek left a comment

Choose a reason for hiding this comment

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

Finally tested using latest Substance Painter 8.4.3.

Did test Publish of the TextureSet and all worked nicely and smoothly

image

Also showed later in Asset Load in maya host and successfully loaded into scene

image

@BigRoy
Copy link
Collaborator Author

BigRoy commented Apr 4, 2023

@moonyuet @ddesmond @gabormarinov @maxpareschi @fabiaserra @kekefreedog If any of you are using Substance Painter in production or have experience with it then it would be super if you're able to test this PR whether it works as you'd need for your production cases. Being able to comment now before we get into merging this PR would make sure the core functionality fits your production needs.

@LiborBatek
Copy link
Member

LiborBatek commented Apr 4, 2023

There are still some questionable things too speaking of Substance integration... the core is functional tho!

  1. TextureSet file naming differs from Substance Project and is hardcoded by OP?

image

  1. Maya warns that color profile isnt available even tho its set to the same Aces cg via OCIO config?! Not sure whats goin on there

image

  1. Its great user can Update Asset and gets warning of obsolete asset for TextureSet much appreciate feature! Great!
    However its not later visible in Scene Manager ...bug? My bad.....it works flawlessly! Had filter outdated on :) so nevermind!

Loving it so far!

@BigRoy
Copy link
Collaborator Author

BigRoy commented Apr 4, 2023

TextureSet file naming differs from Substance Project and is hardcoded by OP?

Correct. The output behaves according to the output templates for the subset. If you need to preserve the source name I believe you should define a custom template and use the {originalBasename} token instead. I can't find mention of it in the documentation so I'm not sure how and where to set this up but some Unreal related templates use it here.

As far as I'm aware this is "true" to how the naming of the files should work by default. Right @mkolar @iLLiCiTiT @antirotor ?

Maya warns that color profile isnt available even tho its set to the same Aces cg via OCIO config?! Not sure whats goin on there

That's definitely something to investigate - thanks. I'll look into it. But in your Maya you are using the Maya OCIO config and that is almost 100% certain not the OCIO config you're using in Substance Painter. It seems your Maya isn't correctly color managed to the same OCIO config.

This only shows more and more that at least managing OCIO env var like @fabiaserra mentioned in #4700 here and here will result in a much more artist friendly behavior since it's much harder to get maya into a state where it won't be using the correct OCIO config since it'll always listen to the env var.

For now could you try manually setting the same OCIO path as Substance Painter ended up using in Maya to ensure it has access to the exact same color space names. I think maybe the color space is slightly different named in the Maya config, maybe acescg instead of ACES - ACEScg.

Its great user can Update Asset and gets warning of obsolete asset for TextureSet much appreciate feature! Great!
However its not later visible in Scene Manager ...bug? My bad.....it works flawlessly! Had filter outdated on :) so nevermind!

What a rollercoaster of emotions there. Thanks for testing, and great to hear it's working.

@LiborBatek
Copy link
Member

LiborBatek commented Apr 4, 2023

Speaking of color profile in SubstancePainter using OP integration/Launcher ... my settings looks like this (this time Im not relating to maya issue more just a note how things are set right now in Substance)

image

So I guess its the OP dictating the OCIO config file / and required color profile (acesCg) - so user cant change it accidentaly right? All managed through OP Settings right?

I also understand the OCIO issue in maya as you described it. So I guess right now its more of a problem that maya host doesnt use OCIO config from the same place and setting (OP should dictate it right?)

So manually setting the same OCIO config file solves the maya issue and all working normally/predictably!

image

@LiborBatek
Copy link
Member

So in the end, all core functions is working well! Now if any other users suggestions arises...

@BigRoy Welldone, man!

@BigRoy
Copy link
Collaborator Author

BigRoy commented Apr 4, 2023

I also understand the OCIO issue in maya as you described it. So I guess right now its more of a problem that maya host doesnt use OCIO config from the same place and setting (OP should dictate it right?)

It should be, yes. If not working correctly then it's an issue on the Maya side which MIGHT be solved with #4700 but it might be best to report it in that PR if the OP setting doesn't correctly propagate into Maya for you so it could be resolved with that PR.

So manually setting the same OCIO config file solves the maya issue and all working normally/predictably!

That's great. Maya's OCIO config has ACEScg but no ACES - ACEScg entry which is the name that the default OCIO config with OpenPype uses. So it is correct that maya failed to apply the color space correctly.

Thanks again for testing!

Copy link
Member

@mkolar mkolar left a comment

Choose a reason for hiding this comment

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

Seems to me that this might be ready for merge right?

Copy link
Collaborator Author

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

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

@mkolar I think this is pretty much ready to merge. However I've placed some comments now that I thought would be good to highlight before we do so.

@antirotor antirotor merged commit 426ad9c into ynput:develop May 3, 2023
7 checks passed
@ynbot ynbot added this to the next-patch milestone May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community contribution host: Substance Painter size/XL Denotes a PR changes 1500-2499 lines, ignoring general files type: documentation type: feature Larger, user affecting changes and completely new things
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

10 participants