Skip to content

Commit 42924a4

Browse files
update Open Source Docs from Roblox internal teams
1 parent 5f2c49f commit 42924a4

File tree

3 files changed

+71
-2
lines changed

3 files changed

+71
-2
lines changed

content/common/navigation/avatar/guides.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,5 @@ navigation:
118118

119119
- title: In-experience creation
120120
path: /avatar/in-experience-creation
121+
- title: Photo-to-Avatar generation
122+
path: /avatar/avatar-generation
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: Photo-to-Avatar generation
3+
description: Explains how to use AvatarCreationService AvatarGeneration APIs to prompt users to generate Avatars from photos in experience.
4+
---
5+
6+
<Alert severity = 'success'>
7+
The Photo-to-Avatar feature is currently in alpha. Please refer to the [DevForum announcement](https://devforum.roblox.com/t/early-preview-alpha-release-of-photo-to-avatar-apis/3931624) for latest information.
8+
</Alert>
9+
10+
<Alert severity = 'warning'>
11+
The following guide applies to creators who are familiar with scripting and Roblox Studio and intend to develop experiences that allow user-generated avatar items.
12+
</Alert>
13+
14+
You can create an experience that allows players to generate a fully functional avatar character using a photo and a text prompt.
15+
16+
This process involves the following steps:
17+
18+
1. Request an AvatarGeneration session
19+
2. Prompt the user to take a selfie and generate a 2D preview image of the avatar
20+
3. Generate the full Avatar character using `Class.HumanoidDescription`
21+
22+
### Request an AvatarGeneration session
23+
24+
To start a photo-to-avatar generation, call `Class.AvatarCreationService:RequestAvatarGenerationSessionAsync()` from the server to request a session for the player. A session provides a `Class.Player` with a certain number of Avatar previews and Avatar generations.
25+
26+
As it may take some time for a session to become available, `Class.AvatarCreationService:RequestAvatarGenerationSessionAsync()` returns a `Datatype.RBXScriptConnection` and a waitTime in seconds. The waitTime can be used to provide the `Class.Player` with information on how long it will take them to be able to start their generations.
27+
28+
Once a session is ready, the callback is invoked with a `Dictionary` of information about the session. The `Dictionary` includes:
29+
30+
- `SessionId` — passed as an argument when calling `Class.AvatarCreationService:GenerateAvatar2DPreviewAsync` and `Class.AvatarCreationService:GenerateAvatarAsync`
31+
- `Allowed2DGenerations` — the number of 2D preview generations allowed in a session
32+
- `Allowed3DGenerations` — the number of 3D avatar generations allowed in a session
33+
- `SessionTime` — the maximum time for a session in seconds
34+
35+
### Prompt selfie and generate 2D preview
36+
37+
After a session is started, prompt the user to take a selfie and get the fileId `string` by calling the `Class.AvatarCreationService:PromptSelectAvatarGenerationImageAsync` method on the Server. This fileId will be passed to the `Class.AvatarCreationService:GenerateAvatar2DPreviewAsync` method.
38+
39+
To create a 2D preview image of the Avatar call the following methods:
40+
41+
1. `Class.AvatarCreationService:GenerateAvatar2DPreviewAsync` on the Server
42+
2. `Class.AvatarCreationService:LoadAvatar2DPreviewAsync` on the Client
43+
44+
The `Class.AvatarCreationService:GenerateAvatar2DPreviewAsync` takes the SessionId, fileId and an optional text prompt as input to generate a 2D Avatar preview. This method returns a previewId.
45+
46+
This previewId should be sent to the client and can then be used to retrieve the preview as an `Class.EditableImage`.
47+
48+
If the user is not satisfied with the generated preview this workflow can be repeated.
49+
50+
### Generate the 3D avatar
51+
52+
Once the user is satisfied with the preview, you can generate the complete 3D avatar character.
53+
54+
To generate an avatar character:
55+
56+
1. Call `Class.AvatarCreationService:GenerateAvatarAsync` on the Server with a `Dictionary` containing the SessionId and PreviewId.
57+
1. This method call returns a `string` generationId.
58+
2. Retrieve the generated avatar data as a `Class.HumanoidDescription` using the `Class.AvatarCreationService:LoadGeneratedAvatarAsync` method on both the game server and the client.
59+
3. You can use the `Players.CreateHumanoidModelFromDescription` method to create an avatar model from the `Class.HumanoidDescription` to display to the `Class.Player`.
60+
61+
Mesh and texture assets will be provided as `Class.EditableMesh` and `Class.EditableImage` objects, respectively, to allow continued editing of the generated avatar. Edits should be made on both the game server and the client copy to keep them in sync for publish.
62+
63+
### Publish
64+
65+
If the user is satisfied with the resulting avatar it can be published using the `Class.AvatarCreationService:PromptCreateAvatarAsync` method.
66+
67+
For more details on see [in-experience creation](./in-experience-creation.md).

content/en-us/avatar/in-experience-creation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ title: Avatar in-experience creation
33
description: Explains how to use AvatarCreationService to prompt users to create and purchase avatars from within your experience.
44
---
55

6-
<Alert severity = 'error'>
7-
The following guide applies to creators who are familiar with scripting and Roblox Studio.
6+
<Alert severity = 'warning'>
7+
The following guide applies to creators who are familiar with scripting and Roblox Studio and intend to develop experiences that allow user-generated avatar items.
88
</Alert>
99

1010
You can publish an experience that allows players to create, customize, and purchase avatar bodies in realtime. When purchased, these custom bodies save directly to the player's Roblox inventory, allowing players to equip and wear the custom avatars in other experiences.

0 commit comments

Comments
 (0)