Graphics

 View Only
  • 1.  More than one Filepath in a script?

    Posted 08-15-2019 19:22

    Hey guys, 

        I am new to the scripting aspect of all of this, and I just encountered an issue.

    I have a script in my scene that can be used to re-skin an section of my element with the colors / logo of ANY of the 32 NFL teams.  That script is this:

    dim P1Logo as xpMaterial
    dim P1LogoShader as xpBaseShader
    dim P1GScale as xpMaterial
    dim P1GScaleShader as xpBaseShader
    dim P1Primary as xpMaterial
    dim P1PrimaryShader as xpBaseShader
    dim P1Secondary as xpMaterial
    dim P1SecondaryShader as xpBaseShader
    dim P1Team as xpTextObject
    dim Filepath as xpTextObject

    Self.GetObjectByName("FILE PATH", Filepath)

    Self.Project.GetMaterialByName("P1 Logo 6006", P1Logo)
    P1Logo.GetShader(0, P1LogoShader)
    Self.Project.GetMaterialByName ("P1 Logo GS 6006", P1GScale)
    P1GScale.GetShader(0, P1GScaleShader)
    Self.Project.GetMaterialByName("P1 Primary 6006", P1Primary)
    P1Primary.GetShader(0, P1PrimaryShader)
    Self.Project.GetMaterialByName("P1 Secondary 6006", P1Secondary)
    P1Secondary.GetShader(0, P1SecondaryShader)
    Self.GetObjectByName("P1 Team", P1Team)

     

    P1LogoShader.SetFileName(Filepath.text & P1Team.text & "_Logo.png")
    P1GScaleShader.SetFileName(Filepath.text & P1Team.text & "_Logo.png")
    P1PrimaryShader.SetFileName(Filepath.text & P1Team.text & "_Primary.png")
    P1SecondaryShader.SetFileName(Filepath.text & P1Team.text & "_Secondary.png")

     

    Then, I also have a player image which gets revealed with these colored 'sleeves' .  To do this, I have one object with a player image, and a second object with subrtractive matte of that same image, so the sleeves have a silhouette effect on the sleeve reveal.  I need the datalinq which calls up the player image to assign the same png file to both materials (P-IMG Head-1 and P-MATTE Head-1), and have done this before with a script like this:

    dim PlayerImg, PlayerMask as xpBaseObject
    dim PlayerImgMat, PlayerMaskMat as xpMaterial
    dim PlayerImgSha, PlayerMaskSha as xpBaseShader
    dim FilePath as String

    'get file from image for head shot-----------------------------

    Self.GetObjectByName("P-IMG Head-1", PlayerImg)
    PlayerImg.GetMaterial(0, PlayerImgMat)
    PlayerImgMat.GetShader(0, PlayerImgSha)
    FilePath = PlayerImgSha.FileName

    'set file to mask head shot--------------------------------

    Self.GetObjectByName("P-MATTE Head-1", PlayerMask)
    PlayerMask.GetMaterial(0, PlayerMaskMat)
    PlayerMaskMat.GetShader(0, PlayerMaskSha)
    PlayerMaskSha.SetFileName(FilePath)

     

    The problem is, I have already declared the 'filepath' as an XPTextObject in the earlier script, and here I need an object to pull a filepath based of the string value of a datalinq key instead of an XPTextObject.  Is this possible?  Is there someway to setup a 'FilePath-1" and "Filepath-2"? Or does it not work that way, and I have an unattainable goal?

    I've made all the lines dealing with Filepath bold to make them easier to find.

    Thanks in advance!

       - Willie 



  • 2.  RE: More than one Filepath in a script?

    Posted 08-15-2019 19:35

    Hey Willie,

     

    All you need to do is re-name the variable FilePath to something different, Here is an example.

     

    dim P1Logo, P1GScale, P1Primary, P1Secondary as xpMaterial
    dim P1LogoShader, P1GScaleShader, P1PrimaryShader, P1SecondaryShader as xpBaseShader
    dim P1Team, Filepath as xpTextObject

    Self.GetObjectByName("FILE PATH", Filepath)

    Self.Project.GetMaterialByName("P1 Logo 6006", P1Logo)
    P1Logo.GetShader(0, P1LogoShader)
    Self.Project.GetMaterialByName ("P1 Logo GS 6006", P1GScale)
    P1GScale.GetShader(0, P1GScaleShader)
    Self.Project.GetMaterialByName("P1 Primary 6006", P1Primary)
    P1Primary.GetShader(0, P1PrimaryShader)
    Self.Project.GetMaterialByName("P1 Secondary 6006", P1Secondary)
    P1Secondary.GetShader(0, P1SecondaryShader)
    Self.GetObjectByName("P1 Team", P1Team)

     

    P1LogoShader.SetFileName(Filepath.text & P1Team.text & "_Logo.png")
    P1GScaleShader.SetFileName(Filepath.text & P1Team.text & "_Logo.png")
    P1PrimaryShader.SetFileName(Filepath.text & P1Team.text & "_Primary.png")
    P1SecondaryShader.SetFileName(Filepath.text & P1Team.text & "_Secondary.png")

     

    'Then, I also have a player image which gets revealed with these colored 'sleeves' . To do this, I have one object with a player image, and a second object with subrtractive matte of that same image, so the sleeves have a silhouette effect on the sleeve reveal. I need the datalinq which calls up the player image to assign the same png file to both materials (P-IMG Head-1 and P-MATTE Head-1), and have done this before with a script like this:

    dim PlayerImg, PlayerMask as xpBaseObject
    dim PlayerImgMat, PlayerMaskMat as xpMaterial
    dim PlayerImgSha, PlayerMaskSha as xpBaseShader
    dim MatFilePath as String

    'get file from image for head shot-----------------------------

    Self.GetObjectByName("P-IMG Head-1", PlayerImg)
    PlayerImg.GetMaterial(0, PlayerImgMat)
    PlayerImgMat.GetShader(0, PlayerImgSha)
    MatFilePath = PlayerImgSha.FileName

    'set file to mask head shot--------------------------------

    Self.GetObjectByName("P-MATTE Head-1", PlayerMask)
    PlayerMask.GetMaterial(0, PlayerMaskMat)
    PlayerMaskMat.GetShader(0, PlayerMaskSha)
    PlayerMaskSha.SetFileName(MatFilePath)


    #XPression


  • 3.  RE: More than one Filepath in a script?

    Posted 08-15-2019 19:42

    Beautiful!  I will test that now.  I thought it might be as simple as that, but I thought perhaps 'FilePath' was a specific call that if meddled with, wouldn't know what to do, if that makes sense.


    #XPression


  • 4.  RE: More than one Filepath in a script?

    Posted 08-15-2019 19:45

    Tested, and it works perfectly, many thanks!


    #XPression


  • 5.  RE: More than one Filepath in a script?

    Posted 08-16-2019 01:28

    Brandon - I hope you check back in on this... I am having a problem

    If I have one of these scenes online, and I change the datalinq key for the player on a completely different scene in the sequencer (but with the same sort of setup and the identical script), the image mask on the live scene will change to the mask of the player from that offline scene.

    The problem is even worse in scenes where I have 2 or more player images (and I did iterate the script so those are looking at the other object P-IMG Head-2, P-MATTE Head-2, etc) where the second player's matte changes perfectly one one, but on the next 2-up scene, the second player's mask won't change at all.

    I feel like something needs to happen to localize the script to the individual scene (kind of like how VL works), is this possible, or is there something else I am doing wrong?


    #XPression


  • 6.  RE: More than one Filepath in a script?

    Posted 08-16-2019 16:55

    Willie, what you are describing as your first issue sounds like datalinq is triggering the SetFile ahead of another scene going online, which means that  the filepath is changing and refreshing across all materials since the shader isn't specific to a scene, but a global material. Which is one of the drawbacks of doing it this way. What I would maybe try is instead of feeding a value directly via your datalinq, try doing so with another text object hidden within your scene. Then set the value of dlinq key to it by using the @. Maybe that would make it so that the filename wouldn't actually update until a scene has rendered with text in it. Alternatively, you might want to move your script into a script  event that the the update isn't actually triggering. 

    As far as your second issue, without seeing the script, I couldn't fully guess where the problem is, but it might be a matter of the fact that the shader hasn't been renamed or there's a mismatch in variables of your mask (like what you declared your shader as, and the name of it within material editor).

    More to it, maybe you are too far committed to this workflow, but we generally use an XML or JSON file with relevant attributes to drive all of this stuff via datalinq keys rather than shaders. For instance we have a team file XML that has relevant info in it (name, city, full team name, tricode, etc.) but we hardcode filepaths in there. From how you are describing you need, you could  accomplish what you are trying to do almost entirely without scripting.


    #XPression


  • 7.  RE: More than one Filepath in a script?

    Posted 08-16-2019 18:07

    Hey Martin, 

         So, to give you more insight into how all this is meant to work.  We DO have Excel from the client with all manner of information in it, including file paths to 3 types of player images (Head Shots, Action Shot, and Studio Shots).  All of that is actually working fine with traditional datalinq keys and some VL to switch between the image types.  Where things are going a little sideways for me and where the script is coming into play has to do with the MATTE material we are using to reveal the player images.  These are using materials which have the same image file in them as the visible player image, but the settings of the material are such that it works as a sort of reverse mask wherein the player silhouette is the alpha.  This allows the colored 'sleeves' to reveal the player in a particular way.

         What needs to happen here, is for that matte material to update to have the image file of the currently selected (via DL key) populate that MATTE material, as we don't have a folder full of  images formatted that way to pull from.

          I have considered that perhaps I need unique materials for every scene, but when we've had the folks at Ross help me with that sort of thing in the past, that wasn't a step that we took.

         I am attaching below a few screenshots which show the reveal in progress, the resolve, the materials and my object hierarchy to hopefully clear things up for you and anyone else who wants to help me solve this.  The full script relevant to the functionality I seek is as follow:

    dim PlayerImg, PlayerMask as xpBaseObject
    dim PlayerImgMat, PlayerMaskMat as xpMaterial
    dim PlayerImgSha, PlayerMaskSha as xpBaseShader
    dim MatFilePath as String

    'get file from image for head shot-----------------------------

    Self.GetObjectByName("P-IMG Head-1", PlayerImg)
    PlayerImg.GetMaterial(0, PlayerImgMat)
    PlayerImgMat.GetShader(0, PlayerImgSha)
    MatFilePath = PlayerImgSha.FileName

    'set file to mask head shot--------------------------------

    Self.GetObjectByName("P-MATTE Head-1", PlayerMask)
    PlayerMask.GetMaterial(0, PlayerMaskMat)
    PlayerMaskMat.GetShader(0, PlayerMaskSha)
    PlayerMaskSha.SetFileName(MatFilePath)

    'get file from image for drama shot-----------------------------

    Self.GetObjectByName("P-IMG Dram-1", PlayerImg)
    PlayerImg.GetMaterial(0, PlayerImgMat)
    PlayerImgMat.GetShader(0, PlayerImgSha)
    MatFilePath = PlayerImgSha.FileName

    'set file to mask drama shot--------------------------------

    Self.GetObjectByName("P-MATTE Dram-1", PlayerMask)
    PlayerMask.GetMaterial(0, PlayerMaskMat)
    PlayerMaskMat.GetShader(0, PlayerMaskSha)
    PlayerMaskSha.SetFileName(MatFilePath)

    'get file from image for action shot-----------------------------

    Self.GetObjectByName("P-IMG Action-1", PlayerImg)
    PlayerImg.GetMaterial(0, PlayerImgMat)
    PlayerImgMat.GetShader(0, PlayerImgSha)
    MatFilePath = PlayerImgSha.FileName

    'set file to mask action shot--------------------------------

    Self.GetObjectByName("P-MATTE Action-1", PlayerMask)
    PlayerMask.GetMaterial(0, PlayerMaskMat)
    PlayerMaskMat.GetShader(0, PlayerMaskSha)
    PlayerMaskSha.SetFileName(MatFilePath)


    'get file from image for head shot-----------------------------

    Self.GetObjectByName("P-IMG Head-2", PlayerImg)
    PlayerImg.GetMaterial(0, PlayerImgMat)
    PlayerImgMat.GetShader(0, PlayerImgSha)
    MatFilePath = PlayerImgSha.FileName

    'set file to mask head shot--------------------------------

    Self.GetObjectByName("P-MATTE Head-2", PlayerMask)
    PlayerMask.GetMaterial(0, PlayerMaskMat)
    PlayerMaskMat.GetShader(0, PlayerMaskSha)
    PlayerMaskSha.SetFileName(MatFilePath)

    'get file from image for drama shot-----------------------------

    Self.GetObjectByName("P-IMG Dram-2", PlayerImg)
    PlayerImg.GetMaterial(0, PlayerImgMat)
    PlayerImgMat.GetShader(0, PlayerImgSha)
    MatFilePath = PlayerImgSha.FileName

    'set file to mask drama shot--------------------------------

    Self.GetObjectByName("P-MATTE Dram-2", PlayerMask)
    PlayerMask.GetMaterial(0, PlayerMaskMat)
    PlayerMaskMat.GetShader(0, PlayerMaskSha)
    PlayerMaskSha.SetFileName(MatFilePath)

    'get file from image for action shot-----------------------------

    Self.GetObjectByName("P-IMG Action-2", PlayerImg)
    PlayerImg.GetMaterial(0, PlayerImgMat)
    PlayerImgMat.GetShader(0, PlayerImgSha)
    MatFilePath = PlayerImgSha.FileName

    'set file to mask action shot--------------------------------

    Self.GetObjectByName("P-MATTE Action-2", PlayerMask)
    PlayerMask.GetMaterial(0, PlayerMaskMat)
    PlayerMaskMat.GetShader(0, PlayerMaskSha)
    PlayerMaskSha.SetFileName(MatFilePath)


    #XPression


  • 8.  RE: More than one Filepath in a script?

    Posted 08-16-2019 18:09

    One note - there are 4 of each type of image / matte, as we have templates set up to compare as many as 4 players at once


    #XPression


  • 9.  RE: More than one Filepath in a script?

    Posted 08-16-2019 22:26

    Ok, so after a chat and remote session with the king himself, Mr Andrew Sampson, we got it sorted.  I needed to uktimate ly to do 2 things:

    1 - Make a 'preview' version of the matte material and modify the OnPreviewRender script to update that separately from the regular matte that updates via the script on OnOnline, so that changes to offline scenes didn't impact that which was currently onoine.

    2 - one of the image types we have is Action Shot, but the client hasn't yet produced any of these, so the 'Clear On Empty' datalinq option was unbinding the material, causing the script to fail.

     

    Posting this here for posterity in the event similar troubles befall another.  Thank you both for responding and offering assistance.


    #XPression