This script is for combine a Roughness texture and a Metallic map texture together, Since I can’t do it on blender(I hate shadergraph for some reason).
You need to keep Roughness texture(Black&White) in your clipboard while having Metallic map(Also Black&White)’s cel active on aseprite when using this script. Result will be create as new layer name “Metallic_map”.
*edit I use color from Roughness instead of metallic.(fixed)
I not sure if alpha channel need to be invert for unity’s metallic alpha setting.
app.transaction(function()
local Metallic = app.image
local Roughness = app.clipboard.image
if not Roughness then return app.alert ("Something wrong with Metallic layer") end
if not Roughness then return app.alert ("Need to copy Roughness") end
if not Metallic.cel then return app.alert ("Something wrong with cel") end
local ln = app.sprite:newLayer()
if not ln then return app.alert ("Something wrong with new layer") end
if not Metallic.cel.frame then return app.alert ("Can't get target frame") end
for cx = 0 , Metallic.width, 1 do
for cy = 0 , Metallic.height, 1 do
local rc = Roughness:getPixel(cx,cy)
if not rc then return app.alert ("Can't get Roughness pixel") end
local mc = Metallic:getPixel(cx,cy)
if not mc then return app.alert ("Can't get Metallic pixel") end
local NR = app.pixelColor.rgbaR(mc)
if not NR then return app.alert ("Can't get Metallic color(r)") end
local NG = app.pixelColor.rgbaG(mc)
if not NG then return app.alert ("Can't get Metallic color(g)") end
local NB = app.pixelColor.rgbaB(mc)
if not NB then return app.alert ("Can't get Metallic color(b)") end
local NA = app.pixelColor.rgbaR(rc)
if not NA then return app.alert ("Can't get Roughness color(r)") end
app.useTool{
tool="pencil",
color=Color{ r=NR, g=NG, b=NB, a=NA },
brush=Brush(1),
points={Point{x=cx, y=cy}},
layer=ln,
ink=0
}
end
end
ln.name = "Metallic_map"
end)
This is my first lua script ever made, It took me 4 hour. And I don’t know why I decide to do it this way.