Skip to content

Commit

Permalink
fix: avatar rendering face zoom (#525)
Browse files Browse the repository at this point in the history
* fix: avatar rendering face zoom

* remove unwanted code

* fix snapshots
kuruk-mm authored Jan 18, 2025
1 parent 72e023e commit 40e3f92
Showing 9 changed files with 6 additions and 11 deletions.
4 changes: 0 additions & 4 deletions godot/project.godot
Original file line number Diff line number Diff line change
@@ -38,10 +38,6 @@ gdscript/warnings/redundant_await=false
window/size/viewport_width=1280
window/size/viewport_height=720

[editor]

run/main_run_args="--avatar-renderer --avatars ../tests/avatars-test-input.json"

[editor_plugins]

enabled=PackedStringArray("res://addons/dcl_build_plugin/plugin.cfg", "res://addons/godot-xr-tools/plugin.cfg", "res://addons/resource_tracker/plugin.cfg", "res://addons/webview-godot-android/plugin.cfg")
2 changes: 1 addition & 1 deletion godot/src/tool/avatar_renderer/avatar_renderer_helper.gd
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ class AvatarRendererSpecs:
var face_dest_path := ""
var face_width := 256
var face_height := 256
var face_zoom := 25
var face_zoom := 25.0

var avatar: DclAvatarWireFormat

Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ func _async_on_avatar_avatar_loaded():
ensure_base_dir_exists(face_dest_path)

var face_image = await avatar_preview.async_get_viewport_image(
true, Vector2i(profile.face_width, profile.face_height)
true, Vector2i(profile.face_width, profile.face_height), profile.face_zoom
)
face_image.save_png(face_dest_path)
logs.push_back("🟢 " + face_dest_path)
7 changes: 3 additions & 4 deletions godot/src/ui/components/backpack/avatar_preview.gd
Original file line number Diff line number Diff line change
@@ -109,15 +109,14 @@ func _on_gui_input(event):
camera_3d.transform = changed_transform


func async_get_viewport_image(face: bool, dest_size: Vector2i, fov: Variant = null) -> Image:
func async_get_viewport_image(face: bool, dest_size: Vector2i, fov: float = 40) -> Image:
avatar.emote_controller.freeze_on_idle()
avatar.rotation.y = 0.0
const PROFILE_BODY_CAMERA_POSITION = Vector3(0, 2.3, -3.5)
const PROFILE_HEAD_CAMERA_POSITION = Vector3(0, 1.6, -1.25)
const PROFILE_HEAD_CAMERA_POSITION = Vector3(0, 1.7, -1.25)
camera_3d.position = PROFILE_HEAD_CAMERA_POSITION if face else PROFILE_BODY_CAMERA_POSITION
camera_3d.rotation_degrees = DEFAULT_ROTATION if not face else Vector3(0.0, 180.0, 0.0)
if fov is float:
camera_3d.fov = fov
camera_3d.fov = fov

set_deferred("size", dest_size)
set_size(dest_size)
2 changes: 1 addition & 1 deletion godot/src/ui/components/backpack/backpack.gd
Original file line number Diff line number Diff line change
@@ -282,7 +282,7 @@ func async_prepare_snapshots(new_mutable_avatar: DclAvatarWireFormat, profile: D
cloned_avatar_preview.show_platform = false
cloned_avatar_preview.hide_name = true
cloned_avatar_preview.can_move = false
var face = await cloned_avatar_preview.async_get_viewport_image(true, Vector2i(256, 256))
var face = await cloned_avatar_preview.async_get_viewport_image(true, Vector2i(256, 256), 25)
var body = await cloned_avatar_preview.async_get_viewport_image(false, Vector2i(256, 512))

var body_data: PackedByteArray = body.save_png_to_buffer()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 40e3f92

Please sign in to comment.