Improve render scripts and formatting
This commit is contained in:
parent
630d9aab82
commit
baf73c6c18
|
|
@ -0,0 +1,75 @@
|
||||||
|
local HttpService = game:GetService "HttpService"
|
||||||
|
local ScriptContext = game:GetService "ScriptContext"
|
||||||
|
local Players = game:GetService "Players"
|
||||||
|
local ContentProvider = game:GetService "ContentProvider"
|
||||||
|
local InsertService = game:GetService "InsertService"
|
||||||
|
|
||||||
|
local function post(url: string, body: string)
|
||||||
|
-- We have to lie about the contentType to avoid being nuked by CORS from the website
|
||||||
|
game:HttpPost(url, body, true, "text/json")
|
||||||
|
end
|
||||||
|
|
||||||
|
return function(baseUrl: string, thumbnailKey: string)
|
||||||
|
local Render = {}
|
||||||
|
|
||||||
|
function Render.SetupAvatar(
|
||||||
|
renderType: string,
|
||||||
|
assetId: string,
|
||||||
|
characterAppearance: string
|
||||||
|
)
|
||||||
|
pcall(function()
|
||||||
|
ContentProvider:SetBaseUrl(baseUrl)
|
||||||
|
InsertService:SetAssetUrl(`{baseUrl}/asset?id=%d`)
|
||||||
|
InsertService:SetAssetVersionUrl(
|
||||||
|
`{baseUrl}/asset?assetversionid=%d`
|
||||||
|
)
|
||||||
|
end)
|
||||||
|
|
||||||
|
HttpService.HttpEnabled = true
|
||||||
|
ScriptContext.ScriptsDisabled = true
|
||||||
|
|
||||||
|
print(
|
||||||
|
`[{game.JobId}] Starting new render for {renderType} ID {assetId}`
|
||||||
|
)
|
||||||
|
post(
|
||||||
|
`{baseUrl}/api/render/update?apiKey={thumbnailKey}&taskID={game.JobId}`,
|
||||||
|
"Rendering"
|
||||||
|
)
|
||||||
|
|
||||||
|
local player = Players:CreateLocalPlayer(0)
|
||||||
|
player.CharacterAppearance = baseUrl .. characterAppearance .. assetId
|
||||||
|
player:LoadCharacter(false)
|
||||||
|
|
||||||
|
-- Raise up the character's arm if they have gear.
|
||||||
|
local gear = player.Backpack:GetChildren()[1]
|
||||||
|
if gear then
|
||||||
|
gear.Parent = player.Character
|
||||||
|
player.Character.Torso["Right Shoulder"].CurrentAngle = math.rad(90)
|
||||||
|
end
|
||||||
|
|
||||||
|
return player
|
||||||
|
end
|
||||||
|
|
||||||
|
function Render.Upload(result: string)
|
||||||
|
for i = 1, 3 do
|
||||||
|
local ok, err = pcall(function()
|
||||||
|
post(
|
||||||
|
`{baseUrl}/api/render/update?apiKey={thumbnailKey}&taskID={game.JobId}`,
|
||||||
|
result
|
||||||
|
)
|
||||||
|
end)
|
||||||
|
if ok then
|
||||||
|
print(`[{game.JobId}] Upload successful! Moving on...`)
|
||||||
|
break
|
||||||
|
elseif i == 3 then
|
||||||
|
print(`[{game.JobId}] An error occurred! ({err}). Giving up...`)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
print(
|
||||||
|
`[{game.JobId}] An error occurred! ({err}). Uploading again...`
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return Render
|
||||||
|
end
|
||||||
|
|
@ -5,7 +5,7 @@ done
|
||||||
|
|
||||||
echo "Processing libraries..."
|
echo "Processing libraries..."
|
||||||
darklua process -c dense.json5 ./corescripts/Libraries/Fusion/init.luau ./corescripts/processed/10000001.lua
|
darklua process -c dense.json5 ./corescripts/Libraries/Fusion/init.luau ./corescripts/processed/10000001.lua
|
||||||
darklua process -c bundle.json5 ./corescripts/Libraries/Red/init.luau ./corescripts/processed/10000002.lua
|
darklua process -c dense.json5 ./corescripts/Libraries/Red/init.luau ./corescripts/processed/10000002.lua
|
||||||
|
|
||||||
echo "Processing other corescripts..."
|
echo "Processing other corescripts..."
|
||||||
for file in ./corescripts/luau/[a-z]*.luau; do
|
for file in ./corescripts/luau/[a-z]*.luau; do
|
||||||
|
|
|
||||||
|
|
@ -1,54 +1,18 @@
|
||||||
-- Avatar v1.1.0
|
-- Render script for R6 avatars
|
||||||
-- This is the thumbnail script for R6 avatars. Straight up and down, with the right arm out if they have a gear.
|
|
||||||
|
|
||||||
local baseUrl = _BASE_URL
|
|
||||||
local thumbnailKey = _THUMBNAIL_KEY
|
|
||||||
local renderType = _RENDER_TYPE
|
|
||||||
local assetId = _ASSET_ID
|
|
||||||
|
|
||||||
local ThumbnailGenerator = game:GetService "ThumbnailGenerator"
|
local ThumbnailGenerator = game:GetService "ThumbnailGenerator"
|
||||||
local ContentProvider = game:GetService "ContentProvider"
|
local Render = require "../Modules/Render.luau"(_BASE_URL, _THUMBNAIL_KEY)
|
||||||
local InsertService = game:GetService "InsertService"
|
|
||||||
local HttpService = game:GetService "HttpService"
|
|
||||||
local ScriptContext = game:GetService "ScriptContext"
|
|
||||||
|
|
||||||
pcall(function()
|
local player =
|
||||||
ContentProvider:SetBaseUrl(baseUrl)
|
Render.SetupAvatar(_RENDER_TYPE, _ASSET_ID, `/asset/characterfetch?userID=`)
|
||||||
InsertService:SetAssetUrl(`{baseUrl}/asset?id=%d`)
|
|
||||||
InsertService:SetAssetVersionUrl(`{baseUrl}/asset?assetversionid=%d`)
|
|
||||||
end)
|
|
||||||
|
|
||||||
HttpService.HttpEnabled = true
|
local clickBody = ThumbnailGenerator:Click("PNG", 1680, 1680, true)
|
||||||
ScriptContext.ScriptsDisabled = true
|
|
||||||
|
|
||||||
print(`[{game.JobId}] Starting new render for {renderType} ID {assetId}`)
|
|
||||||
game:HttpPost(
|
|
||||||
`{baseUrl}/api/render/update?apiKey={thumbnailKey}&taskID={game.JobId}`,
|
|
||||||
"Rendering",
|
|
||||||
true,
|
|
||||||
"text/json"
|
|
||||||
)
|
|
||||||
|
|
||||||
local player = game:GetService("Players"):CreateLocalPlayer(0)
|
|
||||||
player.CharacterAppearance = `{baseUrl}/asset/characterfetch?userID={assetId}`
|
|
||||||
player:LoadCharacter(false)
|
|
||||||
|
|
||||||
-- Raise up the character's arm if they have gear.
|
|
||||||
local gear = player.Backpack:GetChildren()[1]
|
|
||||||
if gear then
|
|
||||||
gear.Parent = player.Character
|
|
||||||
player.Character.Torso["Right Shoulder"].CurrentAngle = math.rad(90)
|
|
||||||
end
|
|
||||||
|
|
||||||
local clickBody = ThumbnailGenerator:Click("PNG", 2048, 2048, true)
|
|
||||||
|
|
||||||
print(`[{game.JobId}] Rendered bodyshot`)
|
print(`[{game.JobId}] Rendered bodyshot`)
|
||||||
|
|
||||||
player.Character.Torso["Right Shoulder"].CurrentAngle = 0
|
player.Character.Torso["Right Shoulder"].CurrentAngle = 0
|
||||||
|
|
||||||
-- Headshot Camera
|
-- Headshot Camera
|
||||||
local FOV = 52.5
|
|
||||||
|
|
||||||
local CameraAngle = player.Character.Head.CFrame
|
local CameraAngle = player.Character.Head.CFrame
|
||||||
local CameraPosition = CameraAngle
|
local CameraPosition = CameraAngle
|
||||||
+ CFrame.Angles(0, math.pi, 0).lookVector.unit * 2.75
|
+ CFrame.Angles(0, math.pi, 0).lookVector.unit * 2.75
|
||||||
|
|
@ -57,31 +21,12 @@ local Camera = Instance.new "Camera"
|
||||||
Camera.Name = "ThumbnailCamera"
|
Camera.Name = "ThumbnailCamera"
|
||||||
Camera.CameraType = Enum.CameraType.Scriptable
|
Camera.CameraType = Enum.CameraType.Scriptable
|
||||||
Camera.CoordinateFrame = CFrame.new(CameraPosition.p, CameraAngle.p)
|
Camera.CoordinateFrame = CFrame.new(CameraPosition.p, CameraAngle.p)
|
||||||
Camera.FieldOfView = FOV
|
Camera.FieldOfView = 52.5
|
||||||
Camera.Parent = player.Character
|
Camera.Parent = player.Character
|
||||||
workspace.CurrentCamera = Camera
|
workspace.CurrentCamera = Camera
|
||||||
|
|
||||||
local clickHead = ThumbnailGenerator:Click("PNG", 300, 300, true)
|
local clickHead = ThumbnailGenerator:Click("PNG", 300, 300, true)
|
||||||
|
|
||||||
local result = `Completed\n{clickBody}\n{clickHead}`
|
|
||||||
|
|
||||||
print(`[{game.JobId}] Rendered headshot`)
|
print(`[{game.JobId}] Rendered headshot`)
|
||||||
|
|
||||||
for i = 1, 3 do
|
Render.Upload(`Completed\n{clickBody}\n{clickHead}`)
|
||||||
local ok, err = pcall(function()
|
|
||||||
game:HttpPost(
|
|
||||||
`{baseUrl}/api/render/update?apiKey={thumbnailKey}&taskID={game.JobId}`,
|
|
||||||
result,
|
|
||||||
true,
|
|
||||||
"text/json"
|
|
||||||
)
|
|
||||||
end)
|
|
||||||
if ok then
|
|
||||||
print(`[{game.JobId}] Upload successful! Moving on...`)
|
|
||||||
break
|
|
||||||
elseif i == 3 then
|
|
||||||
print(`[{game.JobId}] An error occurred! ({err}). Giving up...`)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
print(`[{game.JobId}] An error occurred! ({err}). Uploading again...`)
|
|
||||||
end
|
|
||||||
|
|
|
||||||
|
|
@ -1,65 +1,12 @@
|
||||||
-- Avatar v1.1.0
|
-- Render script for R6 clothing
|
||||||
-- This is the thumbnail script for R6 avatars. Straight up and down, with the right arm out if they have a gear.
|
|
||||||
|
|
||||||
local baseUrl = _BASE_URL
|
|
||||||
local thumbnailKey = _THUMBNAIL_KEY
|
|
||||||
local renderType = _RENDER_TYPE
|
|
||||||
local assetId = _ASSET_ID
|
|
||||||
|
|
||||||
local ThumbnailGenerator = game:GetService "ThumbnailGenerator"
|
local ThumbnailGenerator = game:GetService "ThumbnailGenerator"
|
||||||
local ContentProvider = game:GetService "ContentProvider"
|
local Render = require "../Modules/Render.luau"(_BASE_URL, _THUMBNAIL_KEY)
|
||||||
local InsertService = game:GetService "InsertService"
|
|
||||||
local HttpService = game:GetService "HttpService"
|
|
||||||
local ScriptContext = game:GetService "ScriptContext"
|
|
||||||
|
|
||||||
pcall(function()
|
Render.SetupAvatar(_RENDER_TYPE, _ASSET_ID, `/api/render/characterasset?id=`)
|
||||||
ContentProvider:SetBaseUrl(baseUrl)
|
|
||||||
InsertService:SetAssetUrl(`{baseUrl}/asset?id=%d`)
|
|
||||||
InsertService:SetAssetVersionUrl(`{baseUrl}/asset?assetversionid=%d`)
|
|
||||||
end)
|
|
||||||
|
|
||||||
HttpService.HttpEnabled = true
|
local click = ThumbnailGenerator:Click("PNG", 1680, 1680, true)
|
||||||
ScriptContext.ScriptsDisabled = true
|
|
||||||
|
|
||||||
print(`[{game.JobId}] Starting new render for {renderType} ID {assetId}`)
|
|
||||||
game:HttpPost(
|
|
||||||
`{baseUrl}/api/render/update?apiKey={thumbnailKey}&taskID={game.JobId}`,
|
|
||||||
"Rendering",
|
|
||||||
true,
|
|
||||||
"text/json"
|
|
||||||
)
|
|
||||||
|
|
||||||
local player = game:GetService("Players"):CreateLocalPlayer(0)
|
|
||||||
player.CharacterAppearance = `{baseUrl}/api/render/characterasset?id={assetId}`
|
|
||||||
player:LoadCharacter(false)
|
|
||||||
|
|
||||||
-- Raise up the character's arm if they have gear.
|
|
||||||
local gear = player.Backpack:GetChildren()[1]
|
|
||||||
if gear then
|
|
||||||
gear.Parent = player.Character
|
|
||||||
player.Character.Torso["Right Shoulder"].CurrentAngle = math.rad(90)
|
|
||||||
end
|
|
||||||
|
|
||||||
local click = ThumbnailGenerator:Click("PNG", 2048, 2048, true)
|
|
||||||
|
|
||||||
local result = "Completed\n" .. tostring(click)
|
|
||||||
print(`[{game.JobId}] Successfully rendered, moving on...`)
|
print(`[{game.JobId}] Successfully rendered, moving on...`)
|
||||||
|
|
||||||
for i = 1, 3 do
|
Render.Upload(`Completed\n{click}`)
|
||||||
local ok, err = pcall(function()
|
|
||||||
game:HttpPost(
|
|
||||||
`{baseUrl}/api/render/update?apiKey={thumbnailKey}&taskID={game.JobId}`,
|
|
||||||
result,
|
|
||||||
true,
|
|
||||||
"text/json"
|
|
||||||
)
|
|
||||||
end)
|
|
||||||
if ok then
|
|
||||||
print(`[{game.JobId}] Upload successful! Moving on...`)
|
|
||||||
break
|
|
||||||
elseif i == 3 then
|
|
||||||
print(`[{game.JobId}] An error occurred! ({err}). Giving up...`)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
print(`[{game.JobId}] An error occurred! ({err}). Uploading again...`)
|
|
||||||
end
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue