View Full Version : alpha masks and pastebitmap()
12-05-2010, 12:03 AM
i'm writing a little script that's supposed to render the viewport you're looking at and paste a pre-alpha masked on top of that, like you would in photoshop.
now, I have a problem: according to what i've seen in maxscript help, i'm supposed to do that using the pasteBitmap() method, using the type:#composite line.
here's my code: (it's pretty short and I kept it structured)
render1 = render camera vfb:on outputwidth: 1280 outputheight:720 force2sided:on
Watermark = openBitmap "C:\\Users\\Mattias\\Desktop\\NAMING TEMPLATE.tga"
finalRender = bitmap (1280) (720) color:backgroundcolor
pasteBitmap render1 finalRender(box2 0 0 1280 720)[0,0]
pasteBitmap Watermark finalRender(box2 0 0 1280 720)[0,0] type:#composite
the solution is probably something ridiculously easy, but I just can't seem to find it :S
i've already tried it with a .png image, so I don't think the file format is a problem
12-21-2010, 01:19 AM
guys, I think i've found the problem, but I don't seem to be able to solve it:
the problem should be somewhere in the alpha of the image that i'm pasting on top.
when I render with my script, I get this result:
where I should get this: (done with photoshop, the whole point of the script is not to have to open photoshop and paste the watermark on top of the render)
so I would sincerely appreciate it is someone could lend me a hand here...
the image i'm pasting on top is a .tga file with an opacity map in it's alpha channel, saved as a 24bit per pixel image. the render is the default output of a max render, meaning no file format yet.
12-21-2010, 02:09 AM
what do you want to get? do you want to know why pasteBitmap does not work right? or do you want to add a watermark to an image? if you are looking for a solution of the second issue just do it using per pixel method. is it slow? might be. but the rendering of an image usually is dozen times slower.
12-21-2010, 02:11 AM
yes the second thing :)
i'll try to work out the per pixel method, i'll let you know how it turns out :)
12-21-2010, 02:26 AM
yeah... I can't get the per pixel thing to work i'm afraid, so if someone would be kind enought to tell me how to sample an entire bitmap to see where a pixel should be transparent and where not? the code i'm writing here is messed up, even though I got it from the archives of cgsociety. (there was a similar issue some years ago apparently, but they didn't solve it eventually... apparently no one on the entire internet that ever had this problem ever solved it)
have you tried using type:#blend instead of #composite?
12-24-2010, 10:34 AM
yes, but the blend mode just gives a 50% opacity to the top image, without using the alpha channel...
Works perfectly for me using a PNG. Perhaps give that a try.
12-24-2010, 11:36 AM
man, you just solved a very big problem! I don't know why it didn't work previously, but it does now :D you have my eternal gratitude, I owe you one! :D
12-24-2010, 11:42 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.