1 /**
2 Captures its surroundings to create reflections.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.reflectionprobe;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.visualinstance;
25 /**
26 Captures its surroundings to create reflections.
27 
28 Capture its surroundings as a dual paraboloid image, and stores versions of it with increasing levels of blur to simulate different material roughnesses.
29 The $(D ReflectionProbe) is used to create high-quality reflections at the cost of performance. It can be combined with $(D GIProbe)s and Screen Space Reflections to achieve high quality reflections. $(D ReflectionProbe)s render all objects within their $(D cullMask), so updating them can be quite expensive. It is best to update them once with the important static objects and then leave them.
30 Note: By default Godot will only render 16 reflection probes. If you need more, increase the number of atlas subdivisions. This setting can be found in $(D ProjectSettings.rendering/quality/reflections/atlasSubdiv).
31 */
32 @GodotBaseClass struct ReflectionProbe
33 {
34 	package(godot) enum string _GODOT_internal_name = "ReflectionProbe";
35 public:
36 @nogc nothrow:
37 	union { /** */ godot_object _godot_object; /** */ VisualInstance _GODOT_base; }
38 	alias _GODOT_base this;
39 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
40 	package(godot) __gshared bool _classBindingInitialized = false;
41 	package(godot) static struct GDNativeClassBinding
42 	{
43 		__gshared:
44 		@GodotName("are_shadows_enabled") GodotMethod!(bool) areShadowsEnabled;
45 		@GodotName("get_cull_mask") GodotMethod!(long) getCullMask;
46 		@GodotName("get_extents") GodotMethod!(Vector3) getExtents;
47 		@GodotName("get_intensity") GodotMethod!(double) getIntensity;
48 		@GodotName("get_interior_ambient") GodotMethod!(Color) getInteriorAmbient;
49 		@GodotName("get_interior_ambient_energy") GodotMethod!(double) getInteriorAmbientEnergy;
50 		@GodotName("get_interior_ambient_probe_contribution") GodotMethod!(double) getInteriorAmbientProbeContribution;
51 		@GodotName("get_max_distance") GodotMethod!(double) getMaxDistance;
52 		@GodotName("get_origin_offset") GodotMethod!(Vector3) getOriginOffset;
53 		@GodotName("get_update_mode") GodotMethod!(ReflectionProbe.UpdateMode) getUpdateMode;
54 		@GodotName("is_box_projection_enabled") GodotMethod!(bool) isBoxProjectionEnabled;
55 		@GodotName("is_set_as_interior") GodotMethod!(bool) isSetAsInterior;
56 		@GodotName("set_as_interior") GodotMethod!(void, bool) setAsInterior;
57 		@GodotName("set_cull_mask") GodotMethod!(void, long) setCullMask;
58 		@GodotName("set_enable_box_projection") GodotMethod!(void, bool) setEnableBoxProjection;
59 		@GodotName("set_enable_shadows") GodotMethod!(void, bool) setEnableShadows;
60 		@GodotName("set_extents") GodotMethod!(void, Vector3) setExtents;
61 		@GodotName("set_intensity") GodotMethod!(void, double) setIntensity;
62 		@GodotName("set_interior_ambient") GodotMethod!(void, Color) setInteriorAmbient;
63 		@GodotName("set_interior_ambient_energy") GodotMethod!(void, double) setInteriorAmbientEnergy;
64 		@GodotName("set_interior_ambient_probe_contribution") GodotMethod!(void, double) setInteriorAmbientProbeContribution;
65 		@GodotName("set_max_distance") GodotMethod!(void, double) setMaxDistance;
66 		@GodotName("set_origin_offset") GodotMethod!(void, Vector3) setOriginOffset;
67 		@GodotName("set_update_mode") GodotMethod!(void, long) setUpdateMode;
68 	}
69 	/// 
70 	pragma(inline, true) bool opEquals(in ReflectionProbe other) const
71 	{ return _godot_object.ptr is other._godot_object.ptr; }
72 	/// 
73 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
74 	{ _godot_object.ptr = n; return null; }
75 	/// 
76 	pragma(inline, true) bool opEquals(typeof(null) n) const
77 	{ return _godot_object.ptr is n; }
78 	/// 
79 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
80 	mixin baseCasts;
81 	/// Construct a new instance of ReflectionProbe.
82 	/// Note: use `memnew!ReflectionProbe` instead.
83 	static ReflectionProbe _new()
84 	{
85 		static godot_class_constructor constructor;
86 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ReflectionProbe");
87 		if(constructor is null) return typeof(this).init;
88 		return cast(ReflectionProbe)(constructor());
89 	}
90 	@disable new(size_t s);
91 	/// 
92 	enum UpdateMode : int
93 	{
94 		/**
95 		Update the probe once on the next frame.
96 		*/
97 		updateOnce = 0,
98 		/**
99 		Update the probe every frame. This is needed when you want to capture dynamic objects. However, it results in an increased render time. Use $(D constant UPDATE_ONCE) whenever possible.
100 		*/
101 		updateAlways = 1,
102 	}
103 	/// 
104 	enum Constants : int
105 	{
106 		updateOnce = 0,
107 		updateAlways = 1,
108 	}
109 	/**
110 	
111 	*/
112 	bool areShadowsEnabled() const
113 	{
114 		checkClassBinding!(typeof(this))();
115 		return ptrcall!(bool)(GDNativeClassBinding.areShadowsEnabled, _godot_object);
116 	}
117 	/**
118 	
119 	*/
120 	long getCullMask() const
121 	{
122 		checkClassBinding!(typeof(this))();
123 		return ptrcall!(long)(GDNativeClassBinding.getCullMask, _godot_object);
124 	}
125 	/**
126 	
127 	*/
128 	Vector3 getExtents() const
129 	{
130 		checkClassBinding!(typeof(this))();
131 		return ptrcall!(Vector3)(GDNativeClassBinding.getExtents, _godot_object);
132 	}
133 	/**
134 	
135 	*/
136 	double getIntensity() const
137 	{
138 		checkClassBinding!(typeof(this))();
139 		return ptrcall!(double)(GDNativeClassBinding.getIntensity, _godot_object);
140 	}
141 	/**
142 	
143 	*/
144 	Color getInteriorAmbient() const
145 	{
146 		checkClassBinding!(typeof(this))();
147 		return ptrcall!(Color)(GDNativeClassBinding.getInteriorAmbient, _godot_object);
148 	}
149 	/**
150 	
151 	*/
152 	double getInteriorAmbientEnergy() const
153 	{
154 		checkClassBinding!(typeof(this))();
155 		return ptrcall!(double)(GDNativeClassBinding.getInteriorAmbientEnergy, _godot_object);
156 	}
157 	/**
158 	
159 	*/
160 	double getInteriorAmbientProbeContribution() const
161 	{
162 		checkClassBinding!(typeof(this))();
163 		return ptrcall!(double)(GDNativeClassBinding.getInteriorAmbientProbeContribution, _godot_object);
164 	}
165 	/**
166 	
167 	*/
168 	double getMaxDistance() const
169 	{
170 		checkClassBinding!(typeof(this))();
171 		return ptrcall!(double)(GDNativeClassBinding.getMaxDistance, _godot_object);
172 	}
173 	/**
174 	
175 	*/
176 	Vector3 getOriginOffset() const
177 	{
178 		checkClassBinding!(typeof(this))();
179 		return ptrcall!(Vector3)(GDNativeClassBinding.getOriginOffset, _godot_object);
180 	}
181 	/**
182 	
183 	*/
184 	ReflectionProbe.UpdateMode getUpdateMode() const
185 	{
186 		checkClassBinding!(typeof(this))();
187 		return ptrcall!(ReflectionProbe.UpdateMode)(GDNativeClassBinding.getUpdateMode, _godot_object);
188 	}
189 	/**
190 	
191 	*/
192 	bool isBoxProjectionEnabled() const
193 	{
194 		checkClassBinding!(typeof(this))();
195 		return ptrcall!(bool)(GDNativeClassBinding.isBoxProjectionEnabled, _godot_object);
196 	}
197 	/**
198 	
199 	*/
200 	bool isSetAsInterior() const
201 	{
202 		checkClassBinding!(typeof(this))();
203 		return ptrcall!(bool)(GDNativeClassBinding.isSetAsInterior, _godot_object);
204 	}
205 	/**
206 	
207 	*/
208 	void setAsInterior(in bool enable)
209 	{
210 		checkClassBinding!(typeof(this))();
211 		ptrcall!(void)(GDNativeClassBinding.setAsInterior, _godot_object, enable);
212 	}
213 	/**
214 	
215 	*/
216 	void setCullMask(in long layers)
217 	{
218 		checkClassBinding!(typeof(this))();
219 		ptrcall!(void)(GDNativeClassBinding.setCullMask, _godot_object, layers);
220 	}
221 	/**
222 	
223 	*/
224 	void setEnableBoxProjection(in bool enable)
225 	{
226 		checkClassBinding!(typeof(this))();
227 		ptrcall!(void)(GDNativeClassBinding.setEnableBoxProjection, _godot_object, enable);
228 	}
229 	/**
230 	
231 	*/
232 	void setEnableShadows(in bool enable)
233 	{
234 		checkClassBinding!(typeof(this))();
235 		ptrcall!(void)(GDNativeClassBinding.setEnableShadows, _godot_object, enable);
236 	}
237 	/**
238 	
239 	*/
240 	void setExtents(in Vector3 extents)
241 	{
242 		checkClassBinding!(typeof(this))();
243 		ptrcall!(void)(GDNativeClassBinding.setExtents, _godot_object, extents);
244 	}
245 	/**
246 	
247 	*/
248 	void setIntensity(in double intensity)
249 	{
250 		checkClassBinding!(typeof(this))();
251 		ptrcall!(void)(GDNativeClassBinding.setIntensity, _godot_object, intensity);
252 	}
253 	/**
254 	
255 	*/
256 	void setInteriorAmbient(in Color ambient)
257 	{
258 		checkClassBinding!(typeof(this))();
259 		ptrcall!(void)(GDNativeClassBinding.setInteriorAmbient, _godot_object, ambient);
260 	}
261 	/**
262 	
263 	*/
264 	void setInteriorAmbientEnergy(in double ambient_energy)
265 	{
266 		checkClassBinding!(typeof(this))();
267 		ptrcall!(void)(GDNativeClassBinding.setInteriorAmbientEnergy, _godot_object, ambient_energy);
268 	}
269 	/**
270 	
271 	*/
272 	void setInteriorAmbientProbeContribution(in double ambient_probe_contribution)
273 	{
274 		checkClassBinding!(typeof(this))();
275 		ptrcall!(void)(GDNativeClassBinding.setInteriorAmbientProbeContribution, _godot_object, ambient_probe_contribution);
276 	}
277 	/**
278 	
279 	*/
280 	void setMaxDistance(in double max_distance)
281 	{
282 		checkClassBinding!(typeof(this))();
283 		ptrcall!(void)(GDNativeClassBinding.setMaxDistance, _godot_object, max_distance);
284 	}
285 	/**
286 	
287 	*/
288 	void setOriginOffset(in Vector3 origin_offset)
289 	{
290 		checkClassBinding!(typeof(this))();
291 		ptrcall!(void)(GDNativeClassBinding.setOriginOffset, _godot_object, origin_offset);
292 	}
293 	/**
294 	
295 	*/
296 	void setUpdateMode(in long mode)
297 	{
298 		checkClassBinding!(typeof(this))();
299 		ptrcall!(void)(GDNativeClassBinding.setUpdateMode, _godot_object, mode);
300 	}
301 	/**
302 	If `true`, enables box projection. This makes reflections look more correct in rectangle-shaped rooms by offsetting the reflection center depending on the camera's location.
303 	*/
304 	@property bool boxProjection()
305 	{
306 		return isBoxProjectionEnabled();
307 	}
308 	/// ditto
309 	@property void boxProjection(bool v)
310 	{
311 		setEnableBoxProjection(v);
312 	}
313 	/**
314 	Sets the cull mask which determines what objects are drawn by this probe. Every $(D VisualInstance) with a layer included in this cull mask will be rendered by the probe. It is best to only include large objects which are likely to take up a lot of space in the reflection in order to save on rendering cost.
315 	*/
316 	@property long cullMask()
317 	{
318 		return getCullMask();
319 	}
320 	/// ditto
321 	@property void cullMask(long v)
322 	{
323 		setCullMask(v);
324 	}
325 	/**
326 	If `true`, computes shadows in the reflection probe. This makes the reflection probe slower to render; you may want to disable this if using the $(D constant UPDATE_ALWAYS) $(D updateMode).
327 	*/
328 	@property bool enableShadows()
329 	{
330 		return areShadowsEnabled();
331 	}
332 	/// ditto
333 	@property void enableShadows(bool v)
334 	{
335 		setEnableShadows(v);
336 	}
337 	/**
338 	The size of the reflection probe. The larger the extents the more space covered by the probe which will lower the perceived resolution. It is best to keep the extents only as large as you need them.
339 	*/
340 	@property Vector3 extents()
341 	{
342 		return getExtents();
343 	}
344 	/// ditto
345 	@property void extents(Vector3 v)
346 	{
347 		setExtents(v);
348 	}
349 	/**
350 	Defines the reflection intensity. Intensity modulates the strength of the reflection.
351 	*/
352 	@property double intensity()
353 	{
354 		return getIntensity();
355 	}
356 	/// ditto
357 	@property void intensity(double v)
358 	{
359 		setIntensity(v);
360 	}
361 	/**
362 	Sets the ambient light color to be used when this probe is set to $(D interiorEnable).
363 	*/
364 	@property Color interiorAmbientColor()
365 	{
366 		return getInteriorAmbient();
367 	}
368 	/// ditto
369 	@property void interiorAmbientColor(Color v)
370 	{
371 		setInteriorAmbient(v);
372 	}
373 	/**
374 	Sets the contribution value for how much the reflection affects the ambient light for this reflection probe when set to $(D interiorEnable). Useful so that ambient light matches the color of the room.
375 	*/
376 	@property double interiorAmbientContrib()
377 	{
378 		return getInteriorAmbientProbeContribution();
379 	}
380 	/// ditto
381 	@property void interiorAmbientContrib(double v)
382 	{
383 		setInteriorAmbientProbeContribution(v);
384 	}
385 	/**
386 	Sets the energy multiplier for this reflection probe's ambient light contribution when set to $(D interiorEnable).
387 	*/
388 	@property double interiorAmbientEnergy()
389 	{
390 		return getInteriorAmbientEnergy();
391 	}
392 	/// ditto
393 	@property void interiorAmbientEnergy(double v)
394 	{
395 		setInteriorAmbientEnergy(v);
396 	}
397 	/**
398 	If `true`, reflections will ignore sky contribution. Ambient lighting is then controlled by the `interior_ambient_*` properties.
399 	*/
400 	@property bool interiorEnable()
401 	{
402 		return isSetAsInterior();
403 	}
404 	/// ditto
405 	@property void interiorEnable(bool v)
406 	{
407 		setAsInterior(v);
408 	}
409 	/**
410 	Sets the max distance away from the probe an object can be before it is culled.
411 	*/
412 	@property double maxDistance()
413 	{
414 		return getMaxDistance();
415 	}
416 	/// ditto
417 	@property void maxDistance(double v)
418 	{
419 		setMaxDistance(v);
420 	}
421 	/**
422 	Sets the origin offset to be used when this reflection probe is in box project mode.
423 	*/
424 	@property Vector3 originOffset()
425 	{
426 		return getOriginOffset();
427 	}
428 	/// ditto
429 	@property void originOffset(Vector3 v)
430 	{
431 		setOriginOffset(v);
432 	}
433 	/**
434 	Sets how frequently the probe is updated. Can be $(D constant UPDATE_ONCE) or $(D constant UPDATE_ALWAYS).
435 	*/
436 	@property ReflectionProbe.UpdateMode updateMode()
437 	{
438 		return getUpdateMode();
439 	}
440 	/// ditto
441 	@property void updateMode(long v)
442 	{
443 		setUpdateMode(v);
444 	}
445 }