Graphics

 View Only
  • 1.  Replacing images with a mask from sequencer

    Posted 07-19-2012 16:41
    Hi all,

    I have the next challenge: I have a quad on which I want to map a image with a mask (a material with one shader containing a mask and a second shader containing an image). So far so good, but since I have more pictures I want to be able to do that from the sequencer.

    Now I can not do that from the sequencer directly, because if I publish the material of my quad and I assign an imagefile to it, it will replace my entire material by the new imagefile, including my mask. So as a solution to this I created a second quad (set to not visible) with a new material (just one shader with the image) and my intention was to use scripting to get the shader from material of the second quad (containing the picture assigned in the sequencer) and add that shader to the material of the first quad (initially only containing the mask). The mask of the first quad should than interact with the added shader from the second quad and create the effect I wanted, but nothing happens when I assign images in the sequencer even though every line of code is executed (I checked that).

    So I have the following objects:

    "quadPicture" - "matPicture" - "shaderMask"

    "quadDummy" - "matDummy" - "shaderPicture"

    And I have this code in the OnSceneOnline-event:

    dim xBaseObjectDummy, xBaseObjectPicture as xpBaseObject

    dim xMaterialDummy, xMaterialPicture as xpMaterial

    dim xBaseShader as xpBaseShader

    if Self.GetObjectByName("quadDummy", xBaseObjectDummy) then

    if xBaseObjectDummy.GetMaterial(0, xMaterialDummy) then

    if xMaterialDummy.GetShaderByName("shaderPicture", xBaseShader) then

    if Self.GetObjectByName("quadPicture", xBaseObjectPicture) then

    if xBaseObjectPicture.GetMaterial(0, xMaterialPicture) then

    xMaterialPicture.AddShader("Texture2D", 1, xBaseShader)

    end if

    end if

    end if

    end if

    end if



    I can easily solve this using the API, but I don't want a separate application and do it from within XPression itself, so does anyone have a clue why this doesn't work? In theory (in mine anyway) it should.

    Kind regards,

    Gerard


  • 2.  RE: Replacing images with a mask from sequencer

    Posted 07-23-2012 20:06
    Hi Gerard,

    It looks like you are trying to use the GetShaderByName and AddShader calls to "copy" a shader from one material to another. Unfortunately that isn't how AddShader() works. AddShader will add a new *empty* shader to the material and return you a handle to the new empty shader. You could perhaps use xBaseShader.FileName to get the file the first material points to and then use .SetFileName to set that file in the new shader you created.

    #XPression


  • 3.  RE: Replacing images with a mask from sequencer

    Posted 07-26-2012 08:20
    Hi Brian,

    Thansk for clearing that up. From the helpfile for the SDK it wasn't clear what the true function was of the AddShader methode. It seemed to me that you could add you own shader into a material, but apparently instead of adding your own shader, XPression creates one for you and adds that to the material returing a reference to it. Is it possible you could run through the entire helpfile for the SDK and clarify those things in the file; there are alot of other 'mysterious' functions which could use some additional explanation.

    To get back to the subject: I now used the xBaseShader.Filename as you suggested and this works fine when assigning different materials from the sequencer, but when I directly assign image files to a quad, the xBaseShader.Filename returns an empty string. This sounds to me like a bug since I would expect to get the filename of the assigned image file.

    #XPression