ai_closure.h
Go to the documentation of this file.
1// Copyright 2021 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
25struct AtBSDF;
26struct 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
48AI_API AI_DEVICE AtClosureType AiClosureType(AtClosureBase* closure);
49AI_API AI_DEVICE AtRGB AiClosureWeight(AtClosureBase* closure);
50AI_API AI_DEVICE void AiClosureSetWeight(AtClosureBase* closure, const AtRGB& weight);
51AI_API AtString AiClosureLabel(AtClosureBase* closure);
52AI_API void AiClosureSetLabel(AtClosureBase* closure, const AtString label);
53AI_API AI_DEVICE AtClosureBase* AiClosureNext(AtClosureBase* closure);
54AI_API AI_DEVICE void AiClosureSetExtraDepth(AtClosureBase* closure, uint8_t extra_depth);
55AI_API AI_DEVICE void AiClosureSetExtraSamples(AtClosureBase* closure, uint8_t extra_samples);
56
57/*
58 * Closure
59 */
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
74private:
75 AtClosureBase* data;
76};
77
78/*
79 * Closure List
80 */
81AI_API AI_DEVICE AtClosureBase* AiClosureListAdd(AtClosureBase* listA, AtClosureBase* listB);
82AI_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
146private:
147 AtClosureBase* data;
148};
149
150/*\}*/
DLL export prefix for API functions (necessary for multi-platform development)
Color types and utilities.
Arnold String allows for fast string comparisons.
Definition: ai_string.h:46
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 AtClosure front() const
First element in the list.
Definition: ai_closure.h:105
AI_DEVICE AtClosureList()
Create empty closure list.
Definition: ai_closure.h:87
AI_DEVICE void add(AtClosure closure)
Add closure to closure list.
Definition: ai_closure.h:111
AI_DEVICE bool empty() const
Test if list is empty.
Definition: ai_closure.h:141
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:107
AtClosureType
Shader closure types.
Definition: ai_closure.h:31
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:91
AI_DEVICE AtRGB weight()
Get closure weight.
Definition: ai_closure.h:66
AI_DEVICE AtClosureType type()
Get closure type.
Definition: ai_closure.h:63
Definition: ai_closure.h:85
Definition: ai_closure.h:61
RGB color.
Definition: ai_color.h:32

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