ai_closure.h
Go to the documentation of this file.
1 // Copyright 2020 Autodesk, Inc. All rights reserved.
2 //
3 // Use of this software is subject to the terms of the Autodesk license
4 // agreement provided at the time of installation or download, or which
5 // otherwise accompanies this software in either electronic or hard copy form.
6 
12 #pragma once
13 #include "ai_api.h"
14 #include "ai_color.h"
15 
16 #include <stdint.h>
17 
25 struct AtBSDF;
26 struct AtClosureBase;
27 
32  AI_CLOSURE_NONE = 0,
33  AI_CLOSURE_BSDF,
34  AI_CLOSURE_BSSRDF,
35  AI_CLOSURE_EMISSION,
36  AI_CLOSURE_DEBUG,
37  AI_CLOSURE_TRANSPARENT,
38  AI_CLOSURE_MATTE,
39  AI_CLOSURE_BACKGROUND,
40  AI_CLOSURE_VOLUME_ABSORPTION,
41  AI_CLOSURE_VOLUME_SCATTERING,
42  AI_CLOSURE_VOLUME_EMISSION,
43  AI_CLOSURE_VOLUME_MATTE,
44  AI_CLOSURE_VOLUME_ATMOSPHERE,
45  AI_CLOSURE_DIELECTRIC
46 };
47 
48 AI_API AI_DEVICE AtClosureType AiClosureType(AtClosureBase* closure);
49 AI_API AI_DEVICE AtRGB AiClosureWeight(AtClosureBase* closure);
50 AI_API AI_DEVICE void AiClosureSetWeight(AtClosureBase* closure, const AtRGB& weight);
51 AI_API AtString AiClosureLabel(AtClosureBase* closure);
52 AI_API void AiClosureSetLabel(AtClosureBase* closure, const AtString label);
53 AI_API AI_DEVICE AtClosureBase* AiClosureNext(AtClosureBase* closure);
54 AI_API AI_DEVICE void AiClosureSetExtraDepth(AtClosureBase* closure, uint8_t extra_depth);
55 AI_API AI_DEVICE void AiClosureSetExtraSamples(AtClosureBase* closure, uint8_t extra_samples);
56 
57 /*
58  * Closure
59  */
60 struct AtClosure
61 {
63  AI_DEVICE AtClosureType type() { return AiClosureType(data); }
64 
66  AI_DEVICE AtRGB weight() { return AiClosureWeight(data); }
67 
69  AI_DEVICE AtClosure next() { return AiClosureNext(data); };
70 
71  AI_DEVICE AtClosure(AtClosureBase* data_) : data(data_) {}
72  AI_DEVICE operator AtClosureBase*() const { return data; }
73 
74 private:
75  AtClosureBase* data;
76 };
77 
78 /*
79  * Closure List
80  */
81 AI_API AI_DEVICE AtClosureBase* AiClosureListAdd(AtClosureBase* listA, AtClosureBase* listB);
82 AI_API AI_DEVICE AtClosureBase* AiClosureListWeight(AtClosureBase* list, const AtRGB& weight);
83 
85 {
87  AI_DEVICE AtClosureList()
88  : data(NULL)
89  {
90  }
91 
93  AI_DEVICE AtClosureList(AtClosure data_)
94  : data(data_)
95  {
96  }
97 
99  AI_DEVICE AtClosureList(AtBSDF* data_)
100  : data((AtClosureBase*)data_)
101  {
102  }
103 
105  AI_DEVICE AtClosure front() const
106  {
107  return data;
108  }
109 
111  AI_DEVICE inline void add(AtClosure closure)
112  {
113  data = AiClosureListAdd(data, (AtClosureBase*)closure);
114  }
115 
117  AI_DEVICE inline void add(AtBSDF* bsdf)
118  {
119  data = AiClosureListAdd(data, (AtClosureBase*)bsdf);
120  }
121 
123  AI_DEVICE inline void add(AtClosureList list)
124  {
125  data = AiClosureListAdd(data, list.data);
126  }
127 
129  AI_DEVICE inline void operator*=(const AtRGB& weight)
130  {
131  data = AiClosureListWeight(data, weight);
132  }
133 
135  AI_DEVICE inline void operator*=(float weight)
136  {
137  data = AiClosureListWeight(data, AtRGB(weight));
138  }
139 
141  AI_DEVICE inline bool empty() const
142  {
143  return data == NULL;
144  }
145 
146 private:
147  AtClosureBase* data;
148 };
149 
150 /*\}*/
AI_DEVICE AtClosure front() const
First element in the list.
Definition: ai_closure.h:105
RGB color.
Definition: ai_color.h:31
AI_DEVICE void add(AtClosure closure)
Add closure to closure list.
Definition: ai_closure.h:111
AI_DEVICE AtClosureType type()
Get closure type.
Definition: ai_closure.h:63
AI_DEVICE void add(AtBSDF *bsdf)
Add BSDF to closure list.
Definition: ai_closure.h:117
AI_DEVICE void operator*=(const AtRGB &weight)
Multiply weight of all closures in the list.
Definition: ai_closure.h:129
AI_DEVICE AtClosure next()
Get next closure, if part of an AtClosureList.
Definition: ai_closure.h:69
AI_DEVICE AtClosureList(AtClosure data_)
Create closure list from single closure.
Definition: ai_closure.h:93
Arnold String allows for fast string comparisons.
Definition: ai_string.h:46
Definition: ai_closure.h:60
Color types and utilities.
DLL export prefix for API functions (necessary for multi-platform development)
AI_API AI_DEVICE void AiClosureSetExtraSamples(AtClosureBase *closure, uint8_t extra_samples)
Set BSDF, BSSRDF or volume closures to use additional GI samples.
Definition: ai_shader_closure.cpp:102
AI_API AI_DEVICE void AiClosureSetExtraDepth(AtClosureBase *closure, uint8_t extra_depth)
Set BSDF, BSSRDF or volume closures to use additional GI depth.
Definition: ai_shader_closure.cpp:86
AI_DEVICE void add(AtClosureList list)
Add closure list to closure list.
Definition: ai_closure.h:123
AI_DEVICE AtClosureList(AtBSDF *data_)
Create closure list from single BSDF.
Definition: ai_closure.h:99
AI_DEVICE void operator*=(float weight)
Multiply weight of all closures in the list.
Definition: ai_closure.h:135
Definition: ai_closure.h:84
AI_DEVICE bool empty() const
Test if list is empty.
Definition: ai_closure.h:141
AI_DEVICE AtClosureList()
Create empty closure list.
Definition: ai_closure.h:87
AI_DEVICE AtRGB weight()
Get closure weight.
Definition: ai_closure.h:66
AtClosureType
Shader closure types.
Definition: ai_closure.h:31

© 2020 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com