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