-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrender_combined_test.gd
More file actions
73 lines (61 loc) · 2.33 KB
/
Copy pathrender_combined_test.gd
File metadata and controls
73 lines (61 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
## Visual test: same character built with separate meshes (left) and one combined
## mesh (right), body size pushed heavy to exercise merged blend shapes.
## Run with: godot -s res://tests/render_combined_test.gd --path .
extends SceneTree
const OUT_PATH := "user://render_combined.png"
func _init() -> void:
call_deferred("_run")
func _run() -> void:
var recipe := SKRecipe.load_from_file("res://synty_assets/characters/Starter_01.sk")
recipe.body_size_value = 80.0
recipe.muscle_value = 80.0
var library := SKPartLibrary.new()
library.scan()
var database := SKDatabase.new()
var colors := SKColorEngine.new()
colors.setup()
if database.open():
var properties := {}
for prop in database.get_color_properties():
properties[int(prop.id)] = prop
var rows: Array = []
for row in recipe.color_rows:
var prop: Dictionary = properties.get(row.property_id, {})
if not prop.is_empty():
rows.append({ "property": { "u": int(prop.u), "v": int(prop.v) }, "colors": row.colors })
colors.apply_rows(rows)
database.close()
var separate_builder := SKCharacterBuilder.new(library, colors)
separate_builder.combine_meshes = false
var separate := separate_builder.build(recipe)
separate.position = Vector3(-0.7, 0, 0)
root.add_child(separate)
var combined_builder := SKCharacterBuilder.new(library, colors)
combined_builder.combine_meshes = true
var combined := combined_builder.build(recipe)
combined.position = Vector3(0.7, 0, 0)
root.add_child(combined)
var light := DirectionalLight3D.new()
light.rotation_degrees = Vector3(-45, 30, 0)
light.light_energy = 1.2
root.add_child(light)
var environment := WorldEnvironment.new()
var env := Environment.new()
env.background_mode = Environment.BG_COLOR
env.background_color = Color(0.2, 0.22, 0.25)
env.ambient_light_source = Environment.AMBIENT_SOURCE_COLOR
env.ambient_light_color = Color(0.7, 0.7, 0.75)
env.ambient_light_energy = 0.6
environment.environment = env
root.add_child(environment)
var camera := Camera3D.new()
camera.position = Vector3(0, 1.0, 3.2)
camera.look_at_from_position(camera.position, Vector3(0, 0.9, 0))
root.add_child(camera)
camera.make_current()
for i in 10:
await process_frame
var image := root.get_viewport().get_texture().get_image()
image.save_png(OUT_PATH)
print("RENDER COMBINED: saved %s" % ProjectSettings.globalize_path(OUT_PATH))
quit(0)