Practicing OSL with Renderman for Maya

General / 21 July 2020

Circle:

Circle Used in Shading Network:

Circle OSL Code:

shader circle(
    float s_center = 0.5,
    float t_center = 0.5,
    float radius = 0.4,
    float s = 0 
        [[
        int lockgeom = 0,
        string widget = "null",
        ]],
    float t = 0 
        [[
        int lockgeom = 0,
        string widget = "null",
        ]],
        
    color base_color = color(1,1,1),
    color pat_color = color(1,0,0),
    output color resultRGB = 0)
{
// i am shading a location in the middle of the "s" texture space
float ss = mod(s,1);
    float tt = mod(t,1);
    float a = ss - s_center;
    float b = tt - t_center;
    float d = sqrt((a*a) + (b*b));
    if (d <= radius)
        resultRGB = pat_color;
    else
        resultRGB = base_color;
}

Hollow Circle:

Hollow Circle Used in Shading Network:

Hollow Circle OSL Code:

shader circle_hollow(
    float s_center = 0.5,
    float t_center = 0.5,
    float smallRadius = 0.2,
    float bigRadius = 0.4,
    float s = 0 
        [[
        int lockgeom = 0,
        string widget = "null",
        ]],
    float t = 0 
        [[
        int lockgeom = 0,
        string widget = "null",
        ]],
        
    color base_color = color(1,1,1),
    color pat_color = color(1,0,0),
    output color resultRGB = 0)
{
// i am shading a location in the middle of the "s" texture space
float ss = mod(s,1);
    float tt = mod(t,1);
    float a = ss - s_center;
    float b = tt - t_center;
    float d = sqrt((a*a) + (b*b));
    if (d <= smallRadius || d>= bigRadius)
        resultRGB = pat_color;
    else
        resultRGB = base_color;
}

Cross:

Cross Used in Shading Network:

Cross OSL Code:

shader UBar(
    float s = 0 
        [[
        int lockgeom = 0,
        string widget = "null",
        ]],
    float t = 0 
        [[
        int lockgeom = 0,
        string widget = "null",
        ]],
    //float s_offset = 0.5,
    float s_offset = 0.1,
    float s_width = 0.223,
    float t_offset = 0.5,
    float t_width = 0.223,
    
    color base_color = color(1,1,1),
    color pat_color = color(1,0,0),
    output color resultRGB = 0)
{
// i am shading a location in the middle of the "s" texture space
float left = s_offset - s_width/2;
float right = s_offset + s_width/2;
float top = t_offset - t_width/2;
float bottom = t_offset + t_width/2;
if(s>= left && s<= right || t>= top && t<= bottom)
    resultRGB = base_color;
else
    resultRGB = pat_color;
}
Report

Trying Out Python Functions in Substance Designer

General / 21 July 2020

I saw there wasn't a ton of documentation on using the python functions in Substance Designer so I thought I would share my findings and what I did to create an animated texture.



The flow speed slider allows the viewer to change the speed and direction of the animation.

Technical Breakdown:

First selecting the overall graph add an input parameter of a float and set the desired default values. 


Then within the initial wave node in the bottom left add an empty function that will be used to drive the color and movement of the liquid by multiplying the previously created input parameter and time.


Creating an FX Map Node to distribute the bubble across the texture sheet.


Creating a float variable for the pattern offset and pattern rotation to be implemented in the Color/Luminosity.


Conclusion:

Overall there were a lot of challenges since there is not as much documentation compared to other areas in Substance Designer and even less documentation for implementing animated materials into Unreal Engine, which was one of my initial goals.

Report

GUI Batch Denoise for Renderman

General / 21 July 2020



How the GUI Denoise works:

  1. Search for the first image in a sequence that you would like to be denoised.
  2. Then press the "Create Denoise Script" to create a script file in the folder the images are located called "run_denoise"
  3. Reads the list of files.
  4. Creates a duplicated denoised list of exr files in numerical order and renames "variance" as "filtered".

Open this link in QT4 Designer to run the code:

https://sdm.scad.edu/faculty/mkesson/tech312/wip/best/winter2020/rachel_howard/batch_denoise_gui/demo.ui

Python code:

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import uic      import sys
import os
import math
import os.path
import run_denoise
reload(run_denoise)
#from connection_utils import *      #________________________________________________________ #                     Widget Names #________________________________________________________ #
#                       doit_Button #       

from PyQt4.QtCore import *

from PyQt4.QtGui import *

from PyQt4 import uic

  

    

import sys

import os

import math

import os.path

import run_denoise

reload(run_denoise)

#from connection_utils import *

  

  

  

#________________________________________________________

#                     Widget Names

#________________________________________________________

#

#                       doit_Button

#                        search_button

#                        exr_pathLine

#                        exr_nameLine

