1 /** 2 A $(D Color) operator to be used within the visual shader graph. 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.visualshadernodecolorop; 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.visualshadernode; 25 import godot.resource; 26 import godot.reference; 27 /** 28 A $(D Color) operator to be used within the visual shader graph. 29 30 Applies $(D operator) to two color inputs. 31 */ 32 @GodotBaseClass struct VisualShaderNodeColorOp 33 { 34 package(godot) enum string _GODOT_internal_name = "VisualShaderNodeColorOp"; 35 public: 36 @nogc nothrow: 37 union { /** */ godot_object _godot_object; /** */ VisualShaderNode _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("get_operator") GodotMethod!(VisualShaderNodeColorOp.Operator) getOperator; 45 @GodotName("set_operator") GodotMethod!(void, long) setOperator; 46 } 47 /// 48 pragma(inline, true) bool opEquals(in VisualShaderNodeColorOp other) const 49 { return _godot_object.ptr is other._godot_object.ptr; } 50 /// 51 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 52 { _godot_object.ptr = n; return null; } 53 /// 54 pragma(inline, true) bool opEquals(typeof(null) n) const 55 { return _godot_object.ptr is n; } 56 /// 57 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 58 mixin baseCasts; 59 /// Construct a new instance of VisualShaderNodeColorOp. 60 /// Note: use `memnew!VisualShaderNodeColorOp` instead. 61 static VisualShaderNodeColorOp _new() 62 { 63 static godot_class_constructor constructor; 64 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("VisualShaderNodeColorOp"); 65 if(constructor is null) return typeof(this).init; 66 return cast(VisualShaderNodeColorOp)(constructor()); 67 } 68 @disable new(size_t s); 69 /// 70 enum Operator : int 71 { 72 /** 73 Produce a screen effect with the following formula: 74 75 76 result = vec3(1.0) - (vec3(1.0) - a) * (vec3(1.0) - b); 77 78 79 */ 80 opScreen = 0, 81 /** 82 Produce a difference effect with the following formula: 83 84 85 result = abs(a - b); 86 87 88 */ 89 opDifference = 1, 90 /** 91 Produce a darken effect with the following formula: 92 93 94 result = min(a, b); 95 96 97 */ 98 opDarken = 2, 99 /** 100 Produce a lighten effect with the following formula: 101 102 103 result = max(a, b); 104 105 106 */ 107 opLighten = 3, 108 /** 109 Produce an overlay effect with the following formula: 110 111 112 for (int i = 0; i < 3; i++) { 113 float base = a$(D i); 114 float blend = b$(D i); 115 if (base < 0.5) { 116 result$(D i) = 2.0 * base * blend; 117 } else { 118 result$(D i) = 1.0 - 2.0 * (1.0 - blend) * (1.0 - base); 119 } 120 } 121 122 123 */ 124 opOverlay = 4, 125 /** 126 Produce a dodge effect with the following formula: 127 128 129 result = a / (vec3(1.0) - b); 130 131 132 */ 133 opDodge = 5, 134 /** 135 Produce a burn effect with the following formula: 136 137 138 result = vec3(1.0) - (vec3(1.0) - a) / b; 139 140 141 */ 142 opBurn = 6, 143 /** 144 Produce a soft light effect with the following formula: 145 146 147 for (int i = 0; i < 3; i++) { 148 float base = a$(D i); 149 float blend = b$(D i); 150 if (base < 0.5) { 151 result$(D i) = base * (blend + 0.5); 152 } else { 153 result$(D i) = 1.0 - (1.0 - base) * (1.0 - (blend - 0.5)); 154 } 155 } 156 157 158 */ 159 opSoftLight = 7, 160 /** 161 Produce a hard light effect with the following formula: 162 163 164 for (int i = 0; i < 3; i++) { 165 float base = a$(D i); 166 float blend = b$(D i); 167 if (base < 0.5) { 168 result$(D i) = base * (2.0 * blend); 169 } else { 170 result$(D i) = 1.0 - (1.0 - base) * (1.0 - 2.0 * (blend - 0.5)); 171 } 172 } 173 174 175 */ 176 opHardLight = 8, 177 } 178 /// 179 enum Constants : int 180 { 181 opScreen = 0, 182 opDifference = 1, 183 opDarken = 2, 184 opLighten = 3, 185 opOverlay = 4, 186 opDodge = 5, 187 opBurn = 6, 188 opSoftLight = 7, 189 opHardLight = 8, 190 } 191 /** 192 193 */ 194 VisualShaderNodeColorOp.Operator getOperator() const 195 { 196 checkClassBinding!(typeof(this))(); 197 return ptrcall!(VisualShaderNodeColorOp.Operator)(GDNativeClassBinding.getOperator, _godot_object); 198 } 199 /** 200 201 */ 202 void setOperator(in long op) 203 { 204 checkClassBinding!(typeof(this))(); 205 ptrcall!(void)(GDNativeClassBinding.setOperator, _godot_object, op); 206 } 207 /** 208 An operator to be applied to the inputs. See $(D operator) for options. 209 */ 210 @property VisualShaderNodeColorOp.Operator operator() 211 { 212 return getOperator(); 213 } 214 /// ditto 215 @property void operator(long v) 216 { 217 setOperator(v); 218 } 219 }