1 /**
2 Directional light from a distance, as from the Sun.
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.directionallight;
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.light;
25 /**
26 Directional light from a distance, as from the Sun.
27 
28 A directional light is a type of $(D Light) node that models an infinite number of parallel rays covering the entire scene. It is used for lights with strong intensity that are located far away from the scene to model sunlight or moonlight. The worldspace location of the DirectionalLight transform (origin) is ignored. Only the basis is used to determine light direction.
29 */
30 @GodotBaseClass struct DirectionalLight
31 {
32 	package(godot) enum string _GODOT_internal_name = "DirectionalLight";
33 public:
34 @nogc nothrow:
35 	union { /** */ godot_object _godot_object; /** */ Light _GODOT_base; }
36 	alias _GODOT_base this;
37 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
38 	package(godot) __gshared bool _classBindingInitialized = false;
39 	package(godot) static struct GDNativeClassBinding
40 	{
41 		__gshared:
42 		@GodotName("get_shadow_depth_range") GodotMethod!(DirectionalLight.ShadowDepthRange) getShadowDepthRange;
43 		@GodotName("get_shadow_mode") GodotMethod!(DirectionalLight.ShadowMode) getShadowMode;
44 		@GodotName("is_blend_splits_enabled") GodotMethod!(bool) isBlendSplitsEnabled;
45 		@GodotName("set_blend_splits") GodotMethod!(void, bool) setBlendSplits;
46 		@GodotName("set_shadow_depth_range") GodotMethod!(void, long) setShadowDepthRange;
47 		@GodotName("set_shadow_mode") GodotMethod!(void, long) setShadowMode;
48 	}
49 	/// 
50 	pragma(inline, true) bool opEquals(in DirectionalLight other) const
51 	{ return _godot_object.ptr is other._godot_object.ptr; }
52 	/// 
53 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
54 	{ _godot_object.ptr = n; return null; }
55 	/// 
56 	pragma(inline, true) bool opEquals(typeof(null) n) const
57 	{ return _godot_object.ptr is n; }
58 	/// 
59 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
60 	mixin baseCasts;
61 	/// Construct a new instance of DirectionalLight.
62 	/// Note: use `memnew!DirectionalLight` instead.
63 	static DirectionalLight _new()
64 	{
65 		static godot_class_constructor constructor;
66 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("DirectionalLight");
67 		if(constructor is null) return typeof(this).init;
68 		return cast(DirectionalLight)(constructor());
69 	}
70 	@disable new(size_t s);
71 	/// 
72 	enum ShadowMode : int
73 	{
74 		/**
75 		Renders the entire scene's shadow map from an orthogonal point of view. This is the fastest directional shadow mode. May result in blurrier shadows on close objects.
76 		*/
77 		shadowOrthogonal = 0,
78 		/**
79 		Splits the view frustum in 2 areas, each with its own shadow map. This shadow mode is a compromise between $(D constant SHADOW_ORTHOGONAL) and $(D constant SHADOW_PARALLEL_4_SPLITS) in terms of performance.
80 		*/
81 		shadowParallel2Splits = 1,
82 		/**
83 		Splits the view frustum in 4 areas, each with its own shadow map. This is the slowest directional shadow mode.
84 		*/
85 		shadowParallel4Splits = 2,
86 	}
87 	/// 
88 	enum ShadowDepthRange : int
89 	{
90 		/**
91 		Keeps the shadow stable when the camera moves, at the cost of lower effective shadow resolution.
92 		*/
93 		shadowDepthRangeStable = 0,
94 		/**
95 		Tries to achieve maximum shadow resolution. May result in saw effect on shadow edges. This mode typically works best in games where the camera will often move at high speeds, such as most racing games.
96 		*/
97 		shadowDepthRangeOptimized = 1,
98 	}
99 	/// 
100 	enum Constants : int
101 	{
102 		shadowDepthRangeStable = 0,
103 		shadowOrthogonal = 0,
104 		shadowParallel2Splits = 1,
105 		shadowDepthRangeOptimized = 1,
106 		shadowParallel4Splits = 2,
107 	}
108 	/**
109 	
110 	*/
111 	DirectionalLight.ShadowDepthRange getShadowDepthRange() const
112 	{
113 		checkClassBinding!(typeof(this))();
114 		return ptrcall!(DirectionalLight.ShadowDepthRange)(GDNativeClassBinding.getShadowDepthRange, _godot_object);
115 	}
116 	/**
117 	
118 	*/
119 	DirectionalLight.ShadowMode getShadowMode() const
120 	{
121 		checkClassBinding!(typeof(this))();
122 		return ptrcall!(DirectionalLight.ShadowMode)(GDNativeClassBinding.getShadowMode, _godot_object);
123 	}
124 	/**
125 	
126 	*/
127 	bool isBlendSplitsEnabled() const
128 	{
129 		checkClassBinding!(typeof(this))();
130 		return ptrcall!(bool)(GDNativeClassBinding.isBlendSplitsEnabled, _godot_object);
131 	}
132 	/**
133 	
134 	*/
135 	void setBlendSplits(in bool enabled)
136 	{
137 		checkClassBinding!(typeof(this))();
138 		ptrcall!(void)(GDNativeClassBinding.setBlendSplits, _godot_object, enabled);
139 	}
140 	/**
141 	
142 	*/
143 	void setShadowDepthRange(in long mode)
144 	{
145 		checkClassBinding!(typeof(this))();
146 		ptrcall!(void)(GDNativeClassBinding.setShadowDepthRange, _godot_object, mode);
147 	}
148 	/**
149 	
150 	*/
151 	void setShadowMode(in long mode)
152 	{
153 		checkClassBinding!(typeof(this))();
154 		ptrcall!(void)(GDNativeClassBinding.setShadowMode, _godot_object, mode);
155 	}
156 	/**
157 	Amount of extra bias for shadow splits that are far away. If self-shadowing occurs only on the splits far away, increasing this value can fix them.
158 	*/
159 	@property double directionalShadowBiasSplitScale()
160 	{
161 		return getParam(14);
162 	}
163 	/// ditto
164 	@property void directionalShadowBiasSplitScale(double v)
165 	{
166 		setParam(14, v);
167 	}
168 	/**
169 	If `true`, shadow detail is sacrificed in exchange for smoother transitions between splits.
170 	*/
171 	@property bool directionalShadowBlendSplits()
172 	{
173 		return isBlendSplitsEnabled();
174 	}
175 	/// ditto
176 	@property void directionalShadowBlendSplits(bool v)
177 	{
178 		setBlendSplits(v);
179 	}
180 	/**
181 	Optimizes shadow rendering for detail versus movement. See $(D shadowdepthrange).
182 	*/
183 	@property DirectionalLight.ShadowDepthRange directionalShadowDepthRange()
184 	{
185 		return getShadowDepthRange();
186 	}
187 	/// ditto
188 	@property void directionalShadowDepthRange(long v)
189 	{
190 		setShadowDepthRange(v);
191 	}
192 	/**
193 	The maximum distance for shadow splits.
194 	*/
195 	@property double directionalShadowMaxDistance()
196 	{
197 		return getParam(8);
198 	}
199 	/// ditto
200 	@property void directionalShadowMaxDistance(double v)
201 	{
202 		setParam(8, v);
203 	}
204 	/**
205 	The light's shadow rendering algorithm. See $(D shadowmode).
206 	*/
207 	@property DirectionalLight.ShadowMode directionalShadowMode()
208 	{
209 		return getShadowMode();
210 	}
211 	/// ditto
212 	@property void directionalShadowMode(long v)
213 	{
214 		setShadowMode(v);
215 	}
216 	/**
217 	Can be used to fix special cases of self shadowing when objects are perpendicular to the light.
218 	*/
219 	@property double directionalShadowNormalBias()
220 	{
221 		return getParam(12);
222 	}
223 	/// ditto
224 	@property void directionalShadowNormalBias(double v)
225 	{
226 		setParam(12, v);
227 	}
228 	/**
229 	The distance from camera to shadow split 1. Relative to $(D directionalShadowMaxDistance). Only used when $(D directionalShadowMode) is `SHADOW_PARALLEL_2_SPLITS` or `SHADOW_PARALLEL_4_SPLITS`.
230 	*/
231 	@property double directionalShadowSplit1()
232 	{
233 		return getParam(9);
234 	}
235 	/// ditto
236 	@property void directionalShadowSplit1(double v)
237 	{
238 		setParam(9, v);
239 	}
240 	/**
241 	The distance from shadow split 1 to split 2. Relative to $(D directionalShadowMaxDistance). Only used when $(D directionalShadowMode) is `SHADOW_PARALLEL_2_SPLITS` or `SHADOW_PARALLEL_4_SPLITS`.
242 	*/
243 	@property double directionalShadowSplit2()
244 	{
245 		return getParam(10);
246 	}
247 	/// ditto
248 	@property void directionalShadowSplit2(double v)
249 	{
250 		setParam(10, v);
251 	}
252 	/**
253 	The distance from shadow split 2 to split 3. Relative to $(D directionalShadowMaxDistance). Only used when $(D directionalShadowMode) is `SHADOW_PARALLEL_4_SPLITS`.
254 	*/
255 	@property double directionalShadowSplit3()
256 	{
257 		return getParam(11);
258 	}
259 	/// ditto
260 	@property void directionalShadowSplit3(double v)
261 	{
262 		setParam(11, v);
263 	}
264 }