Skip to content

Commit

Permalink
added a debug script for visual tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
nightcycle committed Aug 3, 2024
1 parent 549f02c commit 3cd6fa1
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 305 deletions.
Binary file added editable-clothing-util.rbxl
Binary file not shown.
2 changes: 1 addition & 1 deletion scripts/workspace/rojo-build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
rojo build --output package.rbxl dev.project.json
rojo build --output editable-clothing-util.rbxl dev.project.json
97 changes: 97 additions & 0 deletions src/Tuner.story.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
--!strict
-- Services
-- stylua: ignore start
-- Packages
local Maid = require(game:GetService("ReplicatedStorage"):WaitForChild("Packages"):WaitForChild("Maid"))
-- Modules
-- stylua: ignore end
-- Types
-- Constants
-- Variables
-- References
-- Class
return function(frame: Frame)
local maid = Maid.new()
task.spawn(function()
local Util = require(script.Parent)
local character: Model? = workspace:WaitForChild("Rig", 10) :: Model
assert(character)
local shirt: Shirt? = character:WaitForChild("Shirt", 10) :: Shirt?
assert(shirt)

local clothingImage: EditableImage = maid:GiveTask(Util.loadClothingImageAsync(shirt))

local function displayImage(editableImage: EditableImage): ImageLabel
local display = maid:GiveTask(Instance.new("ImageLabel"))
display.Size = UDim2.new(0.5, 0, 0.5, 0)

display.Parent = frame
display.BackgroundTransparency = 1

local displayImage = maid:GiveTask(editableImage:Clone())
display.Size = UDim2.fromOffset(displayImage.Size.X, displayImage.Size.Y)
displayImage.Parent = display
return display
end

do
local function renderTextureImage(bodyPart: Enum.BodyPartR15, tint: Color3?)
local canvas = maid:GiveTask(Instance.new("EditableImage"))
canvas.Size = clothingImage.Size

for i, normal in ipairs(Enum.NormalId:GetEnumItems()) do
local area = Util.getFaceTextureRect(bodyPart, normal)
if area then
local region = maid:GiveTask(clothingImage:Copy(area.Min, area.Max))
canvas:WritePixels(
area.Min,
area.Max - area.Min,
region:ReadPixels(Vector2.zero, area.Max - area.Min)
)
end
end

local display = displayImage(canvas)
display.Name = `{bodyPart}`
display.ImageTransparency = 0.3
display.ImageColor3 = tint or Color3.new(1, 1, 1)
end
-- do
-- renderTextureImage(Enum.BodyPartR15.RightUpperArm, Color3.new(1, 0, 0))
-- renderTextureImage(Enum.BodyPartR15.RightLowerArm, Color3.new(0, 1, 0))
-- renderTextureImage(Enum.BodyPartR15.RightHand, Color3.new(0, 0, 1))
-- end
do
renderTextureImage(Enum.BodyPartR15.UpperTorso, Color3.new(1, 0, 0))
renderTextureImage(Enum.BodyPartR15.LowerTorso, Color3.new(0, 1, 0))
end
end

do
local function renderAppliedImage(bodyPart: Enum.BodyPartR15, tint: Color3?)
local appliedImage = Util.apply(character, clothingImage, bodyPart)
assert(appliedImage)
maid:GiveTask(appliedImage)

local display = displayImage(appliedImage)
display.Name = `{bodyPart}`
display.ImageTransparency = 0.6
display.ImageColor3 = tint or Color3.new(1, 1, 1)

Util.bakeSkinTone(appliedImage, Color3.new(1, 0, 0))
end
-- do
-- renderAppliedImage(Enum.BodyPartR15.RightUpperArm, Color3.new(1, 0, 0))
-- renderAppliedImage(Enum.BodyPartR15.RightLowerArm, Color3.new(0, 1, 0))
-- renderAppliedImage(Enum.BodyPartR15.RightHand, Color3.new(0, 0, 1))
-- end
-- do
-- renderAppliedImage(Enum.BodyPartR15.UpperTorso, Color3.new(1, 0, 0))
-- renderAppliedImage(Enum.BodyPartR15.LowerTorso, Color3.new(0, 1, 0))
-- end
end
end)
return function()
maid:Destroy()
end
end
Loading

0 comments on commit 3cd6fa1

Please sign in to comment.