#                        confirmation_Line

#                        headericon_Label

#________________________________________________________

class DemoDialog(QDialog):

    def __init__(self, parent=None):

        super(DemoDialog, self).__init__(parent)

        pathToUi = os.path.join(os.path.dirname(__file__), 'ui', 'demo.ui')

        self.ui = uic.loadUi(pathToUi,self)

    #------------------------------------------------------------------------------------------

        self.pathToHeaderIcon = os.path.join(os.path.dirname(__file__), 'icons', 'header_image.jpg')

    #------------------------------------------------------------------------------------------

        self.setWindowFlags(Qt.WindowStaysOnTopHint)

        self.makeConnections()

        self.ui.show()    

    #________________________________________________

    def makeConnections(self):

        #------------------------------------------------------------------------------------------

        pixmap = QPixmap(self.pathToHeaderIcon)

        pixmap_resized = pixmap.scaled(400, 405)

        self.ui.headerIcon_Label.setPixmap(pixmap_resized)

        self.ui.headerIcon_Label.setMask(pixmap_resized.mask())

        self.ui.setFixedSize(421, 600) # optional

        #------------------------------------------------------------------------------------------

        self.ui.doit_Button.clicked.connect(self.doitAction)

        self.exr_nameLine = self.ui.exr_nameLine

        self.exr_pathLine = self.ui.exr_pathLine #QLineEdit

        self.search_button = self.ui.search_button.clicked.connect(self.openFileDialogAction)

        

    #________________________________________________

    def openFileDialogAction(self):

        fullpath = QFileDialog.getOpenFileName(self,("Open"), "/home/rhowar24/mount/stuhome/tech312", ("EXR Files (*.exr)"))

        #we want the path to the exr folder and the name of an exr file        

        self.exr_path = os.path.dirname( str(fullpath))

        self.exr_name = os.path.basename( str(fullpath))

        self.exr_pathLine.insert(self.exr_path)

        self.exr_nameLine.insert(self.exr_name)

  

    def doitAction(self):

        run_denoise.doit(self.exr_path,self.exr_name)

    

        self.confirmation_Line.clear()

        self.confirmation_Line.insert( 'Created "run_batch_denoise". Double click created script.')

        print script_path

         

        

#========================================================        

if __name__ == '__main__':

    app = QApplication(sys.argv)

    dialog = DemoDialog()

    dialog.show()

    sys.exit(app.exec_())


                 search_button #                        exr_pathLine #                        exr_nameLine #                        confirmation_Line #                        headericon_Label #________________________________________________________ # class DemoDialog(QDialog):    def __init__(self, parent=None):        super(DemoDialog, self).__init__(parent)        pathToUi = os.path.join(os.path.dirname(__file__), 'ui', 'demo.ui')        self.ui = uic.loadUi(pathToUi,self)    #------------------------------------------------------------------------------------------        self.pathToHeaderIcon = os.path.join(os.path.dirname(__file__), 'icons', 'header_image.jpg')    #------------------------------------------------------------------------------------------        self.setWindowFlags(Qt.WindowStaysOnTopHint)        self.makeConnections()        self.ui.show()        #________________________________________________    def makeConnections(self):        #------------------------------------------------------------------------------------------        pixmap = QPixmap(self.pathToHeaderIcon)        pixmap_resized = pixmap.scaled(400, 405)        self.ui.headerIcon_Label.setPixmap(pixmap_resized)        self.ui.headerIcon_Label.setMask(pixmap_resized.mask())        self.ui.setFixedSize(421, 600) # optional        #------------------------------------------------------------------------------------------        self.ui.doit_Button.clicked.connect(self.doitAction)        self.exr_nameLine = self.ui.exr_nameLine        self.exr_pathLine = self.ui.exr_pathLine #QLineEdit        self.search_button = self.ui.search_button.clicked.connect(self.openFileDialogAction)            #________________________________________________    def openFileDialogAction(self):        fullpath = QFileDialog.getOpenFileName(self,("Open"), "/home/rhowar24/mount/stuhome/tech312", ("EXR Files (*.exr)"))        #we want the path to the exr folder and the name of an exr file                self.exr_path = os.path.dirname( str(fullpath))        self.exr_name = os.path.basename( str(fullpath))        self.exr_pathLine.insert(self.exr_path)        self.exr_nameLine.insert(self.exr_name)      def doitAction(self):        run_denoise.doit(self.exr_path,self.exr_name)            self.confirmation_Line.clear()        self.confirmation_Line.insert( 'Created "run_batch_denoise". Double click created script.')        print script_path                 #========================================================        if __name__ == '__main__':    app = QApplication(sys.argv)    dialog = DemoDialog()    dialog.show()    sys.exit(app.exec_())


QT4 Designer GUI Layout:


Report