-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAddRenderElements.ms
More file actions
179 lines (154 loc) · 6.21 KB
/
AddRenderElements.ms
File metadata and controls
179 lines (154 loc) · 6.21 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
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
macroScript VrayRenderElements
category:"ilya_s Scripts"
tooltip:"Add Render Elements"
buttontext:"Add Render Elements"
(
materialElements = #(MultiMatteElement, MultiMatteElement, MultiMatteElement, MultiMatteElement, MultiMatteElement, MultiMatteElement, MultiMatteElement)
carMaterialElements = #(MultiMatteElement, MultiMatteElement)
objectElements = #(MultiMatteElement, MultiMatteElement, MultiMatteElement, MultiMatteElement, MultiMatteElement, MultiMatteElement, MultiMatteElement)
nonDenoiseElements = #(VRayZDepth, VRayBumpNormals, VRayDiffuseFilter, VrayDenoiser)
otherElementsStill = #(VRayRawReflection, VRayRawRefraction, VRayRawLighting, VRayRawShadow, VRaySelfIllumination, VRaySpecular, VRayLightSelect, VRayLightSelect, VRayLightSelect,VRayCryptomatte,VRayAO)
otherElementsAni = #(VRayRawReflection, VRayRawLighting, VRaySelfIllumination, VRaySpecular, VRayReflection, VRayRefraction, VrayLighting, VrayRawGlobalIllumination)
local re = undefined
local mtlNumber = 5
local objNumber = 5
fn getRenderElementByClass elementClass =
(
result = #()
re = maxOps.GetCurRenderElementMgr()
for n = 0 to (re.numrenderelements() - 1) do
(
thisElement = re.getrenderelement n
if ((classof thisElement) as string == elementClass as string) then (append result thisElement)
)
result
)
fn baseMaterialElements addCarElements=
(
-- get the current render element manager
re.removeallrenderelements() -- remove all renderelements
for i = 1 to mtlNumber do
(
re.addrenderelement (MultiMatteElement elementname:("MtlMatte" + (i as string)+"_"))
thisElement = re.GetRenderElement (i-1)
thisElement.enabled = true
thisElement.filterOn = true
thisElement.R_gbufIDOn = true
thisElement.R_gbufID = (3*(i-1)+1)
thisElement.G_gbufIDOn = true
thisElement.G_gbufID = (3*(i-1)+2)
thisElement.B_gbufIDOn = true
thisElement.B_gbufID = (3*(i-1)+3)
thisElement.MatID = true
)
if addCarElements then
(
for i = 1 to carMaterialElements.count do
(
re.addrenderelement (carMaterialElements[i] elementname:("MtlMatte" + ((i+mtlNumber) as string)+"_"))
thisElement = re.GetRenderElement (re.NumRenderElements()-1)
thisElement.enabled = true
thisElement.filterOn = true
thisElement.R_gbufIDOn = true
thisElement.R_gbufID = (3*(i-1)+1)+29
thisElement.G_gbufIDOn = true
thisElement.G_gbufID = (3*(i-1)+2)+29
thisElement.B_gbufIDOn = true
thisElement.B_gbufID = (3*(i-1)+3)+29
thisElement.MatID = true
)
)
for i = 1 to objNumber do
(
re.addrenderelement (MultiMatteElement elementname:("ObjMatte" + (i as string)+"_"))
thisElement = re.GetRenderElement (re.NumRenderElements()-1)
thisElement.enabled = true
thisElement.filterOn = true
thisElement.R_gbufIDOn = true
thisElement.R_gbufID = (3*(i-1)+1)
thisElement.G_gbufIDOn = true
thisElement.G_gbufID = (3*(i-1)+2)
thisElement.B_gbufIDOn = true
thisElement.B_gbufID = (3*(i-1)+3)
thisElement.MatID = false
)
)
rollout AddRendElements "Add Render Elements" width:200 height: 160
(
spinner mtlNumber_spn "# of MtlMatte" range:[1,100,mtlNumber] type:#integer
spinner objNumber_spn "# of ObjMatte" range:[1,100,objNumber] type:#integer
checkbox denoiseEle_chk "Denoise Elements?" width:160 height:20 align:#center
checkbox carEle_chk "Car Mtl Elements (30-35)?" width:160 height:20 align:#center
button still_btn "Still Image" width:160 height:20 align:#center
button ani_btn "Animation" width:160 height:20 align:#center
on mtlNumber_spn changed arg do (mtlNumber = arg)
on objNumber_spn changed arg do (objNumber = arg)
on still_btn pressed do
(
baseMaterialElements carEle_chk.checked
for n in nonDenoiseElements do (re.addrenderelement (n elementname:(n as string)))
for n in otherElementsStill do
(
local addEle = re.addrenderelement (n elementname:(n as string))
if addEle and denoiseEle_chk.checked then
(
local thisEle = re.GetRenderElement (re.NumRenderElements() - 1 )
try(thisEle.denoise = true)catch()
)
)
zdepthArray = getRenderElementByClass VrayZDepth
for i = 1 to zdepthArray.count do
(
zdepthArray[i].zdepth_use_camera_clip_boudaries = false
if zdepthArray.count > 1 then (zdepthArray[i].elementName = zdepthArray[i].elementName + "_" + i as string)
)
lightSelArray = getRenderElementByClass VrayLightSelect
for i = 1 to lightSelArray.count do
(
lightSelArray[i].mode = 1
if lightSelArray.count > 1 then (lightSelArray[i].elementName = lightSelArray[i].elementName + "_" + i as string)
)
DenoiseArray = getRenderElementByClass VrayDenoiser
for i = 1 to DenoiseArray.count do
(
DenoiseArray[i].mode = 2
if DenoiseArray.count > 1 then (DenoiseArray[i].elementName = DenoiseArray[i].elementName + "_" + i as string)
)
DestroyDialog AddRendElements
)
on ani_btn pressed do
(
baseMaterialElements carEle_chk.checked
for n in nonDenoiseElements do (re.addrenderelement (n elementname:(n as string)))
for n in otherElementsAni do
(
local addEle = re.addrenderelement (n elementname:(n as string))
if addEle and denoiseEle_chk.checked then
(
local thisEle = re.GetRenderElement (re.NumRenderElements() - 1 )
try(thisEle.denoise = true)catch()
)
)
zdepthArray = getRenderElementByClass VrayZDepth
for i = 1 to zdepthArray.count do
(
zdepthArray[i].zdepth_use_camera_clip_boudaries = false
zdepthArray[i].zdepth_min = units.decodeValue "2.0m"
zdepthArray[i].zdepth_max = units.decodeValue "250.0m"
if zdepthArray.count > 1 then (zdepthArray[i].elementName = zdepthArray[i].elementName + "_" + i as string)
)
DenoiseArray = getRenderElementByClass VrayDenoiser
for i = 1 to DenoiseArray.count do
(
DenoiseArray[i].mode = 2
if DenoiseArray.count > 1 then (DenoiseArray[i].elementName = DenoiseArray[i].elementName + "_" + i as string)
)
DestroyDialog AddRendElements
)
)
on execute do
(
createDialog AddRendElements
re = maxOps.GetCurRenderElementMgr()
)
)