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