29 #ifndef SHADER_GRAPH_H 30 #define SHADER_GRAPH_H 35 #include "scene/resources/shader.h" 40 RES_BASE_EXTENSION(
"sgp");
58 NODE_XFORM_VEC_INV_MULT,
103 SHADER_TYPE_FRAGMENT,
116 GRAPH_ERROR_MISSING_CONNECTIONS
123 enum {SLOT_DEFAULT_VALUE = 0x7FFFFFFF};
128 bool operator==(
const SourceSlot& p_slot)
const {
129 return id==p_slot.id && slot==p_slot.slot;
154 struct InOutParamInfo {
156 ShaderType shader_type;
158 const char *variable;
164 static const InOutParamInfo inout_param_info[];
166 struct NodeSlotInfo {
168 enum { MAX_INS=3, MAX_OUTS=3 };
170 const SlotType ins[MAX_INS];
171 const SlotType outs[MAX_OUTS];
174 static const NodeSlotInfo node_slot_info[];
176 bool _pending_update_shader;
177 void _update_shader();
178 void _request_update();
181 void _add_node_code(ShaderType p_type,Node *p_node,
const Vector<String>& p_inputs,
String& code);
183 Array _get_node_list(ShaderType p_type)
const;
184 Array _get_connections(ShaderType p_type)
const;
190 static void _bind_methods();
195 void node_add(ShaderType p_type, NodeType p_node_type,
int p_id);
196 void node_remove(ShaderType p_which,
int p_id);
197 void node_set_pos(ShaderType p_which,
int p_id,
const Point2& p_pos);
198 Point2 node_get_pos(ShaderType p_which,
int p_id)
const;
200 void get_node_list(ShaderType p_which,
List<int> *p_node_list)
const;
201 NodeType node_get_type(ShaderType p_which,
int p_id)
const;
203 void scalar_const_node_set_value(ShaderType p_which,
int p_id,
float p_value);
204 float scalar_const_node_get_value(ShaderType p_which,
int p_id)
const;
206 void vec_const_node_set_value(ShaderType p_which,
int p_id,
const Vector3& p_value);
207 Vector3 vec_const_node_get_value(ShaderType p_which,
int p_id)
const;
209 void rgb_const_node_set_value(ShaderType p_which,
int p_id,
const Color& p_value);
210 Color rgb_const_node_get_value(ShaderType p_which,
int p_id)
const;
212 void xform_const_node_set_value(ShaderType p_which,
int p_id,
const Transform& p_value);
213 Transform xform_const_node_get_value(ShaderType p_which,
int p_id)
const;
215 void texture_node_set_filter_size(ShaderType p_which,
int p_id,
int p_size);
216 int texture_node_get_filter_size(ShaderType p_which,
int p_id)
const;
218 void texture_node_set_filter_strength(ShaderType p_which,
float p_id,
float p_strength);
219 float texture_node_get_filter_strength(ShaderType p_which,
float p_id)
const;
221 void duplicate_nodes(ShaderType p_which,
List<int> &p_nodes);
223 List<int> generate_ids(ShaderType p_type,
int count);
238 void scalar_op_node_set_op(ShaderType p_which,
float p_id,ScalarOp p_op);
239 ScalarOp scalar_op_node_get_op(ShaderType p_which,
float p_id)
const;
254 void vec_op_node_set_op(ShaderType p_which,
float p_id,VecOp p_op);
255 VecOp vec_op_node_get_op(ShaderType p_which,
float p_id)
const;
264 void vec_scalar_op_node_set_op(ShaderType p_which,
float p_id,VecScalarOp p_op);
265 VecScalarOp vec_scalar_op_node_get_op(ShaderType p_which,
float p_id)
const;
280 void rgb_op_node_set_op(ShaderType p_which,
float p_id,RGBOp p_op);
281 RGBOp rgb_op_node_get_op(ShaderType p_which,
float p_id)
const;
283 void xform_vec_mult_node_set_no_translation(ShaderType p_which,
int p_id,
bool p_no_translation);
284 bool xform_vec_mult_node_get_no_translation(ShaderType p_which,
int p_id)
const;
305 SCALAR_FUNC_SATURATE,
310 void scalar_func_node_set_function(ShaderType p_which,
int p_id,ScalarFunc p_func);
311 ScalarFunc scalar_func_node_get_function(ShaderType p_which,
int p_id)
const;
323 void default_set_value(ShaderType p_which,
int p_id,
int p_param,
const Variant& p_value);
324 Variant default_get_value(ShaderType p_which,
int p_id,
int p_param);
326 void vec_func_node_set_function(ShaderType p_which,
int p_id,VecFunc p_func);
327 VecFunc vec_func_node_get_function(ShaderType p_which,
int p_id)
const;
330 DVector<Color> color_ramp_node_get_colors(ShaderType p_which,
int p_id)
const;
331 DVector<real_t> color_ramp_node_get_offsets(ShaderType p_which,
int p_id)
const;
333 void curve_map_node_set_points(ShaderType p_which,
int p_id,
const DVector<Vector2>& p_points);
334 DVector<Vector2> curve_map_node_get_points(ShaderType p_which,
int p_id)
const;
336 void input_node_set_name(ShaderType p_which,
int p_id,
const String& p_name);
337 String input_node_get_name(ShaderType p_which,
int p_id);
339 void scalar_input_node_set_value(ShaderType p_which,
int p_id,
float p_value);
340 float scalar_input_node_get_value(ShaderType p_which,
int p_id)
const;
342 void vec_input_node_set_value(ShaderType p_which,
int p_id,
const Vector3& p_value);
343 Vector3 vec_input_node_get_value(ShaderType p_which,
int p_id)
const;
345 void rgb_input_node_set_value(ShaderType p_which,
int p_id,
const Color& p_value);
346 Color rgb_input_node_get_value(ShaderType p_which,
int p_id)
const;
348 void xform_input_node_set_value(ShaderType p_which,
int p_id,
const Transform& p_value);
349 Transform xform_input_node_get_value(ShaderType p_which,
int p_id)
const;
351 void texture_input_node_set_value(ShaderType p_which,
int p_id,
const Ref<Texture>& p_texture);
352 Ref<Texture> texture_input_node_get_value(ShaderType p_which,
int p_id)
const;
354 void cubemap_input_node_set_value(ShaderType p_which,
int p_id,
const Ref<CubeMap>& p_cubemap);
355 Ref<CubeMap> cubemap_input_node_get_value(ShaderType p_which,
int p_id)
const;
357 void comment_node_set_text(ShaderType p_which,
int p_id,
const String& p_comment);
358 String comment_node_get_text(ShaderType p_which,
int p_id)
const;
360 Error connect_node(ShaderType p_which,
int p_src_id,
int p_src_slot,
int p_dst_id,
int p_dst_slot);
361 bool is_node_connected(ShaderType p_which,
int p_src_id,
int p_src_slot,
int p_dst_id,
int p_dst_slot)
const;
362 void disconnect_node(ShaderType p_which,
int p_src_id,
int p_src_slot,
int p_dst_id,
int p_dst_slot);
364 void get_node_connections(ShaderType p_which,
List<Connection> *p_connections)
const;
366 bool is_slot_connected(ShaderType p_which,
int p_dst_id,
int slot_id);
368 void clear(ShaderType p_which);
370 Variant node_get_state(ShaderType p_type,
int p_node)
const;
371 void node_set_state(ShaderType p_type,
int p_id,
const Variant& p_state);
373 GraphError get_graph_error(ShaderType p_type)
const;
375 int node_count(ShaderType p_which,
int p_type);
377 static int get_type_input_count(NodeType p_type);
378 static int get_type_output_count(NodeType p_type);
379 static SlotType get_type_input_type(NodeType p_type,
int p_idx);
380 static SlotType get_type_output_type(NodeType p_type,
int p_idx);
381 static bool is_type_valid(Mode p_mode,ShaderType p_type);
390 static void get_input_output_node_slot_info(Mode p_mode, ShaderType p_type,
List<SlotInfo> *r_slots);
392 static int get_node_input_slot_count(Mode p_mode, ShaderType p_shader_type,NodeType p_type);
393 static int get_node_output_slot_count(Mode p_mode, ShaderType p_shader_type,NodeType p_type);
394 static SlotType get_node_input_slot_type(Mode p_mode, ShaderType p_shader_type,NodeType p_type,
int p_idx);
395 static SlotType get_node_output_slot_type(Mode p_mode, ShaderType p_shader_type,NodeType p_type,
int p_idx);
407 VARIANT_ENUM_CAST( ShaderGraph::NodeType );
408 VARIANT_ENUM_CAST( ShaderGraph::ShaderType );
409 VARIANT_ENUM_CAST( ShaderGraph::SlotType );
410 VARIANT_ENUM_CAST( ShaderGraph::ScalarOp );
411 VARIANT_ENUM_CAST( ShaderGraph::VecOp );
412 VARIANT_ENUM_CAST( ShaderGraph::VecScalarOp );
413 VARIANT_ENUM_CAST( ShaderGraph::RGBOp );
414 VARIANT_ENUM_CAST( ShaderGraph::ScalarFunc );
415 VARIANT_ENUM_CAST( ShaderGraph::VecFunc );
416 VARIANT_ENUM_CAST( ShaderGraph::GraphError );
444 #endif // SHADER_GRAPH_H
Definition: shader_graph.h:84
Definition: shader_graph.h:431
Definition: shader_graph.h:419
Definition: dictionary.h:42
Definition: shader_graph.h:384
Definition: shader_graph.h:37