1 /** 2 A material that uses a custom $(D Shader) program. 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.shadermaterial; 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.material; 24 import godot.shader; 25 import godot.resource; 26 import godot.reference; 27 /** 28 A material that uses a custom $(D Shader) program. 29 30 A material that uses a custom $(D Shader) program to render either items to screen or process particles. You can create multiple materials for the same shader but configure different values for the uniforms defined in the shader. 31 */ 32 @GodotBaseClass struct ShaderMaterial 33 { 34 enum string _GODOT_internal_name = "ShaderMaterial"; 35 public: 36 @nogc nothrow: 37 union { godot_object _godot_object; Material _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_shader") GodotMethod!(void, Shader) setShader; 45 @GodotName("get_shader") GodotMethod!(Shader) getShader; 46 @GodotName("set_shader_param") GodotMethod!(void, String, Variant) setShaderParam; 47 @GodotName("get_shader_param") GodotMethod!(Variant, String) getShaderParam; 48 @GodotName("_shader_changed") GodotMethod!(void) _shaderChanged; 49 @GodotName("property_can_revert") GodotMethod!(bool, String) propertyCanRevert; 50 @GodotName("property_get_revert") GodotMethod!(Variant, String) propertyGetRevert; 51 } 52 bool opEquals(in ShaderMaterial other) const { return _godot_object.ptr is other._godot_object.ptr; } 53 ShaderMaterial opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 54 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 55 mixin baseCasts; 56 static ShaderMaterial _new() 57 { 58 static godot_class_constructor constructor; 59 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ShaderMaterial"); 60 if(constructor is null) return typeof(this).init; 61 return cast(ShaderMaterial)(constructor()); 62 } 63 @disable new(size_t s); 64 /** 65 66 */ 67 void setShader(Shader shader) 68 { 69 checkClassBinding!(typeof(this))(); 70 ptrcall!(void)(_classBinding.setShader, _godot_object, shader); 71 } 72 /** 73 74 */ 75 Ref!Shader getShader() const 76 { 77 checkClassBinding!(typeof(this))(); 78 return ptrcall!(Shader)(_classBinding.getShader, _godot_object); 79 } 80 /** 81 Changes the value set for this material of a uniform in the shader. 82 */ 83 void setShaderParam(StringArg0, VariantArg1)(in StringArg0 param, in VariantArg1 value) 84 { 85 checkClassBinding!(typeof(this))(); 86 ptrcall!(void)(_classBinding.setShaderParam, _godot_object, param, value); 87 } 88 /** 89 Returns the current value set for this material of a uniform in the shader. 90 */ 91 Variant getShaderParam(StringArg0)(in StringArg0 param) const 92 { 93 checkClassBinding!(typeof(this))(); 94 return ptrcall!(Variant)(_classBinding.getShaderParam, _godot_object, param); 95 } 96 /** 97 98 */ 99 void _shaderChanged() 100 { 101 Array _GODOT_args = Array.empty_array; 102 String _GODOT_method_name = String("_shader_changed"); 103 this.callv(_GODOT_method_name, _GODOT_args); 104 } 105 /** 106 107 */ 108 bool propertyCanRevert(StringArg0)(in StringArg0 name) 109 { 110 checkClassBinding!(typeof(this))(); 111 return ptrcall!(bool)(_classBinding.propertyCanRevert, _godot_object, name); 112 } 113 /** 114 115 */ 116 Variant propertyGetRevert(StringArg0)(in StringArg0 name) 117 { 118 checkClassBinding!(typeof(this))(); 119 return ptrcall!(Variant)(_classBinding.propertyGetRevert, _godot_object, name); 120 } 121 /** 122 The $(D Shader) program used to render this material. 123 */ 124 @property Shader shader() 125 { 126 return getShader(); 127 } 128 /// ditto 129 @property void shader(Shader v) 130 { 131 setShader(v); 132 } 133 }