With the new DrawImageProjected API on Roblox, you can now add decals and images onto assets, including avatar bodies.
New DrawImageProjected API
The new DrawImageProjected API 294 acts very similarly to the existing EditableImage:DrawImage 57 API, but now it properly projects the drawn image if the EditableImage instance is being used with a MeshPart.
The following image shows a side-by-side comparison of the new DrawImageProjected API on the left and the existing DrawImage on the right.
Left star drawn using DrawImageProjected API. Right star drawn using DrawImage API
DrawImageProjected allows the entire target image to be nicely painted onto the shirt, taking into account the seams and edges of the shirt. Drawing an image directly onto the texture does not account for those same seams and edges. You can see this more clearly when looking at the resulting texture after drawing the stars on both sides of the shirt below.
The following code snippet shows a simple example of using the new DrawImageProjected API. It first sets up ProjectionParams 294 and a BrushConfig 294 that are then passed into the DrawImageProjected API
---------------------------------------------------------------------------
local editableImage: EditableImage = nil -- The result for this projection
local decalImage: EditableImage = nil -- The decal for projection
local targetMesh: EditableMesh = nil -- This will be the mesh you want to project to
local relativePos = meshPart.CFrame:PointToWorldSpace(raycastHitPos)
local direction = (game.Workspace.CurrentCamera.CFrame.Position - relativePos).Unit
local projectionParams: ProjectionParams = {
Direction = meshPart.CFrame:VectorToObjectSpace(direction),
Position = meshPart.CFrame:PointToObjectSpace(relativePos),
Size = Vector3.new(1, 1, 1),
Up = meshPart.CFrame:VectorToObjectSpace(Vector3.new(0, 1, 0)),
}
local localBrushConfig: BrushConfig = {
Decal = decalImage,
ColorBlendType = Enum.ImageCombineType.BlendSourceOver,
AlphaBlendType = Enum.ImageAlphaType.Default,
BlendIntensity = 1,
FadeAngle = 90.0
}
editableImage:DrawImageProjected(targetMesh, projectionParams, localBrushConfig)
---------------------------------------------------------------------------
Find more information about the Mesh & Image APIs and what’s next for the tooling in Roblox's recent Client Beta DevForum post.
Official DevForum by Roblox (with more links to get more info) : https://devforum.roblox.com/t/update-projecting-decals-to-editablemesh/3386639