Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Displacement Map Visualizer QoL (#27392)
Browse files Browse the repository at this point in the history
* Update Displacement Map Visualizer.lua

* Add files via upload

* Fix background layer being offset

This was caused by not taking the cel's own bounds into account.
Aseprite doesn't make an image layer "full size" if it only covers a
small part of the sprite.

---------

Co-authored-by: Pieter-Jan Briers <[email protected]>
  • Loading branch information
TheShuEd and PJB3005 authored Apr 27, 2024
1 parent 2621e31 commit 2cefd0e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion Tools/SS14 Aseprite Plugins/Displacement Map Visualizer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,45 @@ dialog:canvas{

local layerDisplacement = findLayer(sprite, dialog.data["displacement-select"])
local layerTarget = findLayer(sprite, dialog.data["reference-select"])
local layerBackground = findLayer(sprite, dialog.data["background-select"])
-- print(layerDisplacement.name)
-- print(layerTarget.name)

local celDisplacement = layerDisplacement:cel(1)
local celTarget = layerTarget:cel(1)
local celBackground = layerBackground:cel(1)

-- Draw background
context:drawImage(
-- srcImage
celBackground.image,
-- srcPos
0, 0,
-- srcSize
celBackground.image.width, celBackground.image.height,
-- dstPos
celBackground.position.x * scale, celBackground.position.y * scale,
-- dstSize
celBackground.image.width * scale, celBackground.image.height * scale)

-- Apply displacement map and draw
local image = applyDisplacementMap(
sprite.width, sprite.height,
dialog.data["size"],
celDisplacement.image, celDisplacement.bounds,
celTarget.image, celTarget.bounds)

context:drawImage(image, 0, 0, image.width, image.height, 0, 0, image.width * scale, context.width, context.height)
context:drawImage(
-- srcImage
image,
-- srcPos
0, 0,
-- srcSize
image.width, image.height,
-- dstPos
0, 0,
-- dstSize
image.width * scale, image.height * scale)
end
}

Expand All @@ -120,6 +148,14 @@ dialog:combobox{
end
}

dialog:combobox{
id = "background-select",
label = "background layer",
options = layers,
onchange = function(ev)
dialog:repaint()
end
}

dialog:slider{
id = "size",
Expand Down
Binary file added Tools/SS14 Aseprite Plugins/Displacement Map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2cefd0e

Please sign in to comment.