-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path02_aov_basic.py
256 lines (198 loc) · 10.5 KB
/
02_aov_basic.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
import c4d
import maxon
import Renderer
from Renderer import Redshift, Arnold, Octane, Vray, Corona
from pprint import pprint
# How to create and modify redshift aovs
def modify_redshift_aov():
# Get the videopost host the aovs
doc: c4d.documents.BaseDocument = c4d.documents.GetActiveDocument()
vp: c4d.documents.BaseVideoPost = Renderer.GetVideoPost(doc, Renderer.ID_REDSHIFT)
# Set redshift AOVHelper instance
aov_helper = Redshift.AOV(vp)
# Create a redshift aov item
# the id can find from Renderer.constants.redshift,or Redshift.theid
# If #name is None, defulat to type name of the aov.
diff_aov = aov_helper.create_aov_shader(aov_type = Redshift.REDSHIFT_AOV_TYPE_BEAUTY)
# Add the DIFFUSE aov just created to the redshift aov system
aov_helper.add_aov(diff_aov)
# Add some aovs
aov_helper.add_aov(aov_helper.create_aov_shader(aov_type = Redshift.REDSHIFT_AOV_TYPE_SHADOWS, aov_name = 'My Shadow'))
aov_helper.add_aov(aov_helper.create_aov_shader(Redshift.REDSHIFT_AOV_TYPE_NORMALS))
aov_helper.add_aov(aov_helper.create_aov_shader(Redshift.REDSHIFT_AOV_TYPE_REFLECTIONS))
aov_helper.add_aov(aov_helper.create_aov_shader(Redshift.REDSHIFT_AOV_TYPE_REFRACTIONS))
aov_helper.add_aov(aov_helper.create_aov_shader(Redshift.REDSHIFT_AOV_TYPE_DEPTH))
aov_helper.add_aov(aov_helper.create_aov_shader(Redshift.REDSHIFT_AOV_TYPE_EMISSION))
aov_helper.add_aov(aov_helper.create_aov_shader(Redshift.REDSHIFT_AOV_TYPE_CRYPTOMATTE))
last_aov = aov_helper.add_aov(aov_helper.create_aov_shader(Redshift.REDSHIFT_AOV_TYPE_OBJECT_ID))
last_aov_name = aov_helper.get_name(last_aov)
# Remove last aov: object id
aov_helper.remove_last_aov()
print(f'We remove the last AOV named: {last_aov_name}')
# Remove specified aov: emission
aov_helper.remove_aov_type(aov_type = Redshift.REDSHIFT_AOV_TYPE_EMISSION)
print(f'We remove the AOV type: EMISSION @{Redshift.REDSHIFT_AOV_TYPE_EMISSION}')
# update the depth aov "Use Camera Near/Far" to Flase
aov_helper.update_aov(aov_type=Redshift.REDSHIFT_AOV_TYPE_DEPTH, aov_id=c4d.REDSHIFT_AOV_DEPTH_USE_CAMERA_NEAR_FAR, aov_attrib=False)
print(f'We update the Depth AOV with attribute "Use Camera Near/Far" to False')
# Set the #REFRACTION aov #name
aov_helper.set_name(Redshift.REDSHIFT_AOV_TYPE_REFRACTIONS, "new refraction name")
# Get the #SHADOW aov and his #name
shadow = aov_helper.get_aovs(Redshift.REDSHIFT_AOV_TYPE_SHADOWS)
if shadow:
print(f'We find a AOV with Named {aov_helper.get_name(shadow)}')
# Set the #REFRACTION aov #light group
aov_helper.set_light_group(Redshift.REDSHIFT_AOV_TYPE_REFRACTIONS, "new group")
print(f'We add a light group the REFRACTION AOV Named: new group')
# Add a puzzle matte with same id(r=g=b), aka a white mask with given id
aov_helper.set_puzzle_matte(puzzle_id = 2 ,aov_name = "My Puzzle 2")
print(f'We add a white puzzle matte with ID = 2 , Name = "My Puzzle 2"')
# Print current aov info
aov_helper.print_aov()
Redshift.AovManager()
# How to create and modify octane aovs
def modify_octane_aov():
# Get the videopost host the aovs
doc: c4d.documents.BaseDocument = c4d.documents.GetActiveDocument()
vp: c4d.documents.BaseVideoPost = Renderer.GetVideoPost(doc, Renderer.ID_OCTANE)
# Set Octane AOVHelper instance
aov_helper = Octane.AOV(vp)
# Create a Octane aov item
# the id can find from Renderer.constants.octane, or Octane.theid
# If #name is None, defulat to type.
diff_aov = aov_helper.create_aov_shader(aov_type = Octane.RNDAOV_DIFFUSE)
# Add the DIFFUSE aov just created to the Octane aov system
aov_helper.add_aov(diff_aov)
# Add some aovs
aov_helper.add_aov(aov_helper.create_aov_shader(aov_type = Octane.RNDAOV_POST,aov_name = 'POST'))
aov_helper.add_aov(aov_helper.create_aov_shader(Octane.RNDAOV_DIF_D))
aov_helper.add_aov(aov_helper.create_aov_shader(Octane.RNDAOV_DIF_I))
aov_helper.add_aov(aov_helper.create_aov_shader(Octane.RNDAOV_REFL_D))
aov_helper.add_aov(aov_helper.create_aov_shader(Octane.RNDAOV_REFL_I))
aov_helper.add_aov(aov_helper.create_aov_shader(Octane.RNDAOV_WIRE))
aov_helper.add_aov(aov_helper.create_aov_shader(Octane.RNDAOV_OBJECT_LAYER_COLOR))
aov_helper.add_aov(aov_helper.create_aov_shader(Octane.RNDAOV_VOLUME))
# Remove last aov: volume
aov_helper.remove_last_aov()
# Remove specified aov: wire
aov_helper.remove_aov_type(aov_type = Octane.RNDAOV_WIRE)
# Add 2 custom aovs with id 1 and 2
aov_helper.add_custom_aov(customID = 1)
aov_helper.add_custom_aov(customID = 2)
# Get the custom aov with id 2
custom2 = aov_helper.get_custom_aov(customID = 2)
if custom2:
print(f'We find a Custom AOV with id 2 Named{custom2.GetName()}')
# Print current aov info
aov_helper.print_aov()
Octane.AovManager()
# How to create and modify arnold aovs
def modify_arnold_aov():
# Get the videopost host the aovs
doc: c4d.documents.BaseDocument = c4d.documents.GetActiveDocument()
vp: c4d.documents.BaseVideoPost = Renderer.GetVideoPost(doc, Renderer.ID_ARNOLD)
# Set Arnold AOVHelper instance
aov_helper = Arnold.AOV(vp)
# Start record undo
aov_helper.doc.StartUndo()
# Create a arnold Driver item
exr_driver: c4d.BaseObject = aov_helper.create_aov_driver(isDisplay=False, driver_type=Arnold.C4DAIN_DRIVER_EXR, denoise=True, sRGB=False)
display_driver: c4d.BaseObject = aov_helper.create_aov_driver(isDisplay=True)
# Create a arnold aov item(aov type must as same as the aov manager aov)
# If #name is None, defulat to #beauty.
diff_aov: c4d.BaseObject = aov_helper.create_aov_shader(aov_name='diffuse')
# Add the DIFFUSE aov just created to the arnold aov system
aov_helper.add_aov(driver=exr_driver,aov=diff_aov)
# Add some aovs to exr_driver
aov_helper.add_aov(exr_driver,aov_helper.create_aov_shader("N"))
aov_helper.add_aov(exr_driver,aov_helper.create_aov_shader("Z"))
aov_helper.add_aov(exr_driver,aov_helper.create_aov_shader("sheen"))
aov_helper.add_aov(exr_driver,aov_helper.create_aov_shader("specular"))
aov_helper.add_aov(exr_driver,aov_helper.create_aov_shader("transmission"))
aov_helper.add_aov(exr_driver,aov_helper.create_aov_shader("emission"))
aov_helper.add_aov(exr_driver,aov_helper.create_aov_shader("coat"))
last_aov: c4d.BaseObject = aov_helper.add_aov(exr_driver,aov_helper.create_aov_shader("sss"))
last_name: str = last_aov.GetName()
# Add some aovs to display_driver
aov_helper.add_aov(display_driver,aov_helper.create_aov_shader("N"))
aov_helper.add_aov(display_driver,aov_helper.create_aov_shader("Z"))
# Find driver
print(f"We have an exr driver called{aov_helper.get_driver('EXR').GetName()}")
print(f"We also have a dispaly driver called{aov_helper.get_dispaly_driver().GetName()}")
# Set exr_driver render path
aov_helper.set_driver_path(exr_driver,r"C:\Users\DunHou\Desktop\DelMe")
# Get all aovs of exr_driver
pprint(aov_helper.get_aovs(exr_driver))
# Remove last aov: sss
aov_helper.remove_last_aov(exr_driver)
print(f'We remove the last AOV named: {last_name}')
# Remove specified aov: N of display_driver
aov_helper.remove_aov_type(display_driver,'N')
print('We remove the AOV type: N of the display_driver')
# Get the #emission aov and his #name
emission = aov_helper.get_aov(exr_driver,'emission')
if emission:
print(f'We find a AOV with Named {emission.GetName()}')
# Print current aov info
aov_helper.print_aov()
Arnold.AovManager()
# End record undo
aov_helper.doc.EndUndo()
# How to create and modify vray aovs
def modify_vray_aov():
# Get the doc host the aovs, in this case th active doc vp
doc: c4d.documents.BaseDocument = c4d.documents.GetActiveDocument()
vp: c4d.documents.BaseVideoPost = Renderer.GetVideoPost(doc, Renderer.ID_VRAY)
# Set Vray AOVHelper instance
aov_helper = Vray.AOV(vp)
# the id can find from Renderer.constants.vray, or Vray_id.py
# If #name is None, defulat to type.
diff_aov = aov_helper.create_aov_shader(aov_type = Vray.VRAY_AOV_DIFFUSE)
# Add the DIFFUSE aov just created to the vray aov system
aov_helper.add_aov(diff_aov)
# Add some aovs
aov_helper.add_aov(aov_helper.create_aov_shader(aov_type = Vray.VRAY_AOV_BACKGROUND, aov_name = 'BG'))
aov_helper.add_aov(aov_helper.create_aov_shader(Vray.VRAY_AOV_SPECULAR))
aov_helper.add_aov(aov_helper.create_aov_shader(Vray.VRAY_AOV_REFLECTION))
aov_helper.add_aov(aov_helper.create_aov_shader(Vray.VRAY_AOV_SHADOW))
aov_helper.add_aov(aov_helper.create_aov_shader(Vray.VRAY_AOV_LIGHT_MIX))
# Remove last aov: volume
aov_helper.remove_last_aov()
# Remove specified aov: wire
aov_helper.remove_aov_type(aov_type = Vray.VRAY_AOV_DIFFUSE[0])
# Print current aov info
aov_helper.print_aov()
Vray.AovManager()
# How to create and modify corona aovs
def modify_corona_aov():
# Get the doc host the aovs, in this case th active doc vp
doc: c4d.documents.BaseDocument = c4d.documents.GetActiveDocument()
vp: c4d.documents.BaseVideoPost = Renderer.GetVideoPost(doc, Renderer.ID_CORONA)
# Set Corona AOVHelper instance
aov_helper = Corona.AOV(vp)
# turn on the mutipass
aov_helper.enable_mutipass(True)
# Add the DIFFUSE aov
diff_aov = aov_helper.create_aov_shader(aov_type = Corona.CORONA_MULTIPASS_TYPE_ALBEDO)
aov_helper.add_aov(diff_aov)
# Add some aovs
aov_helper.add_aov(aov_helper.create_aov_shader(aov_type = Corona.CORONA_MULTIPASS_TYPE_EMISSION, aov_name = 'emmision aov'))
aov_helper.add_aov(aov_helper.create_aov_shader(Corona.CORONA_MULTIPASS_TYPE_REFLECT))
aov_helper.add_aov(aov_helper.create_aov_shader(Corona.CORONA_MULTIPASS_TYPE_REFRACT))
aov_helper.add_aov(aov_helper.create_aov_shader(Corona.CORONA_MULTIPASS_TYPE_TRANSLUCENCY))
aov_helper.add_aov(aov_helper.create_aov_shader(Corona.CORONA_MULTIPASS_TYPE_ZDEPTH))
# Remove last aov: volume
aov_helper.remove_last_aov()
# Remove specified aov: wire
aov_helper.remove_aov_type(aov_type = Corona.CORONA_MULTIPASS_TYPE_TRANSLUCENCY)
# Print current aov info
aov_helper.print_aov()
Corona.AovManager()
if __name__ == '__main__':
Renderer.ClearConsole()
modify_redshift_aov()
# modify_octane_aov()
# modify_arnold_aov()
# modify_vray_aov()
# modify_aorona_aov()
c4d.EventAdd()