-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathBakeInfo.py
233 lines (190 loc) · 6.99 KB
/
BakeInfo.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
import bpy
from .common import *
from bpy.props import *
class YBakeInfoOtherObject(bpy.types.PropertyGroup):
if is_bl_newer_than(2, 79):
object : PointerProperty(type=bpy.types.Object)
object_name : StringProperty(default='')
class YBakeInfoSelectedVertex(bpy.types.PropertyGroup):
index : IntProperty(default=0)
class YBakeInfoSelectedObject(bpy.types.PropertyGroup):
if is_bl_newer_than(2, 79):
object : PointerProperty(type=bpy.types.Object)
object_name : StringProperty(default='')
selected_vertex_indices : CollectionProperty(type=YBakeInfoSelectedVertex)
class YBakeInfoProps(bpy.types.PropertyGroup):
is_baked : BoolProperty(default=False) # Flag to mark if the image is from baking or not
is_baked_channel : BoolProperty(default=False) # Flag to mark if the image baked from main channel
bake_type : EnumProperty(
name = 'Bake Type',
description = 'Bake Type',
items = bake_type_items,
default = 'AO'
)
samples : IntProperty(
name = 'Bake Samples',
description = 'Bake Samples, more means less jagged on generated textures',
default=1, min=1
)
margin : IntProperty(
name = 'Bake Margin',
description = 'Bake margin in pixels',
subtype = 'PIXEL',
default=5, min=0
)
margin_type : EnumProperty(
name = 'Margin Type',
description = '',
items = (
('ADJACENT_FACES', 'Adjacent Faces', 'Use pixels from adjacent faces across UV seams.'),
('EXTEND', 'Extend', 'Extend border pixels outwards')
),
default = 'ADJACENT_FACES'
)
flip_normals : BoolProperty(
name = 'Flip Normals',
description = 'Flip normal of mesh',
default = False
)
only_local : BoolProperty(
name = 'Only Local',
description = 'Only bake local ambient occlusion',
default = False
)
subsurf_influence : BoolProperty(
name = 'Subsurf Influence',
description = 'Take account subsurf when baking cavity',
default = False
)
force_bake_all_polygons : BoolProperty(
name = 'Force Bake all Polygons',
description = 'Force bake all polygons, useful if material is not using direct polygon (ex: solidify material)',
default = False
)
fxaa : BoolProperty(
name='Use FXAA',
description = "Use FXAA on baked image (doesn't work with float images)",
default = False
)
ssaa : BoolProperty(
name = 'Use SSAA',
description = "Use Supersample AA on baked image",
default = False
)
denoise : BoolProperty(
name = 'Use Denoise',
description = "Use Denoise on baked image",
default = True
)
blur : BoolProperty(
name = 'Use Blur',
description = "Use blur to baked image",
default = False
)
blur_factor : FloatProperty(
name = 'Blur Factor',
description = "Blur factor to baked image",
default=1.0, min=0.0, max=100.0
)
use_baked_disp : BoolProperty(
name = 'Use Baked Displacement Map',
description = 'Use baked displacement map, this will also apply subdiv setup on object',
default = False
)
bake_device : EnumProperty(
name = 'Bake Device',
description = 'Device to use for baking',
items = (
('GPU', 'GPU Compute', ''),
('CPU', 'CPU', '')
),
default = 'CPU'
)
cage_object_name : StringProperty(
name = 'Cage Object',
description = 'Object to use as cage instead of calculating the cage from the active object with cage extrusion',
default = ''
)
cage_extrusion : FloatProperty(
name = 'Cage Extrusion',
description = 'Inflate the active object by the specified distance for baking. This helps matching to points nearer to the outside of the selected object meshes',
default=0.2, min=0.0, max=1.0
)
max_ray_distance : FloatProperty(
name = 'Max Ray Distance',
description = 'The maximum ray distance for matching points between the active and selected objects. If zero, there is no limit',
default=0.2, min=0.0, max=1.0
)
use_udim : BoolProperty(
name = 'Use UDIM Tiles',
description = 'Use UDIM Tiles',
default = False
)
aa_level : IntProperty(
name = 'Anti Aliasing Level',
description = 'Super Sample Anti Aliasing Level (1=off)',
default=1, min=1, max=2
)
interpolation : EnumProperty(
name = 'Image Interpolation Type',
description = 'Image interpolation type',
items = interpolation_type_items,
default = 'Linear'
)
use_float_for_normal : BoolProperty(
name = 'Use Float for Normal',
description = 'Use float image for baked normal',
default = False
)
use_float_for_displacement : BoolProperty(
name = 'Use Float for Displacement',
description = 'Use float image for baked displacement',
default = False
)
bake_disabled_layers : BoolProperty(
name = 'Bake Disabled Layers',
description = 'Take disabled layers into account when baking',
default = False
)
# To store other objects info
other_objects : CollectionProperty(type=YBakeInfoOtherObject)
multires_base : IntProperty(default=1, min=0, max=16)
hdr : BoolProperty(name='32 bit Float', default=False)
# AO Props
ao_distance : FloatProperty(default=1.0)
# Bevel Props
bevel_samples : IntProperty(default=4, min=2, max=16)
bevel_radius : FloatProperty(default=0.05, min=0.0, max=1000.0)
use_image_atlas : BoolProperty(
name = 'Use Image Atlas',
description = 'Use Image Atlas',
default = False
)
vcol_force_first_ch_idx : StringProperty(
name = 'Force First Vertex Color Channel',
description = 'Force the first channel after baking the Vertex Color',
default = 'Do Nothing'
)
selected_face_mode : BoolProperty(default=False)
selected_objects : CollectionProperty(type=YBakeInfoSelectedObject)
image_resolution : EnumProperty(
name = 'Image Resolution',
items = image_resolution_items,
default = '1024'
)
use_custom_resolution : BoolProperty(
name = 'Custom Resolution',
default = False,
description = 'Use custom Resolution to adjust the width and height individually'
)
def register():
bpy.utils.register_class(YBakeInfoOtherObject)
bpy.utils.register_class(YBakeInfoSelectedVertex)
bpy.utils.register_class(YBakeInfoSelectedObject)
bpy.utils.register_class(YBakeInfoProps)
bpy.types.Image.y_bake_info = PointerProperty(type=YBakeInfoProps)
def unregister():
bpy.utils.unregister_class(YBakeInfoOtherObject)
bpy.utils.unregister_class(YBakeInfoSelectedVertex)
bpy.utils.unregister_class(YBakeInfoSelectedObject)
bpy.utils.unregister_class(YBakeInfoProps)