Skip to content
0.2.0-dev Download ZIP
136 lines ·7.0 KB Raw
1/**************************************************************************/
2/* visual_shader_sdf_nodes.h */
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#pragma once
32
33#include "../visual_shader.h"
34
35class VisualShaderNodeSDFToScreenUV : public VisualShaderNode {
36 GDCLASS(VisualShaderNodeSDFToScreenUV, VisualShaderNode);
37
38public:
39 virtual String get_caption() const override;
40
41 virtual int get_input_port_count() const override;
42 virtual PortType get_input_port_type(int p_port) const override;
43 virtual String get_input_port_name(int p_port) const override;
44
45 virtual int get_output_port_count() const override;
46 virtual PortType get_output_port_type(int p_port) const override;
47 virtual String get_output_port_name(int p_port) const override;
48
49 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
50
51 virtual Category get_category() const override { return CATEGORY_TEXTURES; }
52 virtual bool is_available(Shader::Mode p_mode, VisualShader::Type p_type) const override { return p_mode == Shader::MODE_CANVAS_ITEM; }
53};
54
55class VisualShaderNodeScreenUVToSDF : public VisualShaderNode {
56 GDCLASS(VisualShaderNodeScreenUVToSDF, VisualShaderNode);
57
58public:
59 virtual String get_caption() const override;
60
61 virtual int get_input_port_count() const override;
62 virtual PortType get_input_port_type(int p_port) const override;
63 virtual String get_input_port_name(int p_port) const override;
64
65 virtual int get_output_port_count() const override;
66 virtual PortType get_output_port_type(int p_port) const override;
67 virtual String get_output_port_name(int p_port) const override;
68
69 virtual bool is_input_port_default(int p_port, Shader::Mode p_mode) const override;
70 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
71
72 virtual Category get_category() const override { return CATEGORY_TEXTURES; }
73 virtual bool is_available(Shader::Mode p_mode, VisualShader::Type p_type) const override { return p_mode == Shader::MODE_CANVAS_ITEM; }
74};
75
76class VisualShaderNodeTextureSDF : public VisualShaderNode {
77 GDCLASS(VisualShaderNodeTextureSDF, VisualShaderNode);
78
79public:
80 virtual String get_caption() const override;
81
82 virtual int get_input_port_count() const override;
83 virtual PortType get_input_port_type(int p_port) const override;
84 virtual String get_input_port_name(int p_port) const override;
85
86 virtual int get_output_port_count() const override;
87 virtual PortType get_output_port_type(int p_port) const override;
88 virtual String get_output_port_name(int p_port) const override;
89
90 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
91
92 virtual Category get_category() const override { return CATEGORY_TEXTURES; }
93 virtual bool is_available(Shader::Mode p_mode, VisualShader::Type p_type) const override { return p_mode == Shader::MODE_CANVAS_ITEM; }
94};
95
96class VisualShaderNodeTextureSDFNormal : public VisualShaderNode {
97 GDCLASS(VisualShaderNodeTextureSDFNormal, VisualShaderNode);
98
99public:
100 virtual String get_caption() const override;
101
102 virtual int get_input_port_count() const override;
103 virtual PortType get_input_port_type(int p_port) const override;
104 virtual String get_input_port_name(int p_port) const override;
105
106 virtual int get_output_port_count() const override;
107 virtual PortType get_output_port_type(int p_port) const override;
108 virtual String get_output_port_name(int p_port) const override;
109
110 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
111
112 virtual Category get_category() const override { return CATEGORY_TEXTURES; }
113 virtual bool is_available(Shader::Mode p_mode, VisualShader::Type p_type) const override { return p_mode == Shader::MODE_CANVAS_ITEM; }
114};
115
116class VisualShaderNodeSDFRaymarch : public VisualShaderNode {
117 GDCLASS(VisualShaderNodeSDFRaymarch, VisualShaderNode);
118
119public:
120 virtual String get_caption() const override;
121
122 virtual int get_input_port_count() const override;
123 virtual PortType get_input_port_type(int p_port) const override;
124 virtual String get_input_port_name(int p_port) const override;
125
126 virtual int get_output_port_count() const override;
127 virtual PortType get_output_port_type(int p_port) const override;
128 virtual String get_output_port_name(int p_port) const override;
129
130 virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
131
132 virtual Category get_category() const override { return CATEGORY_TEXTURES; }
133 virtual bool is_available(Shader::Mode p_mode, VisualShader::Type p_type) const override { return p_mode == Shader::MODE_CANVAS_ITEM; }
134
135 VisualShaderNodeSDFRaymarch();
136};