/
as_standard_surface.osl
934 lines (869 loc) · 31.3 KB
/
as_standard_surface.osl
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
//
// This source file is part of appleseed.
// Visit https://appleseedhq.net/ for additional information and resources.
//
// This software is released under the MIT license.
//
// Copyright (c) 2017-2019 Luis Barrancos, The appleseedhq Organization
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#include "appleseed/material/as_material_helpers.h"
#include "appleseed/math/as_math_helpers.h"
shader as_standard_surface
[[
string help = "appleseed's standard material shader.",
string icon = "asStandardSurface.png",
string URL = "https://appleseed.readthedocs.io/projects/appleseed-maya/en/latest/shaders/material/as_standard_surface.html",
string as_node_name = "asStandardSurface",
string as_category = "shader",
string as_max_class_id = "651059681 943276521",
string as_max_plugin_type = "material",
int as_maya_type_id = 0x001279d4,
string as_maya_classification = "drawdb/shader/surface:rendernode/appleseed/surface:shader/surface:swatch/AppleseedRenderSwatch"
]]
(
float in_diffuse_weight = 1.0
[[
string as_maya_attribute_name = "diffuseWeight",
string as_maya_attribute_short_name = "diw",
float min = 0.0,
float max = 1.0,
string label = "Diffuse Weight",
string page = "Diffuse",
int as_max_param_id = 0
]],
color in_color = color(0.5)
[[
string as_maya_attribute_name = "color",
string as_maya_attribute_short_name = "c",
string label = "Diffuse Color",
string page = "Diffuse",
int as_max_param_id = 2
]],
float in_diffuse_roughness = 0.1
[[
string as_maya_attribute_name = "diffuseRoughness",
string as_maya_attribute_short_name = "dir",
float min = 0.0,
float max = 1.0,
string label = "Diffuse Roughness",
string page = "Diffuse",
int as_max_param_id = 4
]],
float in_subsurface_weight = 0.0
[[
string as_maya_attribute_name = "subsurfaceWeight",
string as_maya_attribute_short_name = "ssw",
float min = 0.0,
float max = 1.0,
string label = "Subsurface Weight",
string page = "Subsurface",
int divider = 1,
int as_max_param_id = 6
]],
color in_sss_mfp = color(0)
[[
string as_maya_attribute_name = "subsurfaceMfp",
string as_maya_attribute_short_name = "mfp",
string label = "Depth",
string page = "Subsurface",
int as_max_param_id = 8
]],
float in_sss_mfp_scale = 1.0
[[
string as_maya_attribute_name = "subsurfaceMfpScale",
string as_maya_attribute_short_name = "sfm",
float min = 0.0,
float max = 1000.0,
float softmax = 100.0,
string label = "Depth Scale",
string page = "Subsurface",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 1,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 10
]],
int in_subsurface_profile = 2
[[
string as_maya_attribute_name = "subsurfaceProfile",
string as_maya_attribute_short_name = "ssp",
string widget = "mapper",
string options = "Gaussian:0|Dipole:1|Normalized Diffusion:2|Random Walk:3",
string label = "Subsurface Profile",
string page = "Subsurface.Advanced",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int divider = 1,
int as_max_param_id = 11
]],
int in_sss_maximum_ray_depth = 2
[[
string as_maya_attribute_name = "sssMaximumRayDepth",
string as_maya_attribute_short_name = "ssd",
int min = 1,
int max = 16,
int softmax = 8,
string label = "Subsurface Ray Depth",
string page = "Subsurface.Advanced",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 12
]],
float in_sss_threshold = 0.001
[[
string as_maya_attribute_name = "sssThreshold",
string as_maya_attibute_short_name = "sth",
float min = 0.0,
float max = 1.0,
float softmax = 0.01,
string label = "Subsurface Threshold",
string page = "Subsurface.Advanced",
string help = "Threshold at which the subsurface scattering term is replaced by a diffuse term.",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 13
]],
float in_translucency_weight = 0.0
[[
string as_maya_attribute_name = "translucencyWeight",
string as_maya_attribute_short_name = "trw",
float min = 0.0,
float max = 1.0,
string label = "Translucency Weight",
string page = "Translucency",
int as_max_param_id = 14
]],
color in_translucency_color = color(0.0)
[[
string as_maya_attribute_name = "translucencyColor",
string as_maya_attribute_short_name = "trc",
string label = "Translucency Color",
string page = "Translucency",
int as_max_param_id = 16
]],
color in_specular_color = color(1)
[[
string as_maya_attribute_name = "specularColor",
string as_maya_attribute_short_name = "spc",
string label = "Specular Color",
string page = "Specular",
int as_max_param_id = 18
]],
float in_specular_roughness = 0.1
[[
string as_maya_attribute_name = "specularRoughness",
string as_maya_attribute_short_name = "sro",
float min = 0.0,
float max = 1.0,
string label = "Specular Roughness",
string page = "Specular",
int as_max_param_id = 20,
int divider = 1
]],
float in_specular_spread = 0.25
[[
string as_maya_attribute_name = "specularSpread",
string as_maya_attribute_short_name = "sps",
string widget = "null",
int as_deprecated = 1,
int as_max_param_id = 22
]],
int in_fresnel_type = 0
[[
string as_maya_attribute_name = "fresnelType",
string as_maya_attribute_short_name = "fty",
string widget = "mapper",
string options = "Dielectric:0|Conductor:1",
string label = "Fresnel Type",
string page = "Specular",
string help = "In dielectric mode, set IOR explicitly, and in conductor mode, set face and edge refletance.",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int divider = 1,
int as_max_param_id = 24
]],
float in_ior = 1.37
[[
string as_maya_attribute_name = "ior",
string as_maya_attribute_short_name = "sio",
float min = 1.0,
float max = 10.0,
float softmax = 2.0,
string label = "Index Of Refraction",
string page = "Specular",
string help = "IOR, only active if Fresnel is set to dielectric.",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 1,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 25
]],
color in_face_tint = color(0.85, 0.21, 0.05)
[[
string as_maya_attribute_name = "faceTint",
string as_maya_attribute_short_name = "f0",
string label = "Facing Tint",
string page = "Specular",
string help = "Reflectance at facing angle, for conductor Fresnel.",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 26
]],
color in_edge_tint = color(1)
[[
string as_maya_attribute_name = "edgeTint",
string as_maya_attribute_short_name = "f90",
string label = "Edge Tint",
string page = "Specular",
string help = "Reflectance at grazing angle, conductor Fresnel only.",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 27
]],
float in_edge_tint_weight = 0.0
[[
string as_maya_attribute_name = "edgeTintWeight",
string as_maya_attribute_short_name = "f90w",
string label = "Edge Tint Weight",
string page = "Specular",
string help = "Edge tint weight.",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int divider = 1,
int as_max_param_id = 71
]],
float in_anisotropy_amount = 0.0
[[
string as_maya_attribute_name = "anisotropyAmount",
string as_maya_attribute_short_name = "anw",
float min = 0.0,
float max = 1.0,
string label = "Anisotropy Amount",
string page = "Specular.Anisotropy",
int as_max_param_id = 28
]],
float in_anisotropy_angle = 0.0
[[
string as_maya_attribute_name = "anisotropyAngle",
string as_maya_attribute_short_name = "ana",
float min = 0.0,
float max = 1.0,
string label = "Anisotropy Angle",
string page = "Specular.Anisotropy",
string help = "Anisotropy angle in [0,1], mapping to [0,360] degrees.",
int as_max_param_id = 30
]],
color in_anisotropy_map = color(0)
[[
string as_maya_attribute_name = "anisotropyMap",
string as_maya_attribute_short_name = "ama",
string label = "Anisotropy Vector Map",
string page = "Specular.Anisotropy",
string help = "Anisotropy vector map, with XY encoded in RG channels.",
int as_max_param_id = 32
]],
float in_refraction_amount = 0.0
[[
string as_maya_attribute_name = "refractionAmount",
string as_maya_attribute_short_name = "rtw",
float min = 0.0,
float max = 1.0,
string label = "Refraction Weight",
string page = "Specular.Refraction",
string help = "Refraction weight. Refraction inherits the IOR.",
int as_max_param_id = 34
]],
color in_refraction_tint = color(1)
[[
string as_maya_attribute_name = "refractionTint",
string as_maya_attribute_short_name = "rti",
string label = "Refraction Tint",
string page = "Specular.Refraction",
int divider = 1,
int as_max_param_id = 36
]],
float in_absorption_depth = 0.0
[[
string as_maya_attribute_name = "absorptionDepth",
string as_maya_attribute_short_name = "rad",
float min = 0.0,
float max = 10000.0,
float softmax = 100.0,
string label = "Absorption Depth",
string page = "Specular.Refraction",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 38
]],
color in_absorption_color = color(1)
[[
string as_maya_attribute_name = "absorptionColor",
string as_maya_attribute_short_name = "rac",
string label = "Absorption Color",
string page = "Specular.Refraction",
int as_max_param_id = 39
]],
float in_coating_reflectivity = 0.0
[[
string as_maya_attribute_name = "coatingReflectivity",
string as_maya_attribute_short_name = "cow",
float min = 0.0,
float max = 1.0,
string label = "Coating Reflectivity",
string page = "Coating",
string help = "Coating specular reflectivity.",
int as_max_param_id = 41
]],
float in_coating_roughness = 0.0
[[
string as_maya_attribute_name = "coatingRoughness",
string as_maya_attribute_short_name = "cor",
float min = 0.0,
float max = 1.0,
string label = "Coating Roughness",
string page = "Coating",
int as_max_param_id = 43
]],
float in_coating_ior = 1.42
[[
string as_maya_attribute_name = "coatingIor",
string as_maya_attribute_short_name = "coi",
float min = 1.0,
float max = 5.0,
float softmax = 2.0,
string label = "Coating IOR",
string page = "Coating",
string help = "Coating (monochromatic) dielectric IOR.",
int divider = 1,
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 1,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 45
]],
float in_coating_depth = 0.0
[[
string as_maya_attribute_name = "coatingDepth",
string as_maya_attribute_short_name = "cod",
float min = 0.0,
float max = 10.0,
float softmax = 1.0,
string label = "Coating Thickness",
string page = "Coating",
string help = "Maps from [0,1] to [0,10] microns.",
int as_max_param_id = 46
]],
color in_coating_absorption = color(1)
[[
string as_maya_attribute_name = "coatingAbsorption",
string as_maya_attribute_short_name = "coa",
string label = "Coating Absorption",
string page = "Coating",
int as_max_param_id = 48
]],
float in_incandescence_amount = 0.0
[[
string as_maya_attribute_name = "incandescenceAmount",
string as_maya_attribute_short_name = "inw",
float min = 0.0,
float softmax = 1.0,
string label = "Emission Amount",
string page = "Emission",
int as_max_param_id = 50
]],
int in_incandescence_type = 0
[[
string as_maya_attribute_name = "incandescenceType",
string as_maya_attribute_short_name = "int",
string widget = "mapper",
string options = "Custom:0|Black-body:1",
string label = "Emission Type",
string page = "Emission",
string help = "Custom or black-body radiator EDF.",
int divider = 1,
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 52
]],
color in_incandescence_color = color(0)
[[
string as_maya_attribute_name = "incandescenceColor",
string as_maya_attribute_short_name = "inc",
string label = "Emission Color",
string page = "Emission",
string help = "Emission color, only valid in constant mode.",
int as_max_param_id = 53
]],
int in_temperature = 4300
[[
string as_maya_attribute_name = "temperature",
string as_maya_attribute_short_name = "tem",
int min = 1000,
int max = 11000,
int softmin = 3400,
int softmax = 9300,
string label = "Temperature",
string page = "Emission",
string help = "Temperature in Kelvin degrees, only valid in physically based mode.",
int divider = 1,
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 55
]],
int in_area_normalize_edf = 0
[[
string as_maya_attribute_name = "normalizeAreaEDF",
string as_maya_attribute_short_name = "nae",
string widget = "checkBox",
string label = "Normalize Area",
string page = "Emission",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 56
]],
int in_tonemap_edf = 1
[[
string as_maya_attribute_name = "toneMapEDF",
string as_maya_attribute_short_name = "tme",
string widget = "checkBox",
string label = "Tonemap Color",
string page = "Emission",
string help = "Tonemap emission, only valid for the black-body radiator mode.",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 57
]],
color in_transparency = color(0)
[[
string as_maya_attribute_name = "transparency",
string as_maya_attribute_short_name = "it",
string label = "Transparency Color",
string page = "Transparency",
int as_max_param_id = 58
]],
normal in_bump_normal_coating = N
[[
string as_maya_attribute_name = "coatingNormal",
string as_maya_attribute_short_name = "ncn",
string label = "Coating Normal",
string page = "Bump",
string help = "The coating normal. If not set, the substrate normal is used for both layers.",
int as_max_param_id = 60
]],
normal in_bump_normal_substrate = N
[[
string as_maya_attribute_name = "normalCamera",
string as_maya_attribute_short_name = "n",
string label = "Substrate Normal",
string page = "Bump",
string help = "The default bump normal.",
int as_max_param_id = 61
]],
int in_enable_matte = 0
[[
string as_maya_attribute_name = "enableMatte",
string as_maya_attribute_short_name = "ema",
string widget = "checkBox",
string label = "Enable Matte Opacity",
string page = "Matte Opacity",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int divider = 1,
int as_max_param_id = 62
]],
float in_matte_opacity = 0.0
[[
string as_maya_attribute_name = "matteOpacity",
string as_maya_attribute_short_name = "mao",
float min = 0.0,
float max = 1.0,
string label = "Matte Opacity",
string page = "Matte Opacity",
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 63
]],
color in_matte_opacity_color = color(1,0.5,0)
[[
string as_maya_attribute_name = "matteOpacityColor",
string as_maya_attribute_short_name = "mac",
string label = "Matte Opacity Color",
string page = "Matte Opacity",
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 65
]],
int in_maximum_ray_depth = 100
[[
string as_maya_attribute_name = "maximumRayDepth",
string as_maya_attribute_short_name = "mrd",
int min = 0,
int max = 100,
int softmax = 16,
string label = "Ray Depth",
string page = "Advanced",
int as_maya_attribute_connectable = 0,
int as_maya_attribute_keyable = 0,
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 67
]],
vector Tn = vector(0)
[[
int lockgeom = 0,
int as_maya_attribute_hidden = 1,
string widget = "null",
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0
]],
vector Bn = vector(0)
[[
int lockgeom = 0,
int as_maya_attribute_hidden = 1,
string widget = "null",
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0
]],
output closure color out_outColor = 0
[[
string as_maya_attribute_name = "outColor",
string as_maya_attribute_short_name = "oc",
string widget = "null",
int as_max_param_id = 70
]],
output closure color out_outTransparency = 0
[[
string as_maya_attribute_name = "outTransparency",
string as_maya_attribute_short_name = "ot",
string widget = "null",
int as_max_param_id = 70
]],
output closure color out_outMatteOpacity = 0
[[
string as_maya_attribute_name = "outMatteOpacity",
string as_maya_attribute_short_name = "om",
string widget = "null",
int as_maya_attribute_hidden = 1,
int as_blender_input_socket = 0,
int gafferNoduleLayoutVisible = 0,
int as_max_param_id = 70
]]
)
{
int compute_transparency = (max(in_transparency) > 0.0) ? 1 : 0;
if (compute_transparency)
{
out_outTransparency = in_transparency * transparent();
out_outColor += out_outTransparency;
}
if (raytype("transparency"))
{
if (in_enable_matte)
{
out_outMatteOpacity = as_matte(
in_matte_opacity_color,
in_matte_opacity);
out_outColor += out_outMatteOpacity;
}
return;
}
if (raytype("shadow"))
{
return;
}
int ray_depth = 0;
int status = getattribute("path:ray_depth", ray_depth);
if (!status || ray_depth > in_maximum_ray_depth)
{
return;
}
if (in_transparency == 1.0)
{
return;
}
color opacity = 1.0 - in_transparency;
// Coating first, with full absorption substrate is not lit.
int compute_coating =
(in_coating_reflectivity > 0.0 || in_coating_depth > 0.0) ? 1 : 0;
color coating_transmittance = color(1);
if (compute_coating)
{
normal Nn = isconnected(in_bump_normal_coating)
? normalize(in_bump_normal_coating)
: normalize(in_bump_normal_substrate);
float costheta_o = max(0.0, dot(-I, Nn));
if (in_coating_ior > 1.0)
{
out_outColor += opacity *
in_coating_reflectivity * microfacet(
"beckmann",
Nn,
in_coating_roughness,
in_coating_ior,
0);
// Dielectric coating, usually [1,2], Schlick approx. suffices.
float R0 = sqr((in_coating_ior - 1.0) / (in_coating_ior + 1.0));
float Kr = R0 + (1.0 - R0) * pow(1.0 - costheta_o, 5.0);
coating_transmittance = 1.0 - clamp(Kr, 0.0, 1.0);
}
if (max(coating_transmittance) > 0.0 &&
min(in_coating_absorption) < 1.0)
{
color absorption_coeff = 1.0 - in_coating_absorption;
// Arbitrary value, it seems to provide a good (visual) range.
float max_depth = 10000.0 * sqr(sqr(in_coating_depth));
float tau = max_depth * (1.0 - max(0.0, costheta_o));
// Restrict range to avoid pure saturated colors.
absorption_coeff = clamp(absorption_coeff, 0.0, 0.99);
color fake_absorption = exp(-tau * absorption_coeff);
coating_transmittance *= clamp(fake_absorption, 0.0, 1.0);
}
if (max(coating_transmittance) <= EPS)
{
return;
}
}
int compute_translucency =
(in_translucency_weight * max(in_translucency_color) > 0.0) ? 1 : 0;
int compute_transmission =
(in_refraction_amount * max(in_refraction_tint) > 0.0) ? 1 : 0;
int compute_specular = max(in_specular_color) > 0.0 ? 1 : 0;
int compute_diffuse = (in_diffuse_weight * max(in_color) > 0.0) ? 1 : 0;
int compute_bssrdf = (
ray_depth > in_sss_maximum_ray_depth ||
compute_transparency || compute_translucency || compute_transmission ||
in_subsurface_weight == 0.0 || max(in_sss_mfp) <= in_sss_threshold)
? 0 : 1;
int compute_edf = (in_incandescence_type == 0)
? ((in_incandescence_amount * max(in_incandescence_color) > 0.0) ? 1 : 0)
: ((in_incandescence_amount > 0.0) ? 1 : 0);
// Specular first, to get the transmittance amount and bailout earlier.
color substrate_transmittance = color(1);
normal Nn = normalize(in_bump_normal_substrate);
if (compute_specular || compute_transmission)
{
vector tangent = Tn;
if (in_anisotropy_amount > 0.0)
{
if (isconnected(in_anisotropy_map))
{
vector vector_map = normalize(
(vector) in_anisotropy_map * 2.0 - 1.0);
tangent = normalize(vector_map[0] * Tn + vector_map[1] * Bn);
}
if (in_anisotropy_angle > 0.0)
{
tangent = rotate(
tangent,
in_anisotropy_angle * M_2PI,
point(0),
point(Nn));
}
}
// Evaluate the BSDF (BRDF+BTDF) for monochromatic dielectric IOR only.
if (in_fresnel_type == 0)
{
if (compute_transmission)
{
out_outColor += opacity * as_glass(
Nn,
tangent,
coating_transmittance,
in_specular_color,
in_refraction_amount * in_refraction_tint,
in_specular_roughness,
in_anisotropy_amount,
in_ior,
in_absorption_color,
in_absorption_depth);
}
else if (max(in_specular_color) > 0.0)
{
out_outColor += coating_transmittance * opacity *
in_specular_color * as_glossy(
Nn,
tangent,
in_specular_roughness,
in_anisotropy_amount,
in_ior);
}
}
else if (max(in_specular_color) > 0.0)
{
out_outColor += coating_transmittance * opacity *
in_specular_color * as_metal(
Nn,
tangent,
in_face_tint,
in_edge_tint,
in_edge_tint_weight,
in_specular_roughness,
in_anisotropy_amount);
}
// In order to layer substrate BxDFs, we need the microfacet Fresnel
// transmission amount (and absorption), but lacking that, use viewer.
if ((compute_diffuse || compute_bssrdf || compute_edf ||
compute_translucency) && max(in_specular_color) > 0.0)
{
float costheta_o = max(0.0, dot(-I, Nn));
if (in_fresnel_type == 0)
{
float R0 = sqr((in_ior - 1.0) / (in_ior + 1.0));
float Kr = R0 + (1.0 - R0) * pow(1.0 - costheta_o, 5.0);
substrate_transmittance = 1.0 - clamp(Kr, 0.0, 1.0);
}
else
{
float exterior_n = compute_coating ? in_coating_ior : 1.0;
color Kr = color(0);
color n = get_eta(in_face_tint, in_edge_tint);
color k = get_kappa(in_face_tint, n);
for (int i = 0; i < 3; ++i)
{
Kr[i] = dielectricConductorFresnel(
exterior_n,
n[i],
k[i],
costheta_o);
}
substrate_transmittance = 1.0 - clamp(Kr, 0.0, 1.0);
}
}
}
color transmittance = coating_transmittance * substrate_transmittance;
if (max(transmittance) <= EPS)
{
return;
}
if (raytype("light"))
{
color edf_color = (in_incandescence_type == 0)
? in_incandescence_amount * in_incandescence_color
: in_incandescence_amount * blackbody(in_temperature);
if (compute_edf && in_area_normalize_edf)
{
edf_color /= surfacearea();
}
if (compute_edf && in_tonemap_edf)
{
edf_color /= luminance(edf_color) + 1.0;
}
if (compute_edf && max(edf_color) > 0.0)
{
out_outColor += transmittance * opacity *
edf_color * emission();
}
}
if (compute_bssrdf)
{
color albedo = in_diffuse_weight * in_color;
if (max(albedo) > 0.0)
{
albedo = clamp(albedo, 0.01, 0.99);
string subsurface_profile;
if (in_subsurface_profile == 0)
{
subsurface_profile = "gaussian";
}
else if (in_subsurface_profile == 1)
{
subsurface_profile = "better_dipole";
}
else if (in_subsurface_profile == 2)
{
subsurface_profile = "normalized_diffusion";
}
else
{
subsurface_profile = "randomwalk";
}
// Disable Fresnel weight since transmittance is computed earlier,
// but ideally, the BSSRDF should be used.
out_outColor += in_subsurface_weight *
as_subsurface(
subsurface_profile,
Nn,
in_diffuse_weight * in_color,
in_sss_mfp_scale * in_sss_mfp,
in_ior,
"fresnel_weight", 0.0);
}
}
else
{
color diffuse_color = in_diffuse_weight * in_color;
if (max(diffuse_color) > 0.0)
{
out_outColor += transmittance * opacity *
as_oren_nayar(diffuse_color, Nn, in_diffuse_roughness);
}
color translucency_color = in_translucency_weight *
in_translucency_color;
if (max(translucency_color) > 0.0)
{
out_outColor += transmittance * opacity *
translucency_color * translucent(Nn);
}
}
}