Skip to content

Commit

Permalink
Merge pull request #1 from UTS-AnimalLogicAcademy/pipe_502
Browse files Browse the repository at this point in the history
integration into ala pipeline; add support for paint across uv tile w…
  • Loading branch information
fdan authored Mar 26, 2021
2 parents 15fb471 + 38fc9c8 commit 473f8b3
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 101 deletions.
113 changes: 111 additions & 2 deletions RenderMan/RendermanPrefsPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ Dialog
alg.settings.setValue("RMSTREE", rmsPathField.text)
// alg.log.info("RMSTREE = "+rmsPathField.text)
}
if (oiioPathField.text != "")
{
alg.settings.setValue("OIIO_HOME", oiioPathField.text)
// alg.log.info("OIIO_HOME = "+oiioPathField.text)
}
if (ocioPathField.text != "")
{
alg.settings.setValue("OCIO", ocioPathField.text)
// alg.log.info("OCIO = "+ocioPathField.text)
}
if (exportPathField.text != "")
{
alg.settings.setValue("saveTo", exportPathField.text)
Expand All @@ -64,6 +74,8 @@ Dialog
{
rmanPathField.readPrefs()
rmsPathField.readPrefs()
oiioPathField.readPrefs()
ocioPathField.readPrefs()
exportPathField.readPrefs()
}

Expand All @@ -86,7 +98,7 @@ Dialog
{
color: "#292929"
implicitWidth: 600
implicitHeight: 180
implicitHeight: 240
anchors.fill: parent
property var text_color: "#c0c0c0"

Expand Down Expand Up @@ -203,13 +215,110 @@ Dialog
}

RowLayout {
id: exportlayout
id: oiiolayout
x:10; y:100
height: 30
width: parent.width
spacing: 6
Layout.fillWidth: true

Text {
id: oiioPathLabel
text: "OpenImageIO:"
horizontalAlignment: Text.AlignRight
color: "#e6e6e6"
Layout.minimumWidth: 150
Layout.maximumWidth: 150
}
RendermanTextField {
id: oiioPathField
placeholderText: "path to OIIO installation"
anchors.left: oiioPathLabel.right
anchors.right: oiioPathButton.left
anchors.leftMargin: 4
anchors.rightMargin: 4

function readPrefs()
{
text = alg.settings.value("OIIO_HOME")
}

Component.onCompleted: {
readPrefs()
}
}
RendermanButton
{
id: oiioPathButton
text: "pick"
width: 40
height: 10
anchors.right: oiiolayout.right
anchors.rightMargin: 20
onClicked: {
folderPickerDialog.fieldid = oiioPathField
folderPickerDialog.setVisible(true)
}
}
}

RowLayout {
id: ociolayout
x:10; y:130
height: 30
width: parent.width
spacing: 6
Layout.fillWidth: true

Text {
id: ocioPathLabel
text: "OpenColorIO Config:"
horizontalAlignment: Text.AlignRight
color: "#e6e6e6"
Layout.minimumWidth: 150
Layout.maximumWidth: 150
}
RendermanTextField {
id: ocioPathField
placeholderText: "path to OCIO config"
anchors.left: ocioPathLabel.right
anchors.right: ocioPathButton.left
anchors.leftMargin: 4
anchors.rightMargin: 4

function readPrefs()
{
text = alg.settings.value("OCIO")
}

Component.onCompleted: {
readPrefs()
}
}
RendermanButton
{
id: ocioPathButton
text: "pick"
width: 40
height: 10
anchors.right: ociolayout.right
anchors.rightMargin: 20
onClicked: {
folderPickerDialog.fieldid = ocioPathField
folderPickerDialog.setVisible(true)
}
}
}


RowLayout {
id: exportlayout
x:10; y:160
height: 30
width: parent.width
spacing: 6
Layout.fillWidth: true

Text {
id: exportPathLabel
text: "Export to:"
Expand Down
65 changes: 31 additions & 34 deletions RenderMan/renderman.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ function isUDIMProject(document)

function exportAssets(bxdf) {

// bail out if the prefs are not all filled
// prefs are optional:
//
var valid = checkPrefs()
if (!valid) {
alg.log.error("RenderMan: Please open the configure panel and fill all fields !")
return
}
// var valid = checkPrefs()
// if (!valid) {
// alg.log.error("RenderMan: Please open the configure panel and fill all fields !")
// return
// }

alg.log.info("\n\n\n\n")
var toks = alg.project.url().split('/')
Expand All @@ -117,10 +117,10 @@ function exportAssets(bxdf) {
var tab4 = tab3 + tab

// Query export path
//
exportPath = osPath(alg.mapexport.exportPath())
exportPath += sep + "RenderMan" + sep
jsonFilePath = exportPath + "RmanExport.json"
exportPath = osPath(alg.mapexport.exportPath()) + "/"
jsonFilePath = exportPath + ".temp.json"

// exportPath = jsonPath(alg.settings.value("saveTo"))

// Export masks
//
Expand All @@ -138,6 +138,8 @@ function exportAssets(bxdf) {
sp_version: alg.version.painter,
RMANTREE: jsonPath(alg.settings.value("RMANTREE")),
RMSTREE: jsonPath(alg.settings.value("RMSTREE")),
OIIO_HOME: jsonPath(alg.settings.value("OIIO_HOME")),
OCIO: jsonPath(alg.settings.value("OCIO")),
bxdf: bxdf,
udim: isUDIM,
saveTo: jsonPath(alg.settings.value("saveTo")),
Expand All @@ -146,10 +148,16 @@ function exportAssets(bxdf) {

// Parse all materials (texture sets)
//

alg.mapexport.setProjectExportPreset("ALA_export_UDIM_Seamless")
alg.mapexport.showExportDialog()

var mobj = null
for (matIdx = 0; matIdx < document.materials.length; matIdx++)
{
var material = document.materials[matIdx].name
var useUVTiles = alg.texturesets.structure(alg.texturesets.getActiveTextureSet()).useUVTiles

if (!isUDIM || matIdx == 0)
{
mobj = {
Expand All @@ -163,35 +171,24 @@ function exportAssets(bxdf) {
for (channelIdx = 0; channelIdx < numChannels; channelIdx++)
{
var thisChannel = document.materials[matIdx].stacks[0].channels[channelIdx]
// alg.log.info("RenderMan: | " + thisChannel)
alg.log.info("RenderMan: | " + thisChannel)

// Skip the height channel: we prefer normal maps.
if (thisChannel == "height")
{
// alg.log.info("RenderMan: |_ skip")
continue
}
var colorspace;

var output = exportPath
if (isUDIM)
output += thisChannel + "." + material + ext
else
output += material + "_" + thisChannel + ext
if (thisChannel.match(/^(basecolor|diffuse|emissive|specular)$/)) {
colorspace = "acescg"
}
else{
colorspace = "linear"
}

var t0 = new Date().getTime()
if (thisChannel == "normal")
{
// Make sure the normals are correctly configured to combine
// mesh + height + normal.
alg.mapexport.saveConvertedMap([material], "normal_directx", output)
if (isUDIM || useUVTiles) {
var output = exportPath + "_MAPID__" + thisChannel + "_" + colorspace + ext
}
else
{
// regular map export
alg.mapexport.save([material, thisChannel], output)
else{
var output = exportPath + material + thisChannel + "_" + colorspace + ext
}
var t1 = new Date().getTime()
alg.log.info("RenderMan: |_ Exported in " + ((t1-t0)/1000.0).toFixed(2) + " sec.: " + output)


try {
mobj.channels[thisChannel].push(jsonPath(output))
Expand Down
Loading

0 comments on commit 473f8b3

Please sign in to comment.