Skip to content

Commit

Permalink
Fix Broken OCIO with Mantra & Arnold, New Lighting
Browse files Browse the repository at this point in the history
  • Loading branch information
Elmar committed Oct 10, 2021
1 parent d1e33e0 commit a709a1b
Show file tree
Hide file tree
Showing 16 changed files with 447 additions and 24 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ A Material Library for Houdini Mantra, Redshift and Arnold
- Deletion of entries from the database (deletes also from disk)
- Edit multiple materials at the same time via the Details-Pane
- Easy adjustable custom preview and rendersize
- ACES 1.2 support (Redshift Native)
- ACES 1.2 support (Redshift Native, Mantra & Arnold need $OCIO)
- Right Click Menus for adding materials quickly from the network pane
- Importing to current network location (pwd()/matnet)
- Double Click or right click for importing Materials into the scene
Expand Down Expand Up @@ -59,9 +59,11 @@ A Material Library for Houdini Mantra, Redshift and Arnold
- Do not (!) edit the .json file by hand if not needed
- you have been warned ;)

### Acknowledgements
- Thanks to Rich Nosworthy for providing the ShaderBall-Setup - https://www.richnosworthy.tv

### Contact & License

- Found a bug? please open an issue or contact me directly via Twitter
- Twitter: @eglaubauf
- Feel free to support me via gumroad https://elmeier.gumroad.com/l/bsghA
- Website: https://elmar-glaubauf.at/
Binary file added img/FloorTexture.tx
Binary file not shown.
Binary file modified img/MatLib.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/Prefs.png
Binary file not shown.
Binary file removed img/RC1.png
Binary file not shown.
Binary file removed img/RC2.png
Binary file not shown.
Binary file added img/photo_studio_01_4k_ACEScg.tx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
154 changes: 154 additions & 0 deletions python2.7libs/About.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>983</width>
<height>836</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>400</height>
</size>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QTextEdit" name="textEdit">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Lato'; font-size:16pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Acknowledgements:&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;The code and assets are released under GPLv3 as Open Source and are free of charge and free to use modify and embed as stated in GPLv3. Selling or Reselling of the code is not permitted. &lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;The tools can be acessed here:&lt;br /&gt;&lt;a href=&quot;https://github.com/eglaubauf/egMatLib&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://github.com/eglaubauf/egMatLib&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; text-decoration: underline; color:#0000ff;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Special Thanks to Rich Nosworthy for providing the ShaderBallScene. &lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;https://www.richnosworthy.tv&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://www.richnosworthy.tv&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;If you find a bug or have suggestions feel free to contact me here:&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Twitter: &lt;a href=&quot;https://twitter.com/eglaubauf&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;@eglaubauf&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Mail: &lt;a href=&quot;mailto:e.glaubauf@gmail.com&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;e.glaubauf@gmail.com&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Github: &lt;a href=&quot;https://github.com/eglaubauf&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://github.com/eglaubauf&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;2021 - Elmar Glaubauf&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;https://elmar-glaubauf.at/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://elmar-glaubauf.at/&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4"/>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="action_HIP">
<property name="text">
<string>$HIP</string>
</property>
</action>
<action name="action_HOME">
<property name="text">
<string>$HOME</string>
</property>
</action>
<action name="actionCreate_Thumbs_for_Directory">
<property name="text">
<string>Recursively Create Thumbs for this Folder (slow)</string>
</property>
</action>
<action name="actionRefresh_Current_Dir">
<property name="text">
<string>Recreate Thumbs for this Folder</string>
</property>
</action>
<action name="actionClear_Thumb_Database">
<property name="text">
<string>Clear All Materials</string>
</property>
</action>
<action name="action50">
<property name="text">
<string>50</string>
</property>
</action>
<action name="actionAddFavourite">
<property name="text">
<string>Add Current Folder to Favourites</string>
</property>
</action>
<action name="actionStartup">
<property name="text">
<string>Set Current Library as Default</string>
</property>
</action>
<action name="actionRemFavourite">
<property name="text">
<string>Remove Current Folder from Favourites</string>
</property>
</action>
<action name="action_updateAll">
<property name="text">
<string>Update All Materials</string>
</property>
</action>
<action name="action_setDefault">
<property name="text">
<string>Set Current Library as Default</string>
</property>
</action>
<action name="action_openLibrary">
<property name="text">
<string>Open Library</string>
</property>
</action>
<action name="action_prefs">
<property name="text">
<string>Preferences</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
11 changes: 9 additions & 2 deletions python2.7libs/MatLib.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1401</width>
<width>1890</width>
<height>1153</height>
</rect>
</property>
Expand Down Expand Up @@ -585,7 +585,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1401</width>
<width>1890</width>
<height>20</height>
</rect>
</property>
Expand All @@ -609,6 +609,8 @@
<addaction name="action_updateAll"/>
<addaction name="separator"/>
<addaction name="action_prefs"/>
<addaction name="separator"/>
<addaction name="action_about"/>
</widget>
<addaction name="menu_file"/>
</widget>
Expand All @@ -628,6 +630,11 @@
<string>_deleteMaterial</string>
</property>
</action>
<action name="action_about">
<property name="text">
<string>About</string>
</property>
</action>
</widget>
<resources/>
<connections/>
Expand Down
68 changes: 59 additions & 9 deletions python2.7libs/egMatLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
from PySide2 import QtUiTools

#Load This HDAs for creation
HDA_REDSHIFT = "thumbnail_Redshift::1.0"
HDA_MANTRA = "thumbnail_Mantra::1.0"
HDA_ARNOLD = "thumbnail_Arnold::2.0"
HDA_REDSHIFT = "thumbnail_Redshift::2.0"
HDA_MANTRA = "thumbnail_Mantra::2.0"
HDA_ARNOLD = "thumbnail_Arnold::3.0"


def saveMaterial(node):
Expand Down Expand Up @@ -155,6 +155,9 @@ def createView(self):
self.action_prefs = self.ui.findChild(QAction, 'action_prefs')
self.action_prefs.triggered.connect(self.show_prefs)

self.action_about = self.ui.findChild(QAction, "action_about")
self.action_about.triggered.connect(self.show_about)

# Link Buttons
self.btn_save = self.ui.findChild(QPushButton, 'btn_save')
self.btn_save.clicked.connect(self.save_material)
Expand Down Expand Up @@ -314,6 +317,13 @@ def catlist_rc_menu(self):
########### USER STUFF ############
###################################

def show_about(self):

about = AboutDialog()
about.exec_()

return

def show_prefs(self):

prefs = PrefsDialog(self.library, self.prefs)
Expand Down Expand Up @@ -670,16 +680,18 @@ def update_all_materials(self):
def update_single_material(self):
'''Rerenders a single materials in the library - The UI is blocked for the duration of the render'''
items = self.get_selected_items_from_thumblist()
call = False
for item in items:
if not item:
return
builder = self.import_material(item)
id = self.get_id_from_thumblist(item)
self.library.save_node(builder, id)
call = self.library.save_node(builder, id)
builder.destroy()

self.update_thumb_view()
hou.ui.displayMessage("Thumbnail(s) updated")
if call:
hou.ui.displayMessage("Thumbnail(s) updated")
return


Expand Down Expand Up @@ -763,6 +775,7 @@ def get_material_info_user(self, sel):
for mat in sel:
self.library.add_material(mat ,dialog.categories, dialog.tags, dialog.fav)
self.update_views()

return


Expand Down Expand Up @@ -1093,9 +1106,15 @@ def save_node(self, node, id):
val= self.save_node_redshift(node, id)
elif node.type().name() == "materialbuilder" or node.type().name() == "principledshader::2.0":
#Interruptable
if hou.getenv("OCIO") is None:
hou.ui.displayMessage("Please set $OCIO first")
return False
with hou.InterruptableOperation("Rendering", "Performing Tasks", open_interrupt_dialog=True) as operation:
val = self.save_node_mantra(node, id)
elif node.type().name() == "arnold_materialbuilder":
if hou.getenv("OCIO") is None:
hou.ui.displayMessage("Please set $OCIO first")
return False
with hou.InterruptableOperation("Rendering", "Performing Tasks", open_interrupt_dialog=True) as operation:
val = self.save_node_arnold(node, id)
else:
Expand Down Expand Up @@ -1146,10 +1165,12 @@ def save_node_arnold(self, node, id): #ARNOLD
thumb.parm("mat").set(node.path())

# Build path
path = self.get_path() + self.settings.get_img_dir() + str(id) + self.settings.get_img_ext()
path = self.get_path() + self.settings.get_img_dir() + str(id)

# Set Rendersettings and Object Exclusions for Thumbnail Rendering
thumb.parm("path").set(path)
thumb.parm("path").set(path+".exr")
thumb.parm("cop_out_img").set(path+self.settings.get_img_ext())

exclude = "* ^" + thumb.name()
thumb.parm("obj_exclude").set(exclude)
lights = thumb.name() + "/*"
Expand All @@ -1174,6 +1195,9 @@ def save_node_arnold(self, node, id): #ARNOLD


thumb.destroy()
if os.path.exists(path+".exr"):
os.remove(path+".exr")

return True

def save_node_mantra(self, node, id):
Expand Down Expand Up @@ -1202,10 +1226,11 @@ def save_node_mantra(self, node, id):
thumb.parm("mat").set(node.path())

# Build path
path = self.get_path() + self.settings.get_img_dir() + str(id) + self.settings.get_img_ext()
path = self.get_path() + self.settings.get_img_dir() + str(id)

# Set Rendersettings and Object Exclusions for Thumbnail Rendering
thumb.parm("path").set(path)
thumb.parm("path").set(path+".exr")
thumb.parm("cop_out_img").set(path+self.settings.get_img_ext())
exclude = "* ^" + thumb.name()
thumb.parm("obj_exclude").set(exclude)
lights = thumb.name() + "/*"
Expand All @@ -1216,8 +1241,12 @@ def save_node_mantra(self, node, id):
# Render Frame
thumb.parm("render").pressButton()


# CleanUp
thumb.destroy()
if os.path.exists(path+".exr"):
os.remove(path+".exr")

return True


Expand Down Expand Up @@ -1400,3 +1429,24 @@ def fill_values(self):
self.line_workdir.setText(self.directory)
self.line_rendersize.setText(str(self.rendersize))
self.line_thumbsize.setText(str(self.thumbsize))


class AboutDialog(QDialog):
def __init__(self):
super(AboutDialog, self).__init__()
self.script_path = os.path.dirname(os.path.realpath(__file__))

## LOAD UI
## Load UI from ui.file
loader = QtUiTools.QUiLoader()
file = QFile(self.script_path + '/About.ui')
file.open(QFile.ReadOnly)
self.ui = loader.load(file)
file.close()

# set main layout and attach to widget
mainLayout = QVBoxLayout()
mainLayout.addWidget(self.ui)
mainLayout.setContentsMargins(0, 0, 0, 0) # Remove Margins

self.setLayout(mainLayout)
Loading

0 comments on commit a709a1b

Please sign in to comment.