1 | /**************************************************************************/ |
2 | /* shader_types.cpp */ |
3 | /**************************************************************************/ |
4 | /* This file is part of: */ |
5 | /* GODOT ENGINE */ |
6 | /* https://godotengine.org */ |
7 | /**************************************************************************/ |
8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
10 | /* */ |
11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
12 | /* a copy of this software and associated documentation files (the */ |
13 | /* "Software"), to deal in the Software without restriction, including */ |
14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
17 | /* the following conditions: */ |
18 | /* */ |
19 | /* The above copyright notice and this permission notice shall be */ |
20 | /* included in all copies or substantial portions of the Software. */ |
21 | /* */ |
22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
29 | /**************************************************************************/ |
30 | |
31 | #include "shader_types.h" |
32 | #include "core/math/math_defs.h" |
33 | |
34 | const HashMap<StringName, ShaderLanguage::FunctionInfo> &ShaderTypes::get_functions(RS::ShaderMode p_mode) const { |
35 | return shader_modes[p_mode].functions; |
36 | } |
37 | |
38 | const Vector<ShaderLanguage::ModeInfo> &ShaderTypes::get_modes(RS::ShaderMode p_mode) const { |
39 | return shader_modes[p_mode].modes; |
40 | } |
41 | |
42 | const HashSet<String> &ShaderTypes::get_types() const { |
43 | return shader_types; |
44 | } |
45 | |
46 | const List<String> &ShaderTypes::get_types_list() const { |
47 | return shader_types_list; |
48 | } |
49 | |
50 | ShaderTypes *ShaderTypes::singleton = nullptr; |
51 | |
52 | static ShaderLanguage::BuiltInInfo constt(ShaderLanguage::DataType p_type) { |
53 | return ShaderLanguage::BuiltInInfo(p_type, true); |
54 | } |
55 | |
56 | ShaderTypes::ShaderTypes() { |
57 | singleton = this; |
58 | |
59 | /*************** SPATIAL ***********************/ |
60 | |
61 | shader_modes[RS::SHADER_SPATIAL].functions["global" ].built_ins["TIME" ] = constt(ShaderLanguage::TYPE_FLOAT); |
62 | shader_modes[RS::SHADER_SPATIAL].functions["global" ].built_ins["EXPOSURE" ] = constt(ShaderLanguage::TYPE_FLOAT); |
63 | shader_modes[RS::SHADER_SPATIAL].functions["constants" ].built_ins["PI" ] = constt(ShaderLanguage::TYPE_FLOAT); |
64 | shader_modes[RS::SHADER_SPATIAL].functions["constants" ].built_ins["TAU" ] = constt(ShaderLanguage::TYPE_FLOAT); |
65 | shader_modes[RS::SHADER_SPATIAL].functions["constants" ].built_ins["E" ] = constt(ShaderLanguage::TYPE_FLOAT); |
66 | |
67 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["VERTEX" ] = ShaderLanguage::TYPE_VEC3; |
68 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["NORMAL" ] = ShaderLanguage::TYPE_VEC3; |
69 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["TANGENT" ] = ShaderLanguage::TYPE_VEC3; |
70 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["BINORMAL" ] = ShaderLanguage::TYPE_VEC3; |
71 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["POSITION" ] = ShaderLanguage::TYPE_VEC4; |
72 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["UV" ] = ShaderLanguage::TYPE_VEC2; |
73 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["UV2" ] = ShaderLanguage::TYPE_VEC2; |
74 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["COLOR" ] = ShaderLanguage::TYPE_VEC4; |
75 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["POINT_SIZE" ] = ShaderLanguage::TYPE_FLOAT; |
76 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["INSTANCE_ID" ] = constt(ShaderLanguage::TYPE_INT); |
77 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["INSTANCE_CUSTOM" ] = constt(ShaderLanguage::TYPE_VEC4); |
78 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["VERTEX_ID" ] = constt(ShaderLanguage::TYPE_INT); |
79 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["ROUGHNESS" ] = ShaderLanguage::TYPE_FLOAT; |
80 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["BONE_INDICES" ] = ShaderLanguage::TYPE_UVEC4; |
81 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["BONE_WEIGHTS" ] = ShaderLanguage::TYPE_VEC4; |
82 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["CUSTOM0" ] = ShaderLanguage::TYPE_VEC4; |
83 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["CUSTOM1" ] = ShaderLanguage::TYPE_VEC4; |
84 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["CUSTOM2" ] = ShaderLanguage::TYPE_VEC4; |
85 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["CUSTOM3" ] = ShaderLanguage::TYPE_VEC4; |
86 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].can_discard = false; |
87 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].main_function = true; |
88 | |
89 | //builtins |
90 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["MODEL_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
91 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["MODEL_NORMAL_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT3); |
92 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["VIEW_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
93 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["INV_VIEW_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
94 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["PROJECTION_MATRIX" ] = ShaderLanguage::TYPE_MAT4; |
95 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["INV_PROJECTION_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
96 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["MODELVIEW_MATRIX" ] = ShaderLanguage::TYPE_MAT4; |
97 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["MODELVIEW_NORMAL_MATRIX" ] = ShaderLanguage::TYPE_MAT3; |
98 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["VIEWPORT_SIZE" ] = constt(ShaderLanguage::TYPE_VEC2); |
99 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["OUTPUT_IS_SRGB" ] = constt(ShaderLanguage::TYPE_BOOL); |
100 | |
101 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["NODE_POSITION_WORLD" ] = ShaderLanguage::TYPE_VEC3; |
102 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["CAMERA_POSITION_WORLD" ] = ShaderLanguage::TYPE_VEC3; |
103 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["CAMERA_DIRECTION_WORLD" ] = ShaderLanguage::TYPE_VEC3; |
104 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["CAMERA_VISIBLE_LAYERS" ] = ShaderLanguage::TYPE_UINT; |
105 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["NODE_POSITION_VIEW" ] = ShaderLanguage::TYPE_VEC3; |
106 | |
107 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["VIEW_INDEX" ] = constt(ShaderLanguage::TYPE_INT); |
108 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["VIEW_MONO_LEFT" ] = constt(ShaderLanguage::TYPE_INT); |
109 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["VIEW_RIGHT" ] = constt(ShaderLanguage::TYPE_INT); |
110 | shader_modes[RS::SHADER_SPATIAL].functions["vertex" ].built_ins["EYE_OFFSET" ] = constt(ShaderLanguage::TYPE_VEC3); |
111 | |
112 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["VERTEX" ] = constt(ShaderLanguage::TYPE_VEC3); |
113 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["FRAGCOORD" ] = constt(ShaderLanguage::TYPE_VEC4); |
114 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["FRONT_FACING" ] = constt(ShaderLanguage::TYPE_BOOL); |
115 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["NORMAL" ] = ShaderLanguage::TYPE_VEC3; |
116 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["TANGENT" ] = ShaderLanguage::TYPE_VEC3; |
117 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["BINORMAL" ] = ShaderLanguage::TYPE_VEC3; |
118 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["VIEW" ] = constt(ShaderLanguage::TYPE_VEC3); |
119 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["NORMAL_MAP" ] = ShaderLanguage::TYPE_VEC3; |
120 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["NORMAL_MAP_DEPTH" ] = ShaderLanguage::TYPE_FLOAT; |
121 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["UV" ] = constt(ShaderLanguage::TYPE_VEC2); |
122 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["UV2" ] = constt(ShaderLanguage::TYPE_VEC2); |
123 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["COLOR" ] = constt(ShaderLanguage::TYPE_VEC4); |
124 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["ALBEDO" ] = ShaderLanguage::TYPE_VEC3; |
125 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["ALPHA" ] = ShaderLanguage::TYPE_FLOAT; |
126 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["METALLIC" ] = ShaderLanguage::TYPE_FLOAT; |
127 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["SPECULAR" ] = ShaderLanguage::TYPE_FLOAT; |
128 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["ROUGHNESS" ] = ShaderLanguage::TYPE_FLOAT; |
129 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["RIM" ] = ShaderLanguage::TYPE_FLOAT; |
130 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["RIM_TINT" ] = ShaderLanguage::TYPE_FLOAT; |
131 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["CLEARCOAT" ] = ShaderLanguage::TYPE_FLOAT; |
132 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["CLEARCOAT_ROUGHNESS" ] = ShaderLanguage::TYPE_FLOAT; |
133 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["ANISOTROPY" ] = ShaderLanguage::TYPE_FLOAT; |
134 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["ANISOTROPY_FLOW" ] = ShaderLanguage::TYPE_VEC2; |
135 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["SSS_STRENGTH" ] = ShaderLanguage::TYPE_FLOAT; |
136 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["SSS_TRANSMITTANCE_COLOR" ] = ShaderLanguage::TYPE_VEC4; |
137 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["SSS_TRANSMITTANCE_DEPTH" ] = ShaderLanguage::TYPE_FLOAT; |
138 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["SSS_TRANSMITTANCE_BOOST" ] = ShaderLanguage::TYPE_FLOAT; |
139 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["BACKLIGHT" ] = ShaderLanguage::TYPE_VEC3; |
140 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["AO" ] = ShaderLanguage::TYPE_FLOAT; |
141 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["AO_LIGHT_AFFECT" ] = ShaderLanguage::TYPE_FLOAT; |
142 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["EMISSION" ] = ShaderLanguage::TYPE_VEC3; |
143 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["DEPTH" ] = ShaderLanguage::TYPE_FLOAT; |
144 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["SCREEN_UV" ] = constt(ShaderLanguage::TYPE_VEC2); |
145 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["POINT_COORD" ] = constt(ShaderLanguage::TYPE_VEC2); |
146 | |
147 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["NODE_POSITION_WORLD" ] = ShaderLanguage::TYPE_VEC3; |
148 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["CAMERA_POSITION_WORLD" ] = ShaderLanguage::TYPE_VEC3; |
149 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["CAMERA_DIRECTION_WORLD" ] = ShaderLanguage::TYPE_VEC3; |
150 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["CAMERA_VISIBLE_LAYERS" ] = ShaderLanguage::TYPE_UINT; |
151 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["NODE_POSITION_VIEW" ] = ShaderLanguage::TYPE_VEC3; |
152 | |
153 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["VIEW_INDEX" ] = constt(ShaderLanguage::TYPE_INT); |
154 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["VIEW_MONO_LEFT" ] = constt(ShaderLanguage::TYPE_INT); |
155 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["VIEW_RIGHT" ] = constt(ShaderLanguage::TYPE_INT); |
156 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["EYE_OFFSET" ] = constt(ShaderLanguage::TYPE_VEC3); |
157 | |
158 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["OUTPUT_IS_SRGB" ] = constt(ShaderLanguage::TYPE_BOOL); |
159 | |
160 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["MODEL_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
161 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["MODEL_NORMAL_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT3); |
162 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["VIEW_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
163 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["INV_VIEW_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
164 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["PROJECTION_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
165 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["INV_PROJECTION_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
166 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["VIEWPORT_SIZE" ] = constt(ShaderLanguage::TYPE_VEC2); |
167 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["FOG" ] = ShaderLanguage::TYPE_VEC4; // TODO consider adding to light shader |
168 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["RADIANCE" ] = ShaderLanguage::TYPE_VEC4; |
169 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["IRRADIANCE" ] = ShaderLanguage::TYPE_VEC4; |
170 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].can_discard = true; |
171 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].main_function = true; |
172 | |
173 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["ALPHA_SCISSOR_THRESHOLD" ] = ShaderLanguage::TYPE_FLOAT; |
174 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["ALPHA_HASH_SCALE" ] = ShaderLanguage::TYPE_FLOAT; |
175 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["ALPHA_ANTIALIASING_EDGE" ] = ShaderLanguage::TYPE_FLOAT; |
176 | shader_modes[RS::SHADER_SPATIAL].functions["fragment" ].built_ins["ALPHA_TEXTURE_COORDINATE" ] = ShaderLanguage::TYPE_VEC2; |
177 | |
178 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["MODEL_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
179 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["VIEW_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
180 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["INV_VIEW_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
181 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["PROJECTION_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
182 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["INV_PROJECTION_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
183 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["VIEWPORT_SIZE" ] = constt(ShaderLanguage::TYPE_VEC2); |
184 | |
185 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["FRAGCOORD" ] = constt(ShaderLanguage::TYPE_VEC4); |
186 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["NORMAL" ] = constt(ShaderLanguage::TYPE_VEC3); |
187 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["UV" ] = constt(ShaderLanguage::TYPE_VEC2); |
188 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["UV2" ] = constt(ShaderLanguage::TYPE_VEC2); |
189 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["VIEW" ] = constt(ShaderLanguage::TYPE_VEC3); |
190 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["SPECULAR_AMOUNT" ] = constt(ShaderLanguage::TYPE_FLOAT); |
191 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["LIGHT" ] = constt(ShaderLanguage::TYPE_VEC3); |
192 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["LIGHT_COLOR" ] = constt(ShaderLanguage::TYPE_VEC3); |
193 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["LIGHT_IS_DIRECTIONAL" ] = constt(ShaderLanguage::TYPE_BOOL); |
194 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["ATTENUATION" ] = constt(ShaderLanguage::TYPE_FLOAT); |
195 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["ALBEDO" ] = constt(ShaderLanguage::TYPE_VEC3); |
196 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["BACKLIGHT" ] = constt(ShaderLanguage::TYPE_VEC3); |
197 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["METALLIC" ] = constt(ShaderLanguage::TYPE_FLOAT); |
198 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["ROUGHNESS" ] = constt(ShaderLanguage::TYPE_FLOAT); |
199 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["DIFFUSE_LIGHT" ] = ShaderLanguage::TYPE_VEC3; |
200 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["SPECULAR_LIGHT" ] = ShaderLanguage::TYPE_VEC3; |
201 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["OUTPUT_IS_SRGB" ] = constt(ShaderLanguage::TYPE_BOOL); |
202 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].built_ins["ALPHA" ] = ShaderLanguage::TYPE_FLOAT; |
203 | |
204 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].can_discard = true; |
205 | shader_modes[RS::SHADER_SPATIAL].functions["light" ].main_function = true; |
206 | |
207 | // spatial render modes |
208 | { |
209 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("blend" ), "mix" , "add" , "sub" , "mul" }); |
210 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_draw" ), "opaque" , "always" , "never" }); |
211 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_prepass_alpha" ) }); |
212 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_test_disabled" ) }); |
213 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("sss_mode_skin" ) }); |
214 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("cull" ), "back" , "front" , "disabled" }); |
215 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("unshaded" ) }); |
216 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("wireframe" ) }); |
217 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("diffuse" ), "lambert" , "lambert_wrap" , "burley" , "toon" }); |
218 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("specular" ), "schlick_ggx" , "toon" , "disabled" }); |
219 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("skip_vertex_transform" ) }); |
220 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("world_vertex_coords" ) }); |
221 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("ensure_correct_normals" ) }); |
222 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("shadows_disabled" ) }); |
223 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("ambient_light_disabled" ) }); |
224 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("shadow_to_opacity" ) }); |
225 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("vertex_lighting" ) }); |
226 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("particle_trails" ) }); |
227 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("alpha_to_coverage" ) }); |
228 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("alpha_to_coverage_and_one" ) }); |
229 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("debug_shadow_splits" ) }); |
230 | shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("fog_disabled" ) }); |
231 | } |
232 | |
233 | /************ CANVAS ITEM **************************/ |
234 | |
235 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["global" ].built_ins["TIME" ] = constt(ShaderLanguage::TYPE_FLOAT); |
236 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["constants" ].built_ins["PI" ] = constt(ShaderLanguage::TYPE_FLOAT); |
237 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["constants" ].built_ins["TAU" ] = constt(ShaderLanguage::TYPE_FLOAT); |
238 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["constants" ].built_ins["E" ] = constt(ShaderLanguage::TYPE_FLOAT); |
239 | |
240 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].built_ins["VERTEX" ] = ShaderLanguage::TYPE_VEC2; |
241 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].built_ins["UV" ] = ShaderLanguage::TYPE_VEC2; |
242 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].built_ins["COLOR" ] = ShaderLanguage::TYPE_VEC4; |
243 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].built_ins["POINT_SIZE" ] = ShaderLanguage::TYPE_FLOAT; |
244 | |
245 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].built_ins["MODEL_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
246 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].built_ins["CANVAS_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
247 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].built_ins["SCREEN_MATRIX" ] = constt(ShaderLanguage::TYPE_MAT4); |
248 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].built_ins["INSTANCE_CUSTOM" ] = constt(ShaderLanguage::TYPE_VEC4); |
249 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].built_ins["INSTANCE_ID" ] = constt(ShaderLanguage::TYPE_INT); |
250 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].built_ins["VERTEX_ID" ] = constt(ShaderLanguage::TYPE_INT); |
251 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].built_ins["AT_LIGHT_PASS" ] = constt(ShaderLanguage::TYPE_BOOL); |
252 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].built_ins["TEXTURE_PIXEL_SIZE" ] = constt(ShaderLanguage::TYPE_VEC2); |
253 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].can_discard = false; |
254 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex" ].main_function = true; |
255 | |
256 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["VERTEX" ] = ShaderLanguage::TYPE_VEC2; |
257 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["SHADOW_VERTEX" ] = ShaderLanguage::TYPE_VEC2; |
258 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["LIGHT_VERTEX" ] = ShaderLanguage::TYPE_VEC3; |
259 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["FRAGCOORD" ] = constt(ShaderLanguage::TYPE_VEC4); |
260 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["NORMAL" ] = ShaderLanguage::TYPE_VEC3; |
261 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["NORMAL_MAP" ] = ShaderLanguage::TYPE_VEC3; |
262 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["NORMAL_MAP_DEPTH" ] = ShaderLanguage::TYPE_FLOAT; |
263 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["UV" ] = constt(ShaderLanguage::TYPE_VEC2); |
264 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["COLOR" ] = ShaderLanguage::TYPE_VEC4; |
265 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["TEXTURE" ] = constt(ShaderLanguage::TYPE_SAMPLER2D); |
266 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["TEXTURE_PIXEL_SIZE" ] = constt(ShaderLanguage::TYPE_VEC2); |
267 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["NORMAL_TEXTURE" ] = constt(ShaderLanguage::TYPE_SAMPLER2D); |
268 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["SPECULAR_SHININESS_TEXTURE" ] = constt(ShaderLanguage::TYPE_SAMPLER2D); |
269 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["SPECULAR_SHININESS" ] = constt(ShaderLanguage::TYPE_VEC4); |
270 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["SCREEN_UV" ] = constt(ShaderLanguage::TYPE_VEC2); |
271 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["SCREEN_PIXEL_SIZE" ] = constt(ShaderLanguage::TYPE_VEC2); |
272 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["POINT_COORD" ] = constt(ShaderLanguage::TYPE_VEC2); |
273 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].built_ins["AT_LIGHT_PASS" ] = constt(ShaderLanguage::TYPE_BOOL); |
274 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].can_discard = true; |
275 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].main_function = true; |
276 | |
277 | { |
278 | ShaderLanguage::StageFunctionInfo func; |
279 | func.arguments.push_back(ShaderLanguage::StageFunctionInfo::Argument("sdf_pos" , ShaderLanguage::TYPE_VEC2)); |
280 | func.return_type = ShaderLanguage::TYPE_FLOAT; //whether it could emit |
281 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].stage_functions["texture_sdf" ] = func; |
282 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].stage_functions["texture_sdf" ] = func; |
283 | func.return_type = ShaderLanguage::TYPE_VEC2; //whether it could emit |
284 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].stage_functions["sdf_to_screen_uv" ] = func; |
285 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].stage_functions["sdf_to_screen_uv" ] = func; |
286 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].stage_functions["texture_sdf_normal" ] = func; |
287 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].stage_functions["texture_sdf_normal" ] = func; |
288 | } |
289 | |
290 | { |
291 | ShaderLanguage::StageFunctionInfo func; |
292 | func.arguments.push_back(ShaderLanguage::StageFunctionInfo::Argument("uv" , ShaderLanguage::TYPE_VEC2)); |
293 | func.return_type = ShaderLanguage::TYPE_VEC2; //whether it could emit |
294 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment" ].stage_functions["screen_uv_to_sdf" ] = func; |
295 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].stage_functions["screen_uv_to_sdf" ] = func; |
296 | } |
297 | |
298 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["FRAGCOORD" ] = constt(ShaderLanguage::TYPE_VEC4); |
299 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["NORMAL" ] = constt(ShaderLanguage::TYPE_VEC3); |
300 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["COLOR" ] = constt(ShaderLanguage::TYPE_VEC4); |
301 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["UV" ] = constt(ShaderLanguage::TYPE_VEC2); |
302 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["SPECULAR_SHININESS" ] = constt(ShaderLanguage::TYPE_VEC4); |
303 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["LIGHT_COLOR" ] = constt(ShaderLanguage::TYPE_VEC4); |
304 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["LIGHT_POSITION" ] = constt(ShaderLanguage::TYPE_VEC3); |
305 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["LIGHT_DIRECTION" ] = constt(ShaderLanguage::TYPE_VEC3); |
306 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["LIGHT_ENERGY" ] = constt(ShaderLanguage::TYPE_FLOAT); |
307 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["LIGHT_IS_DIRECTIONAL" ] = constt(ShaderLanguage::TYPE_BOOL); |
308 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["LIGHT_VERTEX" ] = constt(ShaderLanguage::TYPE_VEC3); |
309 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["LIGHT" ] = ShaderLanguage::TYPE_VEC4; |
310 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["SHADOW_MODULATE" ] = ShaderLanguage::TYPE_VEC4; |
311 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["SCREEN_UV" ] = constt(ShaderLanguage::TYPE_VEC2); |
312 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["TEXTURE" ] = constt(ShaderLanguage::TYPE_SAMPLER2D); |
313 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["TEXTURE_PIXEL_SIZE" ] = constt(ShaderLanguage::TYPE_VEC2); |
314 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].built_ins["POINT_COORD" ] = constt(ShaderLanguage::TYPE_VEC2); |
315 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].can_discard = true; |
316 | shader_modes[RS::SHADER_CANVAS_ITEM].functions["light" ].main_function = true; |
317 | |
318 | // canvasitem render modes |
319 | { |
320 | shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back({ PNAME("skip_vertex_transform" ) }); |
321 | shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back({ PNAME("blend" ), "mix" , "add" , "sub" , "mul" , "premul_alpha" , "disabled" }); |
322 | shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back({ PNAME("unshaded" ) }); |
323 | shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back({ PNAME("light_only" ) }); |
324 | } |
325 | |
326 | /************ PARTICLES **************************/ |
327 | |
328 | shader_modes[RS::SHADER_PARTICLES].functions["global" ].built_ins["TIME" ] = constt(ShaderLanguage::TYPE_FLOAT); |
329 | shader_modes[RS::SHADER_PARTICLES].functions["constants" ].built_ins["PI" ] = constt(ShaderLanguage::TYPE_FLOAT); |
330 | shader_modes[RS::SHADER_PARTICLES].functions["constants" ].built_ins["TAU" ] = constt(ShaderLanguage::TYPE_FLOAT); |
331 | shader_modes[RS::SHADER_PARTICLES].functions["constants" ].built_ins["E" ] = constt(ShaderLanguage::TYPE_FLOAT); |
332 | |
333 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["COLOR" ] = ShaderLanguage::TYPE_VEC4; |
334 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["VELOCITY" ] = ShaderLanguage::TYPE_VEC3; |
335 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["MASS" ] = ShaderLanguage::TYPE_FLOAT; |
336 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["ACTIVE" ] = ShaderLanguage::TYPE_BOOL; |
337 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["CUSTOM" ] = ShaderLanguage::TYPE_VEC4; |
338 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["USERDATA1" ] = ShaderLanguage::TYPE_VEC4; |
339 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["USERDATA2" ] = ShaderLanguage::TYPE_VEC4; |
340 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["USERDATA3" ] = ShaderLanguage::TYPE_VEC4; |
341 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["USERDATA4" ] = ShaderLanguage::TYPE_VEC4; |
342 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["USERDATA5" ] = ShaderLanguage::TYPE_VEC4; |
343 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["USERDATA6" ] = ShaderLanguage::TYPE_VEC4; |
344 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["TRANSFORM" ] = ShaderLanguage::TYPE_MAT4; |
345 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["LIFETIME" ] = constt(ShaderLanguage::TYPE_FLOAT); |
346 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["DELTA" ] = constt(ShaderLanguage::TYPE_FLOAT); |
347 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["NUMBER" ] = constt(ShaderLanguage::TYPE_UINT); |
348 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["INDEX" ] = constt(ShaderLanguage::TYPE_UINT); |
349 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["EMISSION_TRANSFORM" ] = constt(ShaderLanguage::TYPE_MAT4); |
350 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["RANDOM_SEED" ] = constt(ShaderLanguage::TYPE_UINT); |
351 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["FLAG_EMIT_POSITION" ] = constt(ShaderLanguage::TYPE_UINT); |
352 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["FLAG_EMIT_ROT_SCALE" ] = constt(ShaderLanguage::TYPE_UINT); |
353 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["FLAG_EMIT_VELOCITY" ] = constt(ShaderLanguage::TYPE_UINT); |
354 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["FLAG_EMIT_COLOR" ] = constt(ShaderLanguage::TYPE_UINT); |
355 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["FLAG_EMIT_CUSTOM" ] = constt(ShaderLanguage::TYPE_UINT); |
356 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["RESTART_POSITION" ] = constt(ShaderLanguage::TYPE_BOOL); |
357 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["RESTART_ROT_SCALE" ] = constt(ShaderLanguage::TYPE_BOOL); |
358 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["RESTART_VELOCITY" ] = constt(ShaderLanguage::TYPE_BOOL); |
359 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["RESTART_COLOR" ] = constt(ShaderLanguage::TYPE_BOOL); |
360 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].built_ins["RESTART_CUSTOM" ] = constt(ShaderLanguage::TYPE_BOOL); |
361 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].main_function = true; |
362 | |
363 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["COLOR" ] = ShaderLanguage::TYPE_VEC4; |
364 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["VELOCITY" ] = ShaderLanguage::TYPE_VEC3; |
365 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["MASS" ] = ShaderLanguage::TYPE_FLOAT; |
366 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["ACTIVE" ] = ShaderLanguage::TYPE_BOOL; |
367 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["RESTART" ] = constt(ShaderLanguage::TYPE_BOOL); |
368 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["CUSTOM" ] = ShaderLanguage::TYPE_VEC4; |
369 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["USERDATA1" ] = ShaderLanguage::TYPE_VEC4; |
370 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["USERDATA2" ] = ShaderLanguage::TYPE_VEC4; |
371 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["USERDATA3" ] = ShaderLanguage::TYPE_VEC4; |
372 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["USERDATA4" ] = ShaderLanguage::TYPE_VEC4; |
373 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["USERDATA5" ] = ShaderLanguage::TYPE_VEC4; |
374 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["USERDATA6" ] = ShaderLanguage::TYPE_VEC4; |
375 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["TRANSFORM" ] = ShaderLanguage::TYPE_MAT4; |
376 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["LIFETIME" ] = constt(ShaderLanguage::TYPE_FLOAT); |
377 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["DELTA" ] = constt(ShaderLanguage::TYPE_FLOAT); |
378 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["NUMBER" ] = constt(ShaderLanguage::TYPE_UINT); |
379 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["INDEX" ] = constt(ShaderLanguage::TYPE_UINT); |
380 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["EMISSION_TRANSFORM" ] = constt(ShaderLanguage::TYPE_MAT4); |
381 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["RANDOM_SEED" ] = constt(ShaderLanguage::TYPE_UINT); |
382 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["FLAG_EMIT_POSITION" ] = constt(ShaderLanguage::TYPE_UINT); |
383 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["FLAG_EMIT_ROT_SCALE" ] = constt(ShaderLanguage::TYPE_UINT); |
384 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["FLAG_EMIT_VELOCITY" ] = constt(ShaderLanguage::TYPE_UINT); |
385 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["FLAG_EMIT_COLOR" ] = constt(ShaderLanguage::TYPE_UINT); |
386 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["FLAG_EMIT_CUSTOM" ] = constt(ShaderLanguage::TYPE_UINT); |
387 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["COLLIDED" ] = constt(ShaderLanguage::TYPE_BOOL); |
388 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["COLLISION_NORMAL" ] = constt(ShaderLanguage::TYPE_VEC3); |
389 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["COLLISION_DEPTH" ] = constt(ShaderLanguage::TYPE_FLOAT); |
390 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].built_ins["ATTRACTOR_FORCE" ] = constt(ShaderLanguage::TYPE_VEC3); |
391 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].main_function = true; |
392 | |
393 | { |
394 | ShaderLanguage::StageFunctionInfo emit_vertex_func; |
395 | emit_vertex_func.arguments.push_back(ShaderLanguage::StageFunctionInfo::Argument("xform" , ShaderLanguage::TYPE_MAT4)); |
396 | emit_vertex_func.arguments.push_back(ShaderLanguage::StageFunctionInfo::Argument("velocity" , ShaderLanguage::TYPE_VEC3)); |
397 | emit_vertex_func.arguments.push_back(ShaderLanguage::StageFunctionInfo::Argument("color" , ShaderLanguage::TYPE_VEC4)); |
398 | emit_vertex_func.arguments.push_back(ShaderLanguage::StageFunctionInfo::Argument("custom" , ShaderLanguage::TYPE_VEC4)); |
399 | emit_vertex_func.arguments.push_back(ShaderLanguage::StageFunctionInfo::Argument("flags" , ShaderLanguage::TYPE_UINT)); |
400 | emit_vertex_func.return_type = ShaderLanguage::TYPE_BOOL; //whether it could emit |
401 | shader_modes[RS::SHADER_PARTICLES].functions["start" ].stage_functions["emit_subparticle" ] = emit_vertex_func; |
402 | shader_modes[RS::SHADER_PARTICLES].functions["process" ].stage_functions["emit_subparticle" ] = emit_vertex_func; |
403 | } |
404 | |
405 | // particles render modes |
406 | { |
407 | shader_modes[RS::SHADER_PARTICLES].modes.push_back({ PNAME("collision_use_scale" ) }); |
408 | shader_modes[RS::SHADER_PARTICLES].modes.push_back({ PNAME("disable_force" ) }); |
409 | shader_modes[RS::SHADER_PARTICLES].modes.push_back({ PNAME("disable_velocity" ) }); |
410 | shader_modes[RS::SHADER_PARTICLES].modes.push_back({ PNAME("keep_data" ) }); |
411 | } |
412 | |
413 | /************ SKY **************************/ |
414 | |
415 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["TIME" ] = constt(ShaderLanguage::TYPE_FLOAT); |
416 | shader_modes[RS::SHADER_SKY].functions["constants" ].built_ins["PI" ] = constt(ShaderLanguage::TYPE_FLOAT); |
417 | shader_modes[RS::SHADER_SKY].functions["constants" ].built_ins["TAU" ] = constt(ShaderLanguage::TYPE_FLOAT); |
418 | shader_modes[RS::SHADER_SKY].functions["constants" ].built_ins["E" ] = constt(ShaderLanguage::TYPE_FLOAT); |
419 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["POSITION" ] = constt(ShaderLanguage::TYPE_VEC3); |
420 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["RADIANCE" ] = constt(ShaderLanguage::TYPE_SAMPLERCUBE); |
421 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["AT_HALF_RES_PASS" ] = constt(ShaderLanguage::TYPE_BOOL); |
422 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["AT_QUARTER_RES_PASS" ] = constt(ShaderLanguage::TYPE_BOOL); |
423 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["AT_CUBEMAP_PASS" ] = constt(ShaderLanguage::TYPE_BOOL); |
424 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT0_ENABLED" ] = constt(ShaderLanguage::TYPE_BOOL); |
425 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT0_DIRECTION" ] = constt(ShaderLanguage::TYPE_VEC3); |
426 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT0_ENERGY" ] = constt(ShaderLanguage::TYPE_FLOAT); |
427 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT0_COLOR" ] = constt(ShaderLanguage::TYPE_VEC3); |
428 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT0_SIZE" ] = constt(ShaderLanguage::TYPE_FLOAT); |
429 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT1_ENABLED" ] = constt(ShaderLanguage::TYPE_BOOL); |
430 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT1_DIRECTION" ] = constt(ShaderLanguage::TYPE_VEC3); |
431 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT1_ENERGY" ] = constt(ShaderLanguage::TYPE_FLOAT); |
432 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT1_COLOR" ] = constt(ShaderLanguage::TYPE_VEC3); |
433 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT1_SIZE" ] = constt(ShaderLanguage::TYPE_FLOAT); |
434 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT2_ENABLED" ] = constt(ShaderLanguage::TYPE_BOOL); |
435 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT2_DIRECTION" ] = constt(ShaderLanguage::TYPE_VEC3); |
436 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT2_ENERGY" ] = constt(ShaderLanguage::TYPE_FLOAT); |
437 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT2_COLOR" ] = constt(ShaderLanguage::TYPE_VEC3); |
438 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT2_SIZE" ] = constt(ShaderLanguage::TYPE_FLOAT); |
439 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT3_ENABLED" ] = constt(ShaderLanguage::TYPE_BOOL); |
440 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT3_DIRECTION" ] = constt(ShaderLanguage::TYPE_VEC3); |
441 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT3_ENERGY" ] = constt(ShaderLanguage::TYPE_FLOAT); |
442 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT3_COLOR" ] = constt(ShaderLanguage::TYPE_VEC3); |
443 | shader_modes[RS::SHADER_SKY].functions["global" ].built_ins["LIGHT3_SIZE" ] = constt(ShaderLanguage::TYPE_FLOAT); |
444 | |
445 | shader_modes[RS::SHADER_SKY].functions["sky" ].built_ins["COLOR" ] = ShaderLanguage::TYPE_VEC3; |
446 | shader_modes[RS::SHADER_SKY].functions["sky" ].built_ins["ALPHA" ] = ShaderLanguage::TYPE_FLOAT; |
447 | shader_modes[RS::SHADER_SKY].functions["sky" ].built_ins["EYEDIR" ] = constt(ShaderLanguage::TYPE_VEC3); |
448 | shader_modes[RS::SHADER_SKY].functions["sky" ].built_ins["SCREEN_UV" ] = constt(ShaderLanguage::TYPE_VEC2); |
449 | shader_modes[RS::SHADER_SKY].functions["sky" ].built_ins["FRAGCOORD" ] = constt(ShaderLanguage::TYPE_VEC4); |
450 | shader_modes[RS::SHADER_SKY].functions["sky" ].built_ins["SKY_COORDS" ] = constt(ShaderLanguage::TYPE_VEC2); |
451 | shader_modes[RS::SHADER_SKY].functions["sky" ].built_ins["HALF_RES_COLOR" ] = constt(ShaderLanguage::TYPE_VEC4); |
452 | shader_modes[RS::SHADER_SKY].functions["sky" ].built_ins["QUARTER_RES_COLOR" ] = constt(ShaderLanguage::TYPE_VEC4); |
453 | shader_modes[RS::SHADER_SKY].functions["sky" ].built_ins["FOG" ] = ShaderLanguage::TYPE_VEC4; |
454 | shader_modes[RS::SHADER_SKY].functions["sky" ].main_function = true; |
455 | |
456 | // sky render modes |
457 | { |
458 | shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("use_half_res_pass" ) }); |
459 | shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("use_quarter_res_pass" ) }); |
460 | shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("disable_fog" ) }); |
461 | shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("use_debanding" ) }); |
462 | } |
463 | |
464 | /************ FOG **************************/ |
465 | |
466 | shader_modes[RS::SHADER_FOG].functions["global" ].built_ins["TIME" ] = constt(ShaderLanguage::TYPE_FLOAT); |
467 | shader_modes[RS::SHADER_FOG].functions["constants" ].built_ins["PI" ] = constt(ShaderLanguage::TYPE_FLOAT); |
468 | shader_modes[RS::SHADER_FOG].functions["constants" ].built_ins["TAU" ] = constt(ShaderLanguage::TYPE_FLOAT); |
469 | shader_modes[RS::SHADER_FOG].functions["constants" ].built_ins["E" ] = constt(ShaderLanguage::TYPE_FLOAT); |
470 | |
471 | shader_modes[RS::SHADER_FOG].functions["fog" ].built_ins["WORLD_POSITION" ] = constt(ShaderLanguage::TYPE_VEC3); |
472 | shader_modes[RS::SHADER_FOG].functions["fog" ].built_ins["OBJECT_POSITION" ] = constt(ShaderLanguage::TYPE_VEC3); |
473 | shader_modes[RS::SHADER_FOG].functions["fog" ].built_ins["UVW" ] = constt(ShaderLanguage::TYPE_VEC3); |
474 | shader_modes[RS::SHADER_FOG].functions["fog" ].built_ins["SIZE" ] = constt(ShaderLanguage::TYPE_VEC3); |
475 | shader_modes[RS::SHADER_FOG].functions["fog" ].built_ins["SDF" ] = constt(ShaderLanguage::TYPE_FLOAT); |
476 | shader_modes[RS::SHADER_FOG].functions["fog" ].built_ins["ALBEDO" ] = ShaderLanguage::TYPE_VEC3; |
477 | shader_modes[RS::SHADER_FOG].functions["fog" ].built_ins["DENSITY" ] = ShaderLanguage::TYPE_FLOAT; |
478 | shader_modes[RS::SHADER_FOG].functions["fog" ].built_ins["EMISSION" ] = ShaderLanguage::TYPE_VEC3; |
479 | shader_modes[RS::SHADER_FOG].functions["fog" ].main_function = true; |
480 | |
481 | shader_types_list.push_back("spatial" ); |
482 | shader_types_list.push_back("canvas_item" ); |
483 | shader_types_list.push_back("particles" ); |
484 | shader_types_list.push_back("sky" ); |
485 | shader_types_list.push_back("fog" ); |
486 | |
487 | for (int i = 0; i < shader_types_list.size(); i++) { |
488 | shader_types.insert(shader_types_list[i]); |
489 | } |
490 | } |
491 | |