Notifications
Clear all
[Closed] SVG as a mask
Dec 06, 2016 7:41 pm
I’d like to have a mask without saving it to disk.
So I’ve tried to use maxscript generated svg as mask but it doesn’t seem to work that way.
solution:
And it works as expected with alphaSource property set to RGB Intensity
v.alphaSource = 1
fn addRect x y width height = (
"<rect x=\"" + (x*width) as string + "\" y=\"" + (y*height) as string + "\" height=\"" + height as string + "\" width=\"" + width as string + "\" style=\"fill: #ffffff\"/>"
)
fn generateSrc = (
src = "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">"
size = 1024.0
w = 64
h = 64
width = size / w
height = size / h
for y = 1 to h do (
for x = 1 to w do (
chance = (x as float) / w
if random 0.0 1.0 <= chance do (
src += addRect (x-1) (y-1) width height
)
)
)
src += "</svg>"
src
)
delete objects
v = vectormap()
v.SetSvgString (generateSrc())
v.alphaSource = 1
m = Mix()
m.mask = v
meditMaterials[1].diffuseMap = m
meditMaterials[2].diffuseMap = v
MatEditor.mode = #basic
MatEditor.open()
activemeditslot = 1
actionMan.executeAction 2 "40296"
activemeditslot = 2
actionMan.executeAction 2 "40296"