diff --git a/addons/ShaderLib/Artistic/Adjustment/Contrast.gd b/addons/ShaderLib/Artistic/Adjustment/Contrast.gd
index 3cbdd34..1062590 100644
--- a/addons/ShaderLib/Artistic/Adjustment/Contrast.gd
+++ b/addons/ShaderLib/Artistic/Adjustment/Contrast.gd
@@ -47,8 +47,7 @@ func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("Contrast.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var input: String = "vec3(1.0)"
diff --git a/addons/ShaderLib/Artistic/Adjustment/Contrast.gdshaderinc b/addons/ShaderLib/Artistic/Adjustment/Contrast.gdshaderinc
deleted file mode 100644
index 9559991..0000000
--- a/addons/ShaderLib/Artistic/Adjustment/Contrast.gdshaderinc
+++ /dev/null
@@ -1,4 +0,0 @@
-vec3 contrast(vec3 input, float contrast){
- float midpoint = pow(0.5, 2.2);
- return (input - midpoint) * contrast + midpoint;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Artistic/Adjustment/Hue.gd b/addons/ShaderLib/Artistic/Adjustment/Hue.gd
index 9f29fd5..ba87b4a 100644
--- a/addons/ShaderLib/Artistic/Adjustment/Hue.gd
+++ b/addons/ShaderLib/Artistic/Adjustment/Hue.gd
@@ -59,8 +59,7 @@ func _get_property_options(index: int) -> PackedStringArray:
return ["Degrees", "Normalize"]
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("Hue.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var range_index: int = get_option_index(0)
diff --git a/addons/ShaderLib/Artistic/Adjustment/Hue.gdshaderinc b/addons/ShaderLib/Artistic/Adjustment/Hue.gdshaderinc
deleted file mode 100644
index 9919c9b..0000000
--- a/addons/ShaderLib/Artistic/Adjustment/Hue.gdshaderinc
+++ /dev/null
@@ -1,27 +0,0 @@
-vec3 hue(vec3 input, float offset, int range_index){
- // RGB to HSV
- vec4 k = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
- vec4 p = mix(vec4(input.bg, k.wz), vec4(input.gb, k.xy), step(input.b, input.g));
- vec4 q = mix(vec4(p.xyw, input.r), vec4(input.r, p.yzx), step(p.x, input.r));
- float d = q.x - min(q.w, q.y);
- float e = 1.0e-10;
- vec3 hsv = vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
-
- offset = (range_index == 0) ? offset / 360.0 : offset;
- float hue = hsv.x + offset;
- if(hue < 0.0){
- hsv.x = hue + 1.;
- }
- else if(hue > 1.){
- hsv.x = hue - 1.;
- }
- else{
- hsv.x = hue;
- }
-
- // HSV to RGB
- vec4 k2 = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
- vec3 p2 = abs(fract(hsv.xxx + k2.xyz) * 6.0 - k2.www);
- vec3 rgb = hsv.z * mix(k2.xxx, clamp(p2 - k2.xxx, 0.0, 1.0), hsv.y);
- return rgb;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Artistic/Adjustment/ReplaceColor.gd b/addons/ShaderLib/Artistic/Adjustment/ReplaceColor.gd
index 8a64cd8..a0f6246 100644
--- a/addons/ShaderLib/Artistic/Adjustment/ReplaceColor.gd
+++ b/addons/ShaderLib/Artistic/Adjustment/ReplaceColor.gd
@@ -55,8 +55,7 @@ func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("ReplaceColor.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var input: String = "vec3(1.0)"
diff --git a/addons/ShaderLib/Artistic/Adjustment/ReplaceColor.gdshaderinc b/addons/ShaderLib/Artistic/Adjustment/ReplaceColor.gdshaderinc
deleted file mode 100644
index 2797299..0000000
--- a/addons/ShaderLib/Artistic/Adjustment/ReplaceColor.gdshaderinc
+++ /dev/null
@@ -1,4 +0,0 @@
-vec3 replace_color(vec3 input, vec3 from, vec3 to, float range, float fuzziness){
- float dist = distance(from, input);
- return mix(to, input, clamp((dist - range) / max(fuzziness, 1.0e-5), 0.0, 1.0));
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Artistic/Adjustment/Saturation.gd b/addons/ShaderLib/Artistic/Adjustment/Saturation.gd
index d295558..186896c 100644
--- a/addons/ShaderLib/Artistic/Adjustment/Saturation.gd
+++ b/addons/ShaderLib/Artistic/Adjustment/Saturation.gd
@@ -48,8 +48,7 @@ func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("Saturation.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var input: String = "vec3(1.0)"
diff --git a/addons/ShaderLib/Artistic/Adjustment/Saturation.gdshaderinc b/addons/ShaderLib/Artistic/Adjustment/Saturation.gdshaderinc
deleted file mode 100644
index f3f958b..0000000
--- a/addons/ShaderLib/Artistic/Adjustment/Saturation.gdshaderinc
+++ /dev/null
@@ -1,4 +0,0 @@
-vec3 saturation(vec3 input, float saturation){
- float luma = dot(input, vec3(0.2126729, 0.7151522, 0.0721750));
- return luma + saturation * (input - vec3(luma));
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Artistic/Adjustment/WhiteBalance.gd b/addons/ShaderLib/Artistic/Adjustment/WhiteBalance.gd
index f5a31e7..6415eac 100644
--- a/addons/ShaderLib/Artistic/Adjustment/WhiteBalance.gd
+++ b/addons/ShaderLib/Artistic/Adjustment/WhiteBalance.gd
@@ -49,8 +49,7 @@ func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("WhiteBalance.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var input: String = "vec3(1.0)"
diff --git a/addons/ShaderLib/Artistic/Adjustment/WhiteBalance.gdshaderinc b/addons/ShaderLib/Artistic/Adjustment/WhiteBalance.gdshaderinc
deleted file mode 100644
index 727e73a..0000000
--- a/addons/ShaderLib/Artistic/Adjustment/WhiteBalance.gdshaderinc
+++ /dev/null
@@ -1,36 +0,0 @@
-vec3 white_balance(vec3 input, float temperature, float tint){
- float t1 = temperature * 10.0 / 6.0;
- float t2 = tint * 10.0 / 6.0;
-
- float x = 0.31271 - t1 * (t1 < 0.0 ? 0.1 : 0.05);
- float standard_illuminant_y = 2.87 * x - 3.0 * x * x - 0.27509507;
- float y = standard_illuminant_y + t2 * 0.05;
-
- vec3 w1 = vec3(0.949237, 1.03542, 1.08728);
-
- float Y = 1.;
- float X = Y * x / y;
- float Z = Y * (1. - x - y) / y;
- float L = 0.7328 * X + 0.4296 * Y - 0.1624 * Z;
- float M = -0.7036 * X + 1.6975 * Y + 0.0061 * Z;
- float S = 0.0030 * X + 0.0136 * Y + 0.9834 * Z;
- vec3 w2 = vec3(L, M, S);
-
- vec3 balance = vec3(w1.x / w2.x, w1.y / w2.y, w1.z / w2.z);
-
- mat3 LIN_2_LMS_MAT = mat3(
- vec3(3.90405e-1, 5.49941e-1, 8.92632e-3),
- vec3(7.08416e-2, 9.63172e-1, 1.35775e-3),
- vec3(2.31082e-2, 1.28021e-1, 9.36245e-1)
- );
-
- mat3 LMS_2_LIN_MAT = mat3(
- vec3(2.85847, -1.62879, -2.48910),
- vec3(-2.10182e-1, 1.15820e+0, 3.24281e-4),
- vec3(-4.18120e-2, -1.18169e-1, 1.06867e+0)
- );
-
- vec3 lms = LIN_2_LMS_MAT * input;
- lms *= balance;
- return LMS_2_LIN_MAT * lms;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Artistic/Artistic.gdshaderinc b/addons/ShaderLib/Artistic/Artistic.gdshaderinc
new file mode 100644
index 0000000..71e5eff
--- /dev/null
+++ b/addons/ShaderLib/Artistic/Artistic.gdshaderinc
@@ -0,0 +1,84 @@
+vec3 contrast(vec3 input, float contrast){
+ float midpoint = pow(0.5, 2.2);
+ return (input - midpoint) * contrast + midpoint;
+}
+
+vec3 hue(vec3 input, float offset, int range_index){
+ // RGB to HSV
+ vec4 k = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
+ vec4 p = mix(vec4(input.bg, k.wz), vec4(input.gb, k.xy), step(input.b, input.g));
+ vec4 q = mix(vec4(p.xyw, input.r), vec4(input.r, p.yzx), step(p.x, input.r));
+ float d = q.x - min(q.w, q.y);
+ float e = 1.0e-10;
+ vec3 hsv = vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
+
+ offset = (range_index == 0) ? offset / 360.0 : offset;
+ float hue = hsv.x + offset;
+ if(hue < 0.0){
+ hsv.x = hue + 1.;
+ }
+ else if(hue > 1.){
+ hsv.x = hue - 1.;
+ }
+ else{
+ hsv.x = hue;
+ }
+
+ // HSV to RGB
+ vec4 k2 = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
+ vec3 p2 = abs(fract(hsv.xxx + k2.xyz) * 6.0 - k2.www);
+ vec3 rgb = hsv.z * mix(k2.xxx, clamp(p2 - k2.xxx, 0.0, 1.0), hsv.y);
+ return rgb;
+}
+
+vec3 replace_color(vec3 input, vec3 from, vec3 to, float range, float fuzziness){
+ float dist = distance(from, input);
+ return mix(to, input, clamp((dist - range) / max(fuzziness, 1.0e-5), 0.0, 1.0));
+}
+
+vec3 saturation(vec3 input, float saturation){
+ float luma = dot(input, vec3(0.2126729, 0.7151522, 0.0721750));
+ return luma + saturation * (input - vec3(luma));
+}
+
+vec3 white_balance(vec3 input, float temperature, float tint){
+ float t1 = temperature * 10.0 / 6.0;
+ float t2 = tint * 10.0 / 6.0;
+
+ float x = 0.31271 - t1 * (t1 < 0.0 ? 0.1 : 0.05);
+ float standard_illuminant_y = 2.87 * x - 3.0 * x * x - 0.27509507;
+ float y = standard_illuminant_y + t2 * 0.05;
+
+ vec3 w1 = vec3(0.949237, 1.03542, 1.08728);
+
+ float Y = 1.;
+ float X = Y * x / y;
+ float Z = Y * (1. - x - y) / y;
+ float L = 0.7328 * X + 0.4296 * Y - 0.1624 * Z;
+ float M = -0.7036 * X + 1.6975 * Y + 0.0061 * Z;
+ float S = 0.0030 * X + 0.0136 * Y + 0.9834 * Z;
+ vec3 w2 = vec3(L, M, S);
+
+ vec3 balance = vec3(w1.x / w2.x, w1.y / w2.y, w1.z / w2.z);
+
+ mat3 LIN_2_LMS_MAT = mat3(
+ vec3(3.90405e-1, 5.49941e-1, 8.92632e-3),
+ vec3(7.08416e-2, 9.63172e-1, 1.35775e-3),
+ vec3(2.31082e-2, 1.28021e-1, 9.36245e-1)
+ );
+
+ mat3 LMS_2_LIN_MAT = mat3(
+ vec3(2.85847, -1.62879, -2.48910),
+ vec3(-2.10182e-1, 1.15820e+0, 3.24281e-4),
+ vec3(-4.18120e-2, -1.18169e-1, 1.06867e+0)
+ );
+
+ vec3 lms = LIN_2_LMS_MAT * input;
+ lms *= balance;
+ return LMS_2_LIN_MAT * lms;
+}
+
+vec4 color_mask(vec3 input, vec3 mask_color, float range, float fuzziness){
+ float dist = distance(mask_color, input);
+ return vec4(clamp(1. - (dist - range) / max(fuzziness, 1e-5), 0., 1.));
+}
\ No newline at end of file
diff --git a/addons/ShaderLib/Artistic/Mask/ColorMask.gd b/addons/ShaderLib/Artistic/Mask/ColorMask.gd
index fbd0b5a..c598ed0 100644
--- a/addons/ShaderLib/Artistic/Mask/ColorMask.gd
+++ b/addons/ShaderLib/Artistic/Mask/ColorMask.gd
@@ -53,8 +53,7 @@ func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_VECTOR_4D
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("ColorMask.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var input: String = "vec3(0.0)"
diff --git a/addons/ShaderLib/Artistic/Mask/ColorMask.gdshaderinc b/addons/ShaderLib/Artistic/Mask/ColorMask.gdshaderinc
deleted file mode 100644
index f304e05..0000000
--- a/addons/ShaderLib/Artistic/Mask/ColorMask.gdshaderinc
+++ /dev/null
@@ -1,4 +0,0 @@
-vec4 color_mask(vec3 input, vec3 mask_color, float range, float fuzziness){
- float dist = distance(mask_color, input);
- return vec4(clamp(1. - (dist - range) / max(fuzziness, 1e-5), 0., 1.));
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Geometry/MeshNode.gdshaderinc b/addons/ShaderLib/Geometry/Geometry.gdshaderinc
similarity index 83%
rename from addons/ShaderLib/Geometry/MeshNode.gdshaderinc
rename to addons/ShaderLib/Geometry/Geometry.gdshaderinc
index de77c68..9b9ccd7 100644
--- a/addons/ShaderLib/Geometry/MeshNode.gdshaderinc
+++ b/addons/ShaderLib/Geometry/Geometry.gdshaderinc
@@ -1,4 +1,4 @@
-vec3 geometry_node_scale_world(mat4 model_matrix){
+vec3 node_scale_world(mat4 model_matrix){
vec3 _axis_x = model_matrix[0].xyz;
vec3 _axis_y = model_matrix[1].xyz;
vec3 _axis_z = model_matrix[2].xyz;
diff --git a/addons/ShaderLib/Geometry/MeshNode.gd b/addons/ShaderLib/Geometry/MeshNode.gd
index 49ce550..22e6bef 100644
--- a/addons/ShaderLib/Geometry/MeshNode.gd
+++ b/addons/ShaderLib/Geometry/MeshNode.gd
@@ -42,11 +42,10 @@ func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool:
return false
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("MeshNode.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Geometry/Geometry.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var code: String
code = "%s = NODE_POSITION_WORLD;" % output_vars[0]
- code += "\n%s = geometry_node_scale_world(MODEL_MATRIX);" % output_vars[1]
+ code += "\n%s = node_scale_world(MODEL_MATRIX);" % output_vars[1]
return code
diff --git a/addons/ShaderLib/Maths/Vector/VectorTransform.gdshaderinc b/addons/ShaderLib/Maths/Maths.gdshaderinc
similarity index 73%
rename from addons/ShaderLib/Maths/Vector/VectorTransform.gdshaderinc
rename to addons/ShaderLib/Maths/Maths.gdshaderinc
index 91ceb44..fce6381 100644
--- a/addons/ShaderLib/Maths/Vector/VectorTransform.gdshaderinc
+++ b/addons/ShaderLib/Maths/Maths.gdshaderinc
@@ -1,3 +1,45 @@
+float chebyshev_distance_2d(vec2 point1, vec2 point2, float power) {
+ vec2 p = abs(point1 - point2);
+ return pow(pow(p.x, power) + pow(p.y, power), 1. / power);
+}
+
+float chebyshev_distance_3d(vec3 point1, vec3 point2, float power) {
+ vec3 p = abs(point1 - point2);
+ return pow(pow(p.x, power) + pow(p.y, power) + pow(p.z, power), 1. / power);
+}
+
+float manhattan_distance_2d(vec2 point1, vec2 point2) {
+ vec2 d = point1 - point2;
+ return abs(d.x) + abs(d.y);
+}
+
+float manhattan_distance_3d(vec3 point1, vec3 point2) {
+ vec3 d = point1 - point2;
+ return abs(d.x) + abs(d.y) + abs(d.z);
+}
+
+vec2 project_2d(vec2 a, vec2 b) {
+ return b * (dot(a, b) / dot(b, b));
+}
+
+vec3 project_3d(vec3 a, vec3 b) {
+ return b * (dot(a, b) / dot(b, b));
+}
+
+vec3 project_on_plane(vec3 vector, vec3 plane_normal) {
+ return vector - (plane_normal * (dot(vector, plane_normal) / dot(plane_normal, plane_normal)));
+}
+
+float smoothmin(float a, float b, float t) {
+ float h = clamp(.5 + .5 * (b - a) / t, 0, 1);
+ return mix(b, a, h) - t * h * (1. - h);
+}
+
+float smoothmax(float a, float b, float t) {
+ float h = clamp(.5 + .5 * (b - a) / -t, 0, 1);
+ return mix(b, a, h) + t * h * (1. - h);
+}
+
vec3 vector_transform_world_to_local(mat4 model_matrix, vec3 vector){
return (inverse(model_matrix) * vec4(vector, 1.0)).xyz;
}
@@ -97,3 +139,23 @@ vec3 vector_transform_tangent_to_screen(mat4 model_matrix, mat4 view_matrix, mat
vec3 vector_local = tangent_to_local_matrix * vector;
return vector_transform_local_to_screen(model_matrix, view_matrix, projection_matrix, vector_local);
}
+
+vec4 noise_sine_wave(vec4 input, vec2 min_max) {
+ vec4 _sin_in = sin(input);
+ vec4 _sin_in_offset = sin(input + 1.0);
+ vec4 _random_number = fract(sin((_sin_in - _sin_in_offset) * (12.9898 + 78.233))*43758.5453);
+ float _noise = mix(min_max.x, min_max.y, _random_number.x);
+ return _sin_in + vec4(_noise);
+}
+
+vec4 sawtooth_wave(vec4 input) {
+ return 2. * (input - floor(.5 + input));
+}
+
+vec4 square_wave(vec4 input) {
+ return 1. - 2. * round(fract(input));
+}
+
+vec4 triangle_wave(vec4 input) {
+ return 2. * abs(2. * (input - floor(.5 + input))) - 1.;
+}
\ No newline at end of file
diff --git a/addons/ShaderLib/Maths/Scalar/SmoothMax.gd b/addons/ShaderLib/Maths/Scalar/SmoothMax.gd
index 11da039..002f111 100644
--- a/addons/ShaderLib/Maths/Scalar/SmoothMax.gd
+++ b/addons/ShaderLib/Maths/Scalar/SmoothMax.gd
@@ -45,8 +45,7 @@ func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("SmoothMax.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var a: String = input_vars[0]
diff --git a/addons/ShaderLib/Maths/Scalar/SmoothMax.gdshaderinc b/addons/ShaderLib/Maths/Scalar/SmoothMax.gdshaderinc
deleted file mode 100644
index 0c1dcf0..0000000
--- a/addons/ShaderLib/Maths/Scalar/SmoothMax.gdshaderinc
+++ /dev/null
@@ -1,4 +0,0 @@
-float smoothmax(float a, float b, float t) {
- float h = clamp(.5 + .5 * (b - a) / -t, 0, 1);
- return mix(b, a, h) + t * h * (1. - h);
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Maths/Scalar/SmoothMin.gd b/addons/ShaderLib/Maths/Scalar/SmoothMin.gd
index 19b0d17..6d0384d 100644
--- a/addons/ShaderLib/Maths/Scalar/SmoothMin.gd
+++ b/addons/ShaderLib/Maths/Scalar/SmoothMin.gd
@@ -45,8 +45,7 @@ func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("SmoothMin.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var a: String = input_vars[0]
diff --git a/addons/ShaderLib/Maths/Scalar/SmoothMin.gdshaderinc b/addons/ShaderLib/Maths/Scalar/SmoothMin.gdshaderinc
deleted file mode 100644
index e9c7621..0000000
--- a/addons/ShaderLib/Maths/Scalar/SmoothMin.gdshaderinc
+++ /dev/null
@@ -1,4 +0,0 @@
-float smoothmin(float a, float b, float t) {
- float h = clamp(.5 + .5 * (b - a) / t, 0, 1);
- return mix(b, a, h) - t * h * (1. - h);
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Maths/Vector/Distance/Chebyshev2D.gdshaderinc b/addons/ShaderLib/Maths/Vector/Distance/Chebyshev2D.gdshaderinc
deleted file mode 100644
index a270d5b..0000000
--- a/addons/ShaderLib/Maths/Vector/Distance/Chebyshev2D.gdshaderinc
+++ /dev/null
@@ -1,4 +0,0 @@
-float chebyshev_distance_2d(vec2 point1, vec2 point2, float power) {
- vec2 p = abs(point1 - point2);
- return pow(pow(p.x, power) + pow(p.y, power), 1. / power);
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Maths/Vector/Distance/Chebyshev3D.gdshaderinc b/addons/ShaderLib/Maths/Vector/Distance/Chebyshev3D.gdshaderinc
deleted file mode 100644
index d5e525b..0000000
--- a/addons/ShaderLib/Maths/Vector/Distance/Chebyshev3D.gdshaderinc
+++ /dev/null
@@ -1,4 +0,0 @@
-float chebyshev_distance_3d(vec3 point1, vec3 point2, float power) {
- vec3 p = abs(point1 - point2);
- return pow(pow(p.x, power) + pow(p.y, power) + pow(p.z, power), 1. / power);
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Maths/Vector/Distance/ChebyshevDistance.gd b/addons/ShaderLib/Maths/Vector/Distance/ChebyshevDistance.gd
index bd89d87..5bedb8a 100644
--- a/addons/ShaderLib/Maths/Vector/Distance/ChebyshevDistance.gd
+++ b/addons/ShaderLib/Maths/Vector/Distance/ChebyshevDistance.gd
@@ -66,14 +66,7 @@ func _get_property_options(index: int) -> PackedStringArray:
return ["Vector2", "Vector3"]
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String
- var vector_index: int = get_option_index(0)
- match vector_index:
- 0:
- code = preload("Chebyshev2D.gdshaderinc").code
- _:
- code = preload("Chebyshev3D.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var point_a: String
diff --git a/addons/ShaderLib/Maths/Vector/Distance/Manhattan2D.gdshaderinc b/addons/ShaderLib/Maths/Vector/Distance/Manhattan2D.gdshaderinc
deleted file mode 100644
index b2d6d7e..0000000
--- a/addons/ShaderLib/Maths/Vector/Distance/Manhattan2D.gdshaderinc
+++ /dev/null
@@ -1,4 +0,0 @@
-float manhattan_distance_2d(vec2 point1, vec2 point2) {
- vec2 d = point1 - point2;
- return abs(d.x) + abs(d.y);
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Maths/Vector/Distance/Manhattan3D.gdshaderinc b/addons/ShaderLib/Maths/Vector/Distance/Manhattan3D.gdshaderinc
deleted file mode 100644
index 78ba265..0000000
--- a/addons/ShaderLib/Maths/Vector/Distance/Manhattan3D.gdshaderinc
+++ /dev/null
@@ -1,4 +0,0 @@
-float manhattan_distance_3d(vec3 point1, vec3 point2) {
- vec3 d = point1 - point2;
- return abs(d.x) + abs(d.y) + abs(d.z);
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Maths/Vector/Distance/ManhattanDistance.gd b/addons/ShaderLib/Maths/Vector/Distance/ManhattanDistance.gd
index ce99534..03173b9 100644
--- a/addons/ShaderLib/Maths/Vector/Distance/ManhattanDistance.gd
+++ b/addons/ShaderLib/Maths/Vector/Distance/ManhattanDistance.gd
@@ -53,14 +53,7 @@ func _get_property_options(index: int) -> PackedStringArray:
return ["Vector2", "Vector3"]
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String
- var vector_index: int = get_option_index(0)
- match vector_index:
- 0:
- code = preload("Manhattan2D.gdshaderinc").code
- _:
- code = preload("Manhattan3D.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var point_a: String
diff --git a/addons/ShaderLib/Maths/Vector/Project.gd b/addons/ShaderLib/Maths/Vector/Project.gd
index 27c0c7a..68db8fd 100644
--- a/addons/ShaderLib/Maths/Vector/Project.gd
+++ b/addons/ShaderLib/Maths/Vector/Project.gd
@@ -63,8 +63,7 @@ func _get_property_options(index: int) -> PackedStringArray:
return ["Vector2", "Vector3"]
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("Project.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var vector_a: String = input_vars[0]
diff --git a/addons/ShaderLib/Maths/Vector/Project.gdshaderinc b/addons/ShaderLib/Maths/Vector/Project.gdshaderinc
deleted file mode 100644
index b3b27ae..0000000
--- a/addons/ShaderLib/Maths/Vector/Project.gdshaderinc
+++ /dev/null
@@ -1,7 +0,0 @@
-vec2 project_2d(vec2 a, vec2 b) {
- return b * (dot(a, b) / dot(b, b));
-}
-
-vec3 project_3d(vec3 a, vec3 b) {
- return b * (dot(a, b) / dot(b, b));
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Maths/Vector/ProjectOnPlane.gd b/addons/ShaderLib/Maths/Vector/ProjectOnPlane.gd
index fb60ab0..d7b2bac 100644
--- a/addons/ShaderLib/Maths/Vector/ProjectOnPlane.gd
+++ b/addons/ShaderLib/Maths/Vector/ProjectOnPlane.gd
@@ -36,8 +36,7 @@ func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("ProjectOnPlane.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var vector_a: String = input_vars[0]
diff --git a/addons/ShaderLib/Maths/Vector/ProjectOnPlane.gdshaderinc b/addons/ShaderLib/Maths/Vector/ProjectOnPlane.gdshaderinc
deleted file mode 100644
index ba49e1c..0000000
--- a/addons/ShaderLib/Maths/Vector/ProjectOnPlane.gdshaderinc
+++ /dev/null
@@ -1,3 +0,0 @@
-vec3 project_on_plane(vec3 vector, vec3 plane_normal) {
- return vector - (plane_normal * (dot(vector, plane_normal) / dot(plane_normal, plane_normal)));
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Maths/Vector/VectorTransform.gd b/addons/ShaderLib/Maths/Vector/VectorTransform.gd
index 6124e22..062abdf 100644
--- a/addons/ShaderLib/Maths/Vector/VectorTransform.gd
+++ b/addons/ShaderLib/Maths/Vector/VectorTransform.gd
@@ -55,8 +55,7 @@ func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool:
return mode == Shader.MODE_SPATIAL
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("VectorTransform.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var code: String
diff --git a/addons/ShaderLib/Maths/Wave/NoiseSineWave.gd b/addons/ShaderLib/Maths/Wave/NoiseSineWave.gd
index c5d9f74..0064741 100644
--- a/addons/ShaderLib/Maths/Wave/NoiseSineWave.gd
+++ b/addons/ShaderLib/Maths/Wave/NoiseSineWave.gd
@@ -87,8 +87,7 @@ func _get_property_options(index: int) -> PackedStringArray:
return ["Vector1", "Vector2", "Vector3", "Vector4"]
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("NoiseSineWave.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var input: String
diff --git a/addons/ShaderLib/Maths/Wave/NoiseSineWave.gdshaderinc b/addons/ShaderLib/Maths/Wave/NoiseSineWave.gdshaderinc
deleted file mode 100644
index 259c210..0000000
--- a/addons/ShaderLib/Maths/Wave/NoiseSineWave.gdshaderinc
+++ /dev/null
@@ -1,8 +0,0 @@
-vec4 noise_sine_wave(vec4 input, vec2 min_max)
-{
- vec4 _sin_in = sin(input);
- vec4 _sin_in_offset = sin(input + 1.0);
- vec4 _random_number = fract(sin((_sin_in - _sin_in_offset) * (12.9898 + 78.233))*43758.5453);
- float _noise = mix(min_max.x, min_max.y, _random_number.x);
- return _sin_in + vec4(_noise);
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Maths/Wave/SawtoothWave.gd b/addons/ShaderLib/Maths/Wave/SawtoothWave.gd
index f487fb4..33d7a70 100644
--- a/addons/ShaderLib/Maths/Wave/SawtoothWave.gd
+++ b/addons/ShaderLib/Maths/Wave/SawtoothWave.gd
@@ -71,8 +71,7 @@ func _get_property_options(index: int) -> PackedStringArray:
return ["Vector1", "Vector2", "Vector3", "Vector4"]
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("SawtoothWave.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var input: String
diff --git a/addons/ShaderLib/Maths/Wave/SawtoothWave.gdshaderinc b/addons/ShaderLib/Maths/Wave/SawtoothWave.gdshaderinc
deleted file mode 100644
index f27a23f..0000000
--- a/addons/ShaderLib/Maths/Wave/SawtoothWave.gdshaderinc
+++ /dev/null
@@ -1,3 +0,0 @@
-vec4 sawtooth_wave(vec4 input) {
- return 2. * (input - floor(.5 + input));
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Maths/Wave/SquareWave.gd b/addons/ShaderLib/Maths/Wave/SquareWave.gd
index 24c3628..fb5f02e 100644
--- a/addons/ShaderLib/Maths/Wave/SquareWave.gd
+++ b/addons/ShaderLib/Maths/Wave/SquareWave.gd
@@ -72,8 +72,7 @@ func _get_property_options(index: int) -> PackedStringArray:
return ["Vector1", "Vector2", "Vector3", "Vector4"]
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("SquareWave.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var input: String
diff --git a/addons/ShaderLib/Maths/Wave/SquareWave.gdshaderinc b/addons/ShaderLib/Maths/Wave/SquareWave.gdshaderinc
deleted file mode 100644
index dc376d0..0000000
--- a/addons/ShaderLib/Maths/Wave/SquareWave.gdshaderinc
+++ /dev/null
@@ -1,3 +0,0 @@
-vec4 square_wave(vec4 input) {
- return 1. - 2. * round(fract(input));
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Maths/Wave/TriangleWave.gd b/addons/ShaderLib/Maths/Wave/TriangleWave.gd
index b5d4328..da8e90b 100644
--- a/addons/ShaderLib/Maths/Wave/TriangleWave.gd
+++ b/addons/ShaderLib/Maths/Wave/TriangleWave.gd
@@ -70,8 +70,7 @@ func _get_property_options(index: int) -> PackedStringArray:
return ["Vector1", "Vector2", "Vector3", "Vector4"]
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("TriangleWave.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var input: String
diff --git a/addons/ShaderLib/Maths/Wave/TriangleWave.gdshaderinc b/addons/ShaderLib/Maths/Wave/TriangleWave.gdshaderinc
deleted file mode 100644
index 2642c07..0000000
--- a/addons/ShaderLib/Maths/Wave/TriangleWave.gdshaderinc
+++ /dev/null
@@ -1,3 +0,0 @@
-vec4 triangle_wave(vec4 input) {
- return 2. * abs(2. * (input - floor(.5 + input))) - 1.;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Procedural/CheckerBoard.gd b/addons/ShaderLib/Procedural/CheckerBoard.gd
index b55d63f..b49e5e0 100644
--- a/addons/ShaderLib/Procedural/CheckerBoard.gd
+++ b/addons/ShaderLib/Procedural/CheckerBoard.gd
@@ -60,8 +60,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_3D
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("CheckerBoard.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
diff --git a/addons/ShaderLib/Procedural/CheckerBoard.gdshaderinc b/addons/ShaderLib/Procedural/CheckerBoard.gdshaderinc
deleted file mode 100644
index 3f6767f..0000000
--- a/addons/ShaderLib/Procedural/CheckerBoard.gdshaderinc
+++ /dev/null
@@ -1,12 +0,0 @@
-vec3 checker_board(vec2 uv, vec3 color_a, vec3 color_b, vec2 frequency){
- uv = (uv.xy + 0.5) * frequency;
- vec4 _derivatives = vec4(dFdx(uv), dFdy(uv));
- vec2 _duv_length = sqrt(vec2(dot(_derivatives.xz, _derivatives.xz), dot(_derivatives.yw, _derivatives.yw)));
- float _width = 1.0;
- vec2 _distance3 = 4.0 * abs(fract(uv + 0.25) - 0.5) - _width;
- vec2 _scale = 0.35 / _duv_length.xy;
- float _frequency_limiter = sqrt(clamp(1.1f - max(_duv_length.x, _duv_length.y), 0.0, 1.0));
- vec2 _vector_alpha = clamp(_distance3 * _scale.xy, -1.0, 1.0);
- float _alpha = clamp(0.5f + 0.5f * _vector_alpha.x * _vector_alpha.y * _frequency_limiter, 0.0, 1.0);
- return mix(color_b, color_a, _alpha);
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Procedural/Fractals/KochFractal.gd b/addons/ShaderLib/Procedural/Fractals/KochFractal.gd
index cf60fd6..ef45355 100644
--- a/addons/ShaderLib/Procedural/Fractals/KochFractal.gd
+++ b/addons/ShaderLib/Procedural/Fractals/KochFractal.gd
@@ -68,8 +68,7 @@ func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("KochFractal.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
diff --git a/addons/ShaderLib/Procedural/Fractals/KochFractal.gdshaderinc b/addons/ShaderLib/Procedural/Fractals/KochFractal.gdshaderinc
deleted file mode 100644
index b04485f..0000000
--- a/addons/ShaderLib/Procedural/Fractals/KochFractal.gdshaderinc
+++ /dev/null
@@ -1,36 +0,0 @@
-vec2 koch_fractal_direction(float angle){
- return vec2(sin(angle), cos(angle));
-}
-
-float koch_fractal(vec2 uv, float outline, int iteration, float shape_width, float shape_height, out vec2 koch_uv) {
- float tiling = 3.0;
- vec2 center = uv - vec2(.5);
- shape_width = .85 * (shape_width / 1.);
- shape_height = .85 * (shape_height / 1.);
- center.x /= shape_width;
- center.y /= shape_height;
-
- center.x = abs(center.x);
- center.y += tan(.833 * PI) * .5;
- vec2 dir = koch_fractal_direction(.833 * PI);
- float dist = dot(center - vec2(tiling / (2. * tiling), 0), dir);
- center -= dir * max(0, dist) * 2.0;
-
- dir = koch_fractal_direction(.6667 * PI);
- float scale = 1.0;
- center.x += .5;
- for(int i = 0; i < iteration; i++){
- center *= tiling;
- scale *= tiling;
- center.x -= .5 * tiling;
-
- center.x = abs(center.x);
- center.x -= .5;
- center -= dir * min(0.0, dot(center, dir)) * 2.0;
- }
-
- dist = length(center - vec2(clamp(center.x, -1.0, 1.0), 0));
- dist += step(outline / 100.0, dist / scale);
- koch_uv = abs(center);
- return 1.0 - dist;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Procedural/Noise/GradientNoise.gd b/addons/ShaderLib/Procedural/Noise/GradientNoise.gd
index a9d47bc..7421215 100644
--- a/addons/ShaderLib/Procedural/Noise/GradientNoise.gd
+++ b/addons/ShaderLib/Procedural/Noise/GradientNoise.gd
@@ -52,8 +52,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("GradientNoise.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
diff --git a/addons/ShaderLib/Procedural/Noise/GradientNoise.gdshaderinc b/addons/ShaderLib/Procedural/Noise/GradientNoise.gdshaderinc
deleted file mode 100644
index 9a8a79d..0000000
--- a/addons/ShaderLib/Procedural/Noise/GradientNoise.gdshaderinc
+++ /dev/null
@@ -1,28 +0,0 @@
-vec2 gradient_modulo(vec2 divident, vec2 divisor){
- vec2 _positive_divident = mod(divident, divisor) + divisor;
- return mod(_positive_divident, divisor);
-}
-
-vec2 gradient_random(vec2 uv){
- uv = vec2(dot(uv, vec2(127.1,311.7)), dot(uv, vec2(269.5,183.3)));
- return -1.0 + 2.0 * fract(sin(uv) * 43758.5453123);
-}
-
-float gradient_noise(vec2 uv, float scale) {
- uv = uv * float(scale);
- vec2 _period = vec2(30.0, 60.0);
- vec2 _cells_minimum = floor(uv);
- vec2 _cells_maximum = ceil(uv);
- vec2 _uv_fract = fract(uv);
- _cells_minimum = gradient_modulo(_cells_minimum, _period);
- _cells_maximum = gradient_modulo(_cells_maximum, _period);
- vec2 _blur = smoothstep(0.0, 1.0, _uv_fract);
- vec2 _lowerLeftDirection = gradient_random(vec2(_cells_minimum.x, _cells_minimum.y));
- vec2 _lowerRightDirection = gradient_random(vec2(_cells_maximum.x, _cells_minimum.y));
- vec2 _upperLeftDirection = gradient_random(vec2(_cells_minimum.x, _cells_maximum.y));
- vec2 _upperRightDirection = gradient_random(vec2(_cells_maximum.x, _cells_maximum.y));
- vec2 _fraction = fract(uv);
- float _mix_one = mix(dot(_lowerLeftDirection, _fraction - vec2(0, 0)), dot(_lowerRightDirection, _fraction - vec2(1, 0)), _blur.x);
- float _mix_two = mix(dot(_upperLeftDirection, _fraction - vec2(0, 1)), dot(_upperRightDirection, _fraction - vec2(1, 1)), _blur.x);
- return mix(_mix_one, _mix_two, _blur.y) * 0.8 + 0.5;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Procedural/Noise/GyroidNoise.gd b/addons/ShaderLib/Procedural/Noise/GyroidNoise.gd
index 711b2ba..be1b836 100644
--- a/addons/ShaderLib/Procedural/Noise/GyroidNoise.gd
+++ b/addons/ShaderLib/Procedural/Noise/GyroidNoise.gd
@@ -62,8 +62,7 @@ func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("GyroidNoise.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
diff --git a/addons/ShaderLib/Procedural/Noise/GyroidNoise.gdshaderinc b/addons/ShaderLib/Procedural/Noise/GyroidNoise.gdshaderinc
deleted file mode 100644
index a7007dc..0000000
--- a/addons/ShaderLib/Procedural/Noise/GyroidNoise.gdshaderinc
+++ /dev/null
@@ -1,7 +0,0 @@
-float gyroid_noise(vec2 uv, float scale, vec2 ratio, float height, float thickness) {
- scale *= 10.;
- thickness = clamp(thickness, 0., 1.);
- vec3 vector = vec3(uv, height);
- vector *= scale;
- return abs(dot(sin(vector * ratio.x), cos(vector.zxy * ratio.y))) - thickness;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Procedural/Noise/PseudoRandomNoise.gd b/addons/ShaderLib/Procedural/Noise/PseudoRandomNoise.gd
index a77c3fe..7d9432e 100644
--- a/addons/ShaderLib/Procedural/Noise/PseudoRandomNoise.gd
+++ b/addons/ShaderLib/Procedural/Noise/PseudoRandomNoise.gd
@@ -42,4 +42,4 @@ func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
- return output_vars[0] + " = fract(sin(dot(UV.xy + vec2(%s), vec2(12.9898,78.233))) * 43758.5453123);" % input_vars[0]
+ return output_vars[0] + " = pseudo_random_noise(UV, %s);" % input_vars[0]
diff --git a/addons/ShaderLib/Procedural/Noise/SimpleNoise.gd b/addons/ShaderLib/Procedural/Noise/SimpleNoise.gd
index fdffb25..57784be 100644
--- a/addons/ShaderLib/Procedural/Noise/SimpleNoise.gd
+++ b/addons/ShaderLib/Procedural/Noise/SimpleNoise.gd
@@ -56,8 +56,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("SimpleNoise.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
diff --git a/addons/ShaderLib/Procedural/Noise/SimpleNoise.gdshaderinc b/addons/ShaderLib/Procedural/Noise/SimpleNoise.gdshaderinc
deleted file mode 100644
index 31c1f3e..0000000
--- a/addons/ShaderLib/Procedural/Noise/SimpleNoise.gdshaderinc
+++ /dev/null
@@ -1,33 +0,0 @@
-float simple_noise_random(vec2 point) {
- return fract(sin(point.x * 100. + point.y * 654.125) * 55647.8745);
-}
-
-float value_noise(vec2 uv) {
- vec2 grid_uv = fract(uv);
- vec2 grid_id = floor(uv);
- grid_uv = grid_uv * grid_uv * (3. - 2. * grid_uv);
-
- float bottom_left = simple_noise_random(grid_id);
- float bottom_right = simple_noise_random(grid_id + vec2(1, 0));
- float bottom = mix(bottom_left, bottom_right, grid_uv.x);
-
- float top_left = simple_noise_random(grid_id + vec2(0, 1));
- float top_right = simple_noise_random(grid_id + vec2(1, 1));
- float top = mix(top_left, top_right, grid_uv.x);
-
- return mix(bottom, top, grid_uv.y);
-}
-
-float simple_noise(vec2 uv, float scale, int octaves) {
- octaves = clamp(octaves, 1, 6);
- float noise = value_noise(uv * scale);
- float amplitude = 1.;
-
- for(int i = 1; i < octaves; i++) {
- scale *= 2.;
- amplitude /= 2.;
- noise += value_noise(uv * scale) * amplitude;
- }
-
- return noise / 2.;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Procedural/Noise/Voronoi.gd b/addons/ShaderLib/Procedural/Noise/Voronoi.gd
index 303df43..25ea313 100644
--- a/addons/ShaderLib/Procedural/Noise/Voronoi.gd
+++ b/addons/ShaderLib/Procedural/Noise/Voronoi.gd
@@ -101,8 +101,7 @@ func _get_property_options(index: int) -> PackedStringArray:
return ["Euclidean", "Manhattan", "Chebyshev"]
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("Voronoi.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
diff --git a/addons/ShaderLib/Procedural/Noise/Voronoi.gdshaderinc b/addons/ShaderLib/Procedural/Noise/Voronoi.gdshaderinc
deleted file mode 100644
index cec15bb..0000000
--- a/addons/ShaderLib/Procedural/Noise/Voronoi.gdshaderinc
+++ /dev/null
@@ -1,43 +0,0 @@
-#include "res://addons/ShaderLib/Maths/Vector/Distance/Manhattan2D.gdshaderinc"
-#include "res://addons/ShaderLib/Maths/Vector/Distance/Chebyshev2D.gdshaderinc"
-
-vec2 voronoi_random_vector(vec2 p) {
- mat2 matrix = mat2(vec2(15.27, 47.63), vec2(99.41, 89.98));
- return fract(sin(p * matrix) * 46839.32);
-}
-
-void voronoi_noise(vec2 uv, float cell_density, float angle_offset, int distance_index, float chebyshev_power, out float output, out float cells){
- vec2 grid_uv = fract(uv * cell_density);
- vec2 grid_id = floor(uv * cell_density);
- vec2 cell_id = vec2(0);
- float min_dist = 100.;
-
- for(float y = -1.; y <= 1.; y++) {
- for(float x = -1.; x <= 1.; x++) {
- vec2 offset = vec2(x, y);
- vec2 n = voronoi_random_vector(grid_id + offset);
- vec2 p = offset + vec2(sin(n.x + angle_offset) * .5 + .5, cos(n.y + angle_offset) * .5 + .5);
- float d = min_dist;
-
- switch(distance_index){
- case 1:
- d = manhattan_distance_2d(grid_uv, p);
- break;
- case 2:
- d = chebyshev_distance_2d(grid_uv, p, chebyshev_power);
- break;
- default:
- d = distance(grid_uv, p);
- break;
- }
-
- if(d < min_dist) {
- min_dist = d;
- cell_id = voronoi_random_vector(grid_id + offset);
- }
- }
- }
-
- output = min_dist;
- cells = cell_id.y;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Procedural/Procedural.gdshaderinc b/addons/ShaderLib/Procedural/Procedural.gdshaderinc
new file mode 100644
index 0000000..0ba50c3
--- /dev/null
+++ b/addons/ShaderLib/Procedural/Procedural.gdshaderinc
@@ -0,0 +1,232 @@
+#include "res://addons/ShaderLib/Maths/Maths.gdshaderinc"
+
+vec3 checker_board(vec2 uv, vec3 color_a, vec3 color_b, vec2 frequency){
+ uv = (uv.xy + 0.5) * frequency;
+ vec4 _derivatives = vec4(dFdx(uv), dFdy(uv));
+ vec2 _duv_length = sqrt(vec2(dot(_derivatives.xz, _derivatives.xz), dot(_derivatives.yw, _derivatives.yw)));
+ float _width = 1.0;
+ vec2 _distance3 = 4.0 * abs(fract(uv + 0.25) - 0.5) - _width;
+ vec2 _scale = 0.35 / _duv_length.xy;
+ float _frequency_limiter = sqrt(clamp(1.1f - max(_duv_length.x, _duv_length.y), 0.0, 1.0));
+ vec2 _vector_alpha = clamp(_distance3 * _scale.xy, -1.0, 1.0);
+ float _alpha = clamp(0.5f + 0.5f * _vector_alpha.x * _vector_alpha.y * _frequency_limiter, 0.0, 1.0);
+ return mix(color_b, color_a, _alpha);
+}
+
+vec2 koch_fractal_direction(float angle){
+ return vec2(sin(angle), cos(angle));
+}
+
+float koch_fractal(vec2 uv, float outline, int iteration, float shape_width, float shape_height, out vec2 koch_uv) {
+ float tiling = 3.0;
+ vec2 center = uv - vec2(.5);
+ shape_width = .85 * (shape_width / 1.);
+ shape_height = .85 * (shape_height / 1.);
+ center.x /= shape_width;
+ center.y /= shape_height;
+
+ center.x = abs(center.x);
+ center.y += tan(.833 * PI) * .5;
+ vec2 dir = koch_fractal_direction(.833 * PI);
+ float dist = dot(center - vec2(tiling / (2. * tiling), 0), dir);
+ center -= dir * max(0, dist) * 2.0;
+
+ dir = koch_fractal_direction(.6667 * PI);
+ float scale = 1.0;
+ center.x += .5;
+ for(int i = 0; i < iteration; i++){
+ center *= tiling;
+ scale *= tiling;
+ center.x -= .5 * tiling;
+
+ center.x = abs(center.x);
+ center.x -= .5;
+ center -= dir * min(0.0, dot(center, dir)) * 2.0;
+ }
+
+ dist = length(center - vec2(clamp(center.x, -1.0, 1.0), 0));
+ dist += step(outline / 100.0, dist / scale);
+ koch_uv = abs(center);
+ return 1.0 - dist;
+}
+
+vec2 gradient_modulo(vec2 divident, vec2 divisor){
+ vec2 _positive_divident = mod(divident, divisor) + divisor;
+ return mod(_positive_divident, divisor);
+}
+
+vec2 gradient_random(vec2 uv){
+ uv = vec2(dot(uv, vec2(127.1,311.7)), dot(uv, vec2(269.5,183.3)));
+ return -1.0 + 2.0 * fract(sin(uv) * 43758.5453123);
+}
+
+float gradient_noise(vec2 uv, float scale) {
+ uv = uv * float(scale);
+ vec2 _period = vec2(30.0, 60.0);
+ vec2 _cells_minimum = floor(uv);
+ vec2 _cells_maximum = ceil(uv);
+ vec2 _uv_fract = fract(uv);
+ _cells_minimum = gradient_modulo(_cells_minimum, _period);
+ _cells_maximum = gradient_modulo(_cells_maximum, _period);
+ vec2 _blur = smoothstep(0.0, 1.0, _uv_fract);
+ vec2 _lowerLeftDirection = gradient_random(vec2(_cells_minimum.x, _cells_minimum.y));
+ vec2 _lowerRightDirection = gradient_random(vec2(_cells_maximum.x, _cells_minimum.y));
+ vec2 _upperLeftDirection = gradient_random(vec2(_cells_minimum.x, _cells_maximum.y));
+ vec2 _upperRightDirection = gradient_random(vec2(_cells_maximum.x, _cells_maximum.y));
+ vec2 _fraction = fract(uv);
+ float _mix_one = mix(dot(_lowerLeftDirection, _fraction - vec2(0, 0)), dot(_lowerRightDirection, _fraction - vec2(1, 0)), _blur.x);
+ float _mix_two = mix(dot(_upperLeftDirection, _fraction - vec2(0, 1)), dot(_upperRightDirection, _fraction - vec2(1, 1)), _blur.x);
+ return mix(_mix_one, _mix_two, _blur.y) * 0.8 + 0.5;
+}
+
+float gyroid_noise(vec2 uv, float scale, vec2 ratio, float height, float thickness) {
+ scale *= 10.;
+ thickness = clamp(thickness, 0., 1.);
+ vec3 vector = vec3(uv, height);
+ vector *= scale;
+ return abs(dot(sin(vector * ratio.x), cos(vector.zxy * ratio.y))) - thickness;
+}
+
+float pseudo_random_noise(vec2 uv, float seed) {
+ return fract(sin(dot(uv.xy + seed, vec2(12.9898,78.233))) * 43758.5453123);
+}
+
+float simple_noise_random(vec2 point) {
+ return fract(sin(point.x * 100. + point.y * 654.125) * 55647.8745);
+}
+
+float value_noise(vec2 uv) {
+ vec2 grid_uv = fract(uv);
+ vec2 grid_id = floor(uv);
+ grid_uv = grid_uv * grid_uv * (3. - 2. * grid_uv);
+
+ float bottom_left = simple_noise_random(grid_id);
+ float bottom_right = simple_noise_random(grid_id + vec2(1, 0));
+ float bottom = mix(bottom_left, bottom_right, grid_uv.x);
+
+ float top_left = simple_noise_random(grid_id + vec2(0, 1));
+ float top_right = simple_noise_random(grid_id + vec2(1, 1));
+ float top = mix(top_left, top_right, grid_uv.x);
+
+ return mix(bottom, top, grid_uv.y);
+}
+
+float simple_noise(vec2 uv, float scale, int octaves) {
+ octaves = clamp(octaves, 1, 6);
+ float noise = value_noise(uv * scale);
+ float amplitude = 1.;
+
+ for(int i = 1; i < octaves; i++) {
+ scale *= 2.;
+ amplitude /= 2.;
+ noise += value_noise(uv * scale) * amplitude;
+ }
+
+ return noise / 2.;
+}
+
+vec2 voronoi_random_vector(vec2 p) {
+ mat2 matrix = mat2(vec2(15.27, 47.63), vec2(99.41, 89.98));
+ return fract(sin(p * matrix) * 46839.32);
+}
+
+void voronoi_noise(vec2 uv, float cell_density, float angle_offset, int distance_index, float chebyshev_power, out float output, out float cells){
+ vec2 grid_uv = fract(uv * cell_density);
+ vec2 grid_id = floor(uv * cell_density);
+ vec2 cell_id = vec2(0);
+ float min_dist = 100.;
+
+ for(float y = -1.; y <= 1.; y++) {
+ for(float x = -1.; x <= 1.; x++) {
+ vec2 offset = vec2(x, y);
+ vec2 n = voronoi_random_vector(grid_id + offset);
+ vec2 p = offset + vec2(sin(n.x + angle_offset) * .5 + .5, cos(n.y + angle_offset) * .5 + .5);
+ float d = min_dist;
+
+ switch(distance_index){
+ case 1:
+ d = manhattan_distance_2d(grid_uv, p);
+ break;
+ case 2:
+ d = chebyshev_distance_2d(grid_uv, p, chebyshev_power);
+ break;
+ default:
+ d = distance(grid_uv, p);
+ break;
+ }
+
+ if(d < min_dist) {
+ min_dist = d;
+ cell_id = voronoi_random_vector(grid_id + offset);
+ }
+ }
+ }
+
+ output = min_dist;
+ cells = cell_id.y;
+}
+
+float ellipse_shape(vec2 uv, float width, float height){
+ float _distance = length((uv * 2.0 - 1.0) / vec2(width, height));
+ return clamp((1.0 - _distance) / fwidth(_distance), 0.0, 1.0);
+}
+
+float polygon_shape(vec2 uv, int sides, float width, float height){
+ float _a_width = width * cos(PI / float(sides));
+ float _a_height = height * cos(PI / float(sides));
+ uv = (uv * 2.0 - 1.0) / vec2(_a_width, _a_height);
+ uv.y *= -1.0;
+ float _polar_coords = atan(uv.x, uv.y);
+ float _radius = 2.0 * PI / float(sides);
+ float _distance = cos(floor(0.5 + _polar_coords / _radius) * _radius - _polar_coords) * length(uv);
+ return clamp((1.0 - _distance) / fwidth(_distance), 0.0, 1.0);
+}
+
+float rectangle_shape(vec2 uv, float width, float height){
+ vec2 _distance = abs(uv * 2.0 - 1.0) - vec2(width, height);
+ _distance = 1.0 - _distance / fwidth(_distance);
+ return clamp(min(_distance.x, _distance.y), 0.0, 1.0);
+}
+
+float rounded_polygon_shape(vec2 uv, float width, float height, float sides, float roundness){
+ uv = uv * 2.0 + vec2(-1.0);
+ roundness /= 10.0;
+ float _epsilon = 1e-6;
+ uv.x = uv.x / ( width + ((width>-_epsilon && width<_epsilon) ? 1.0 : 0.0 * _epsilon));
+ uv.y = uv.y / ( height + ((height>-_epsilon && height<_epsilon) ? 1.0 : 0.0 * _epsilon));
+ roundness = clamp(roundness, 1e-6, 1.0);
+ float _i_sides = floor( abs( sides ) );
+ float _full_angle = 2.0 * PI / _i_sides;
+ float _half_angle = _full_angle / 2.;
+ float _diagonal = 1.0 / cos( _half_angle );
+ float _chamfer_angle = roundness * _half_angle;
+ float _remaining_angle = _half_angle - _chamfer_angle;
+ float _ratio = tan(_remaining_angle) / tan(_half_angle);
+ vec2 _chamfer_center = vec2(cos(_half_angle) , sin(_half_angle))* _ratio * _diagonal;
+
+ float _dist_a = length(_chamfer_center);
+ float _dist_b = 1.0 - _chamfer_center.x;
+ float _uv_scale = _diagonal;
+ uv *= _uv_scale;
+ vec2 _polar_uv = vec2(atan(uv.y, uv.x), length(uv));
+
+ _polar_uv.x += PI / 2.0 + TAU;
+ _polar_uv.x = mod(_polar_uv.x + _half_angle, _full_angle );
+ _polar_uv.x = abs(_polar_uv.x - _half_angle);
+ uv = vec2(cos(_polar_uv.x), sin(_polar_uv.x)) * _polar_uv.y;
+ float _angle_ratio = 1.0 - (_polar_uv.x-_remaining_angle) / _chamfer_angle;
+ float _dist_c = sqrt(_dist_a * _dist_a + _dist_b * _dist_b - 2.0 * _dist_a *_dist_b * cos(PI - _half_angle * _angle_ratio));
+ float output = uv.x;
+ float _chamfer_zone = (_half_angle - _polar_uv.x) < _chamfer_angle ? 1.0 : 0.0;
+ output = mix(uv.x, _polar_uv.y / _dist_c, _chamfer_zone);
+ output = clamp((1.0 - output) / fwidth(output), 0.0, 1.0);
+ return output;
+}
+
+float rounded_rectangle_shape(vec2 uv, float width, float height, float radius){
+ radius /= 10.0;
+ radius = max(min(min(abs(radius * 2.0), abs(width)), abs(height)), 1e-5);
+ uv = abs(uv * 2.0 - 1.0) - vec2(width, height) + radius;
+ float _distance = length(max(vec2(0.0), uv)) / radius;
+ return clamp((1.0 - _distance) / fwidth(_distance), 0.0, 1.0);
+}
\ No newline at end of file
diff --git a/addons/ShaderLib/Procedural/Shapes/Ellipse.gd b/addons/ShaderLib/Procedural/Shapes/Ellipse.gd
index 4a4bb42..2b20403 100644
--- a/addons/ShaderLib/Procedural/Shapes/Ellipse.gd
+++ b/addons/ShaderLib/Procedural/Shapes/Ellipse.gd
@@ -54,8 +54,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("Ellipse.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
diff --git a/addons/ShaderLib/Procedural/Shapes/Ellipse.gdshaderinc b/addons/ShaderLib/Procedural/Shapes/Ellipse.gdshaderinc
deleted file mode 100644
index d820658..0000000
--- a/addons/ShaderLib/Procedural/Shapes/Ellipse.gdshaderinc
+++ /dev/null
@@ -1,4 +0,0 @@
-float ellipse_shape(vec2 uv, float width, float height){
- float _distance = length((uv * 2.0 - 1.0) / vec2(width, height));
- return clamp((1.0 - _distance) / fwidth(_distance), 0.0, 1.0);
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Procedural/Shapes/Polygon.gd b/addons/ShaderLib/Procedural/Shapes/Polygon.gd
index 0dfc2d4..d575571 100644
--- a/addons/ShaderLib/Procedural/Shapes/Polygon.gd
+++ b/addons/ShaderLib/Procedural/Shapes/Polygon.gd
@@ -60,8 +60,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("Polygon.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
diff --git a/addons/ShaderLib/Procedural/Shapes/Polygon.gdshaderinc b/addons/ShaderLib/Procedural/Shapes/Polygon.gdshaderinc
deleted file mode 100644
index f4590a9..0000000
--- a/addons/ShaderLib/Procedural/Shapes/Polygon.gdshaderinc
+++ /dev/null
@@ -1,10 +0,0 @@
-float polygon_shape(vec2 uv, int sides, float width, float height){
- float _a_width = width * cos(PI / float(sides));
- float _a_height = height * cos(PI / float(sides));
- uv = (uv * 2.0 - 1.0) / vec2(_a_width, _a_height);
- uv.y *= -1.0;
- float _polar_coords = atan(uv.x, uv.y);
- float _radius = 2.0 * PI / float(sides);
- float _distance = cos(floor(0.5 + _polar_coords / _radius) * _radius - _polar_coords) * length(uv);
- return clamp((1.0 - _distance) / fwidth(_distance), 0.0, 1.0);
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Procedural/Shapes/Rectangle.gd b/addons/ShaderLib/Procedural/Shapes/Rectangle.gd
index b6e0dfd..19173c6 100644
--- a/addons/ShaderLib/Procedural/Shapes/Rectangle.gd
+++ b/addons/ShaderLib/Procedural/Shapes/Rectangle.gd
@@ -54,8 +54,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("Rectangle.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
diff --git a/addons/ShaderLib/Procedural/Shapes/Rectangle.gdshaderinc b/addons/ShaderLib/Procedural/Shapes/Rectangle.gdshaderinc
deleted file mode 100644
index 50a9d11..0000000
--- a/addons/ShaderLib/Procedural/Shapes/Rectangle.gdshaderinc
+++ /dev/null
@@ -1,5 +0,0 @@
-float rectangle_shape(vec2 uv, float width, float height){
- vec2 _distance = abs(uv * 2.0 - 1.0) - vec2(width, height);
- _distance = 1.0 - _distance / fwidth(_distance);
- return clamp(min(_distance.x, _distance.y), 0.0, 1.0);
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Procedural/Shapes/RoundedPolygon.gd b/addons/ShaderLib/Procedural/Shapes/RoundedPolygon.gd
index 048293a..4798498 100644
--- a/addons/ShaderLib/Procedural/Shapes/RoundedPolygon.gd
+++ b/addons/ShaderLib/Procedural/Shapes/RoundedPolygon.gd
@@ -61,8 +61,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("RoundedPolygon.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
diff --git a/addons/ShaderLib/Procedural/Shapes/RoundedPolygon.gdshaderinc b/addons/ShaderLib/Procedural/Shapes/RoundedPolygon.gdshaderinc
deleted file mode 100644
index 87a241d..0000000
--- a/addons/ShaderLib/Procedural/Shapes/RoundedPolygon.gdshaderinc
+++ /dev/null
@@ -1,34 +0,0 @@
-float rounded_polygon_shape(vec2 uv, float width, float height, float sides, float roundness){
- uv = uv * 2.0 + vec2(-1.0);
- roundness /= 10.0;
- float _epsilon = 1e-6;
- uv.x = uv.x / ( width + ((width>-_epsilon && width<_epsilon) ? 1.0 : 0.0 * _epsilon));
- uv.y = uv.y / ( height + ((height>-_epsilon && height<_epsilon) ? 1.0 : 0.0 * _epsilon));
- roundness = clamp(roundness, 1e-6, 1.0);
- float _i_sides = floor( abs( sides ) );
- float _full_angle = 2.0 * PI / _i_sides;
- float _half_angle = _full_angle / 2.;
- float _diagonal = 1.0 / cos( _half_angle );
- float _chamfer_angle = roundness * _half_angle;
- float _remaining_angle = _half_angle - _chamfer_angle;
- float _ratio = tan(_remaining_angle) / tan(_half_angle);
- vec2 _chamfer_center = vec2(cos(_half_angle) , sin(_half_angle))* _ratio * _diagonal;
-
- float _dist_a = length(_chamfer_center);
- float _dist_b = 1.0 - _chamfer_center.x;
- float _uv_scale = _diagonal;
- uv *= _uv_scale;
- vec2 _polar_uv = vec2(atan(uv.y, uv.x), length(uv));
-
- _polar_uv.x += PI / 2.0 + TAU;
- _polar_uv.x = mod(_polar_uv.x + _half_angle, _full_angle );
- _polar_uv.x = abs(_polar_uv.x - _half_angle);
- uv = vec2(cos(_polar_uv.x), sin(_polar_uv.x)) * _polar_uv.y;
- float _angle_ratio = 1.0 - (_polar_uv.x-_remaining_angle) / _chamfer_angle;
- float _dist_c = sqrt(_dist_a * _dist_a + _dist_b * _dist_b - 2.0 * _dist_a *_dist_b * cos(PI - _half_angle * _angle_ratio));
- float output = uv.x;
- float _chamfer_zone = (_half_angle - _polar_uv.x) < _chamfer_angle ? 1.0 : 0.0;
- output = mix(uv.x, _polar_uv.y / _dist_c, _chamfer_zone);
- output = clamp((1.0 - output) / fwidth(output), 0.0, 1.0);
- return output;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/Procedural/Shapes/RoundedRectangle.gd b/addons/ShaderLib/Procedural/Shapes/RoundedRectangle.gd
index acc3e74..f1b4473 100644
--- a/addons/ShaderLib/Procedural/Shapes/RoundedRectangle.gd
+++ b/addons/ShaderLib/Procedural/Shapes/RoundedRectangle.gd
@@ -58,8 +58,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("RoundedRectangle.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
diff --git a/addons/ShaderLib/Procedural/Shapes/RoundedRectangle.gdshaderinc b/addons/ShaderLib/Procedural/Shapes/RoundedRectangle.gdshaderinc
deleted file mode 100644
index 3d3416d..0000000
--- a/addons/ShaderLib/Procedural/Shapes/RoundedRectangle.gdshaderinc
+++ /dev/null
@@ -1,7 +0,0 @@
-float rounded_rectangle_shape(vec2 uv, float width, float height, float radius){
- radius /= 10.0;
- radius = max(min(min(abs(radius * 2.0), abs(width)), abs(height)), 1e-5);
- uv = abs(uv * 2.0 - 1.0) - vec2(width, height) + radius;
- float _distance = length(max(vec2(0.0), uv)) / radius;
- return clamp((1.0 - _distance) / fwidth(_distance), 0.0, 1.0);
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/RayMarching/RayMarch.gd b/addons/ShaderLib/RayMarching/RayMarch.gd
index acab6b9..4fc3f9b 100644
--- a/addons/ShaderLib/RayMarching/RayMarch.gd
+++ b/addons/ShaderLib/RayMarching/RayMarch.gd
@@ -183,21 +183,7 @@ func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String
- var sdf_index: int = get_option_index(0)
- code = preload("RayMarchRotation.gdshaderinc").code
- match sdf_index:
- 0:
- code += preload("SDBox.gdshaderinc").code
- 1:
- code += preload("SDSphere.gdshaderinc").code
- 2:
- code += preload("SDCapsule.gdshaderinc").code
- 3:
- code += preload("SDCylinder.gdshaderinc").code
- _:
- code += preload("SDTorus.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/RayMarching/SignedDistanceFunctions.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var sdf_index: int = get_option_index(0)
diff --git a/addons/ShaderLib/RayMarching/RayMarchCustom.gdshaderinc b/addons/ShaderLib/RayMarching/RayMarchCustomTemplate.gdshaderinc
similarity index 80%
rename from addons/ShaderLib/RayMarching/RayMarchCustom.gdshaderinc
rename to addons/ShaderLib/RayMarching/RayMarchCustomTemplate.gdshaderinc
index 1a46c9e..600599c 100644
--- a/addons/ShaderLib/RayMarching/RayMarchCustom.gdshaderinc
+++ b/addons/ShaderLib/RayMarching/RayMarchCustomTemplate.gdshaderinc
@@ -1,3 +1,6 @@
+// For in depth ray marching or sphere tracing info check out the playlist
+// https://www.youtube.com/watch?v=68G3V5Yr8FY&list=PLaE0_uENxXqvzte-A0Ux2pav0zrUrTJ1V
+
float sdf_custom(vec3 p) {
// Basic example of Sphere SDF with radius of .3
// Put your custom logic here
diff --git a/addons/ShaderLib/RayMarching/RayMarchRotation.gdshaderinc b/addons/ShaderLib/RayMarching/RayMarchRotation.gdshaderinc
deleted file mode 100644
index 6f88c7e..0000000
--- a/addons/ShaderLib/RayMarching/RayMarchRotation.gdshaderinc
+++ /dev/null
@@ -1,7 +0,0 @@
-mat2 rm_rotation(float angle) {
- angle = -angle * (3.1415926 / 180.);
- return mat2(
- vec2(cos(angle), -sin(angle)),
- vec2(sin(angle), cos(angle))
- );
-}
diff --git a/addons/ShaderLib/RayMarching/SDBox.gdshaderinc b/addons/ShaderLib/RayMarching/SDBox.gdshaderinc
deleted file mode 100644
index 3da6be7..0000000
--- a/addons/ShaderLib/RayMarching/SDBox.gdshaderinc
+++ /dev/null
@@ -1,21 +0,0 @@
-float sd_box(vec3 point, vec3 size, vec3 eulers) {
- point.yz *= rm_rotation(eulers.x);
- point.xy *= rm_rotation(eulers.z);
- point.xz *= rm_rotation(-eulers.y);
- return length(max(abs(point) - size, vec3(0)));
-}
-
-float ray_march_sd_box(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 cube_pos, vec3 eulers, vec3 size) {
- ray_dir = normalize(ray_dir);
- dist_threshold = abs(dist_threshold);
- float dist_from_origin = 0.;
- float dist_to_surface;
- for(int i = 0; i < max_steps; i++) {
- vec3 point = ray_origin + dist_from_origin * ray_dir;
- dist_to_surface = sd_box(point - cube_pos, size, eulers);
- dist_from_origin += dist_to_surface;
- if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
- break;
- }
- return dist_from_origin;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/RayMarching/SDCapsule.gdshaderinc b/addons/ShaderLib/RayMarching/SDCapsule.gdshaderinc
deleted file mode 100644
index 75d56d9..0000000
--- a/addons/ShaderLib/RayMarching/SDCapsule.gdshaderinc
+++ /dev/null
@@ -1,33 +0,0 @@
-float sd_capsule(vec3 point, vec3 capsule_pos, float height, float radius, vec3 eulers) {
- vec3 orientation = vec3(0, 1, 0);
- orientation.yz *= rm_rotation(eulers.x);
- orientation.xy *= rm_rotation(eulers.z);
- orientation.xz *= rm_rotation(-eulers.y);
-
- vec3 top_point = point + orientation * (height * .5);
- vec3 bottom_point = point - orientation * (height * .5);
-
- vec3 height_vector = bottom_point - top_point;
- vec3 top_distance = capsule_pos - top_point;
-
- float t = dot(height_vector, top_distance) / dot(height_vector, height_vector);
- t = clamp(t, 0., 1.);
- vec3 hit_point = top_point + t * height_vector;
-
- return length(capsule_pos - hit_point) - radius;
-}
-
-float ray_march_sd_capsule(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 capsule_pos, float capsule_height, float capsule_radius, vec3 eulers) {
- ray_dir = normalize(ray_dir);
- dist_threshold = abs(dist_threshold);
- float dist_from_origin = 0.;
- float dist_to_surface;
- for(int i = 0; i < max_steps; i++) {
- vec3 point = ray_origin + dist_from_origin * ray_dir;
- dist_to_surface = sd_capsule(point, capsule_pos, capsule_height, capsule_radius, eulers);
- dist_from_origin += dist_to_surface;
- if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
- break;
- }
- return dist_from_origin;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/RayMarching/SDCylinder.gdshaderinc b/addons/ShaderLib/RayMarching/SDCylinder.gdshaderinc
deleted file mode 100644
index 0b5316e..0000000
--- a/addons/ShaderLib/RayMarching/SDCylinder.gdshaderinc
+++ /dev/null
@@ -1,37 +0,0 @@
-float sd_cylinder(vec3 point, vec3 cylinder_pos, float height, float radius, vec3 eulers) {
- vec3 orientation = vec3(0, 1, 0);
- orientation.yz *= rm_rotation(eulers.x);
- orientation.xy *= rm_rotation(eulers.z);
- orientation.xz *= rm_rotation(-eulers.y);
-
- vec3 top_point = point + orientation * (height * .5);
- vec3 bottom_point = point - orientation * (height * .5);
-
- vec3 height_vector = bottom_point - top_point;
- vec3 top_distance = cylinder_pos - top_point;
-
- float t = dot(height_vector, top_distance) / dot(height_vector, height_vector);
- vec3 hit_point = top_point + t * height_vector;
-
- float x = length(cylinder_pos - hit_point) - radius;
- float y = (abs(t - .5) - .5) * length(height_vector);
- float e = length(max(vec2(x, y), 0));
- float i = min(max(x, y), 0.);
-
- return e + i;
-}
-
-float ray_march_sd_cylinder(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 cylinder_pos, float cylinder_height, float cylinder_radius, vec3 eulers) {
- ray_dir = normalize(ray_dir);
- dist_threshold = abs(dist_threshold);
- float dist_from_origin = 0.;
- float dist_to_surface;
- for(int i = 0; i < max_steps; i++) {
- vec3 point = ray_origin + dist_from_origin * ray_dir;
- dist_to_surface = sd_cylinder(point, cylinder_pos, cylinder_height, cylinder_radius, eulers);
- dist_from_origin += dist_to_surface;
- if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
- break;
- }
- return dist_from_origin;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/RayMarching/SDSphere.gdshaderinc b/addons/ShaderLib/RayMarching/SDSphere.gdshaderinc
deleted file mode 100644
index 7319423..0000000
--- a/addons/ShaderLib/RayMarching/SDSphere.gdshaderinc
+++ /dev/null
@@ -1,23 +0,0 @@
-float sd_sphere(vec3 point, vec3 eulers, vec3 scale) {
- float radius = 1.;
- point.yz *= rm_rotation(eulers.x);
- point.xy *= rm_rotation(eulers.z);
- point.xz *= rm_rotation(-eulers.y);
- point /= scale;
- return (length(point) - radius) * min(scale.x, min(scale.y, scale.z));
-}
-
-float ray_march_sd_sphere(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 sphere_pos, vec3 eulers, vec3 scale) {
- ray_dir = normalize(ray_dir);
- dist_threshold = abs(dist_threshold);
- float dist_from_origin = 0.;
- float dist_to_surface;
- for(int i = 0; i < max_steps; i++) {
- vec3 point = ray_origin + dist_from_origin * ray_dir;
- dist_to_surface = sd_sphere(point - sphere_pos, eulers, scale);
- dist_from_origin += dist_to_surface;
- if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
- break;
- }
- return dist_from_origin;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/RayMarching/SDTorus.gdshaderinc b/addons/ShaderLib/RayMarching/SDTorus.gdshaderinc
deleted file mode 100644
index 37c9746..0000000
--- a/addons/ShaderLib/RayMarching/SDTorus.gdshaderinc
+++ /dev/null
@@ -1,21 +0,0 @@
-float sd_torus(vec3 point, float small_radius, float big_radius, vec3 eulers) {
- point.yz *= rm_rotation(eulers.x);
- point.xy *= rm_rotation(eulers.z);
- point.xz *= rm_rotation(-eulers.y);
- return length(vec2(length(point.xz) - big_radius, point.y)) - small_radius;
-}
-
-float ray_march_sd_torus(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 torus_pos, vec3 eulers, float small_radius, float big_radius) {
- ray_dir = normalize(ray_dir);
- dist_threshold = abs(dist_threshold);
- float dist_from_origin = 0.;
- float dist_to_surface;
- for(int i = 0; i < max_steps; i++) {
- vec3 point = ray_origin + dist_from_origin * ray_dir;
- dist_to_surface = sd_torus(point - torus_pos, small_radius, big_radius, eulers);
- dist_from_origin += dist_to_surface;
- if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
- break;
- }
- return dist_from_origin;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/RayMarching/SignedDistanceFunctions.gdshaderinc b/addons/ShaderLib/RayMarching/SignedDistanceFunctions.gdshaderinc
new file mode 100644
index 0000000..e8d515c
--- /dev/null
+++ b/addons/ShaderLib/RayMarching/SignedDistanceFunctions.gdshaderinc
@@ -0,0 +1,150 @@
+mat2 rm_rotation(float angle) {
+ angle = -angle * (3.1415926 / 180.);
+ return mat2(
+ vec2(cos(angle), -sin(angle)),
+ vec2(sin(angle), cos(angle))
+ );
+}
+
+float sd_box(vec3 point, vec3 size, vec3 eulers) {
+ point.yz *= rm_rotation(eulers.x);
+ point.xy *= rm_rotation(eulers.z);
+ point.xz *= rm_rotation(-eulers.y);
+ vec3 box_distances = abs(point) - size;
+ float external_dist = length(max(box_distances, 0));
+ float internal_dist = min(max(box_distances.x, max(box_distances.y, box_distances.z)), 0);
+ return external_dist + internal_dist;
+}
+
+float ray_march_sd_box(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 cube_pos, vec3 eulers, vec3 size) {
+ ray_dir = normalize(ray_dir);
+ dist_threshold = abs(dist_threshold);
+ float dist_from_origin = 0.;
+ float dist_to_surface;
+ for(int i = 0; i < max_steps; i++) {
+ vec3 point = ray_origin + dist_from_origin * ray_dir;
+ dist_to_surface = sd_box(point - cube_pos, size, eulers);
+ dist_from_origin += dist_to_surface;
+ if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
+ break;
+ }
+ return dist_from_origin;
+}
+
+float sd_capsule(vec3 point, vec3 capsule_pos, float height, float radius, vec3 eulers) {
+ vec3 orientation = vec3(0, 1, 0);
+ orientation.yz *= rm_rotation(eulers.x);
+ orientation.xy *= rm_rotation(eulers.z);
+ orientation.xz *= rm_rotation(-eulers.y);
+
+ vec3 top_point = point + orientation * (height * .5);
+ vec3 bottom_point = point - orientation * (height * .5);
+
+ vec3 height_vector = bottom_point - top_point;
+ vec3 top_distance = capsule_pos - top_point;
+
+ float t = dot(height_vector, top_distance) / dot(height_vector, height_vector);
+ t = clamp(t, 0., 1.);
+ vec3 hit_point = top_point + t * height_vector;
+
+ return length(capsule_pos - hit_point) - radius;
+}
+
+float ray_march_sd_capsule(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 capsule_pos, float capsule_height, float capsule_radius, vec3 eulers) {
+ ray_dir = normalize(ray_dir);
+ dist_threshold = abs(dist_threshold);
+ float dist_from_origin = 0.;
+ float dist_to_surface;
+ for(int i = 0; i < max_steps; i++) {
+ vec3 point = ray_origin + dist_from_origin * ray_dir;
+ dist_to_surface = sd_capsule(point, capsule_pos, capsule_height, capsule_radius, eulers);
+ dist_from_origin += dist_to_surface;
+ if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
+ break;
+ }
+ return dist_from_origin;
+}
+
+float sd_cylinder(vec3 point, vec3 cylinder_pos, float height, float radius, vec3 eulers) {
+ vec3 orientation = vec3(0, 1, 0);
+ orientation.yz *= rm_rotation(eulers.x);
+ orientation.xy *= rm_rotation(eulers.z);
+ orientation.xz *= rm_rotation(-eulers.y);
+
+ vec3 top_point = point + orientation * (height * .5);
+ vec3 bottom_point = point - orientation * (height * .5);
+
+ vec3 height_vector = bottom_point - top_point;
+ vec3 top_distance = cylinder_pos - top_point;
+
+ float t = dot(height_vector, top_distance) / dot(height_vector, height_vector);
+ vec3 hit_point = top_point + t * height_vector;
+
+ float x = length(cylinder_pos - hit_point) - radius;
+ float y = (abs(t - .5) - .5) * length(height_vector);
+ float e = length(max(vec2(x, y), 0));
+ float i = min(max(x, y), 0.);
+
+ return e + i;
+}
+
+float ray_march_sd_cylinder(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 cylinder_pos, float cylinder_height, float cylinder_radius, vec3 eulers) {
+ ray_dir = normalize(ray_dir);
+ dist_threshold = abs(dist_threshold);
+ float dist_from_origin = 0.;
+ float dist_to_surface;
+ for(int i = 0; i < max_steps; i++) {
+ vec3 point = ray_origin + dist_from_origin * ray_dir;
+ dist_to_surface = sd_cylinder(point, cylinder_pos, cylinder_height, cylinder_radius, eulers);
+ dist_from_origin += dist_to_surface;
+ if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
+ break;
+ }
+ return dist_from_origin;
+}
+
+float sd_sphere(vec3 point, vec3 eulers, vec3 scale) {
+ float radius = 1.;
+ point.yz *= rm_rotation(eulers.x);
+ point.xy *= rm_rotation(eulers.z);
+ point.xz *= rm_rotation(-eulers.y);
+ point /= scale;
+ return (length(point) - radius) * min(scale.x, min(scale.y, scale.z));
+}
+
+float ray_march_sd_sphere(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 sphere_pos, vec3 eulers, vec3 scale) {
+ ray_dir = normalize(ray_dir);
+ dist_threshold = abs(dist_threshold);
+ float dist_from_origin = 0.;
+ float dist_to_surface;
+ for(int i = 0; i < max_steps; i++) {
+ vec3 point = ray_origin + dist_from_origin * ray_dir;
+ dist_to_surface = sd_sphere(point - sphere_pos, eulers, scale);
+ dist_from_origin += dist_to_surface;
+ if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
+ break;
+ }
+ return dist_from_origin;
+}
+
+float sd_torus(vec3 point, float small_radius, float big_radius, vec3 eulers) {
+ point.yz *= rm_rotation(eulers.x);
+ point.xy *= rm_rotation(eulers.z);
+ point.xz *= rm_rotation(-eulers.y);
+ return length(vec2(length(point.xz) - big_radius, point.y)) - small_radius;
+}
+
+float ray_march_sd_torus(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 torus_pos, vec3 eulers, float small_radius, float big_radius) {
+ ray_dir = normalize(ray_dir);
+ dist_threshold = abs(dist_threshold);
+ float dist_from_origin = 0.;
+ float dist_to_surface;
+ for(int i = 0; i < max_steps; i++) {
+ vec3 point = ray_origin + dist_from_origin * ray_dir;
+ dist_to_surface = sd_torus(point - torus_pos, small_radius, big_radius, eulers);
+ dist_from_origin += dist_to_surface;
+ if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
+ break;
+ }
+ return dist_from_origin;
+}
\ No newline at end of file
diff --git a/addons/ShaderLib/UV/FlipbookUV.gd b/addons/ShaderLib/UV/FlipbookUV.gd
index 95c7e6d..a6e2404 100644
--- a/addons/ShaderLib/UV/FlipbookUV.gd
+++ b/addons/ShaderLib/UV/FlipbookUV.gd
@@ -1,9 +1,6 @@
@tool
class_name VisualShaderNodeUVFlipbook extends VisualShaderNodeCustom
-func _init() -> void:
- set_output_port_for_preview(0)
-
func _get_name() -> String:
return "Flipbook"
@@ -60,8 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_2D
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("FlipbookUV.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool:
match mode:
diff --git a/addons/ShaderLib/UV/FlipbookUV.gdshaderinc b/addons/ShaderLib/UV/FlipbookUV.gdshaderinc
deleted file mode 100644
index b323eb7..0000000
--- a/addons/ShaderLib/UV/FlipbookUV.gdshaderinc
+++ /dev/null
@@ -1,16 +0,0 @@
-vec2 flipbook_uv(vec2 uv, int rows, int columns, float anim_speed){
- int start_frame = 1;
- int end_frame = rows * columns;
- start_frame += int(fract(TIME * anim_speed) * float(end_frame));
- float _frame = float(clamp(start_frame, 0, end_frame));
- vec2 _off_per_frame = vec2((1.0 / float(columns)), (1.0 / float(rows)));
- vec2 _sprite_size = vec2(uv.x / float(columns), uv.y / float(rows));
- vec2 _current_sprite = vec2(0.0, 1.0 - _off_per_frame.y);
- _current_sprite.x += _frame * _off_per_frame.x;
- float _row_index;
- float _mod = modf(_frame / float(columns), _row_index);
- _current_sprite.y -= 1.0 - (_row_index * _off_per_frame.y);
- _current_sprite.x -= _row_index * float(columns) * _off_per_frame.x;
- vec2 _sprite_uv = (_sprite_size + _current_sprite);
- return _sprite_uv;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/UV/ParallaxMappingUV.gd b/addons/ShaderLib/UV/ParallaxMappingUV.gd
index 41d7688..50b35bf 100644
--- a/addons/ShaderLib/UV/ParallaxMappingUV.gd
+++ b/addons/ShaderLib/UV/ParallaxMappingUV.gd
@@ -55,8 +55,7 @@ func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool:
return false
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("ParallaxMappingUV.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var height_map: String = input_vars[0]
diff --git a/addons/ShaderLib/UV/ParallaxMappingUV.gdshaderinc b/addons/ShaderLib/UV/ParallaxMappingUV.gdshaderinc
deleted file mode 100644
index 0ba1d89..0000000
--- a/addons/ShaderLib/UV/ParallaxMappingUV.gdshaderinc
+++ /dev/null
@@ -1,17 +0,0 @@
-vec2 parallax_mapping_uv_offset_1_step(float height, float amplitude, vec3 view_dir_tangent)
-{
- height = height * amplitude - amplitude / 2.0;
- vec3 _vector = view_dir_tangent;
- _vector.y += 0.42;
- return height * (_vector.xz / _vector.y);
-}
-
-vec2 parallax_mapping_uv(sampler2D height, float amplitude, vec2 uv, vec3 tangent, vec3 normal, vec3 binormal, vec3 view)
-{
- float depth = amplitude / 10.0;
- mat3 _tangent_matrix = mat3(tangent, normal, -binormal); // VIEW TO TANGENT SPACE
- vec3 _view_tangent = transpose(_tangent_matrix) * view;
- float _parallaxHeight = texture(height, uv).r;
- vec2 _parallaxOffset = parallax_mapping_uv_offset_1_step(_parallaxHeight, depth, _view_tangent);
- return _parallaxOffset + uv;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/UV/RadialShearUV.gd b/addons/ShaderLib/UV/RadialShearUV.gd
index de5fe3b..03a4a01 100644
--- a/addons/ShaderLib/UV/RadialShearUV.gd
+++ b/addons/ShaderLib/UV/RadialShearUV.gd
@@ -1,9 +1,6 @@
@tool
class_name VisualShaderNodeUVRadialShear extends VisualShaderNodeCustom
-func _init() -> void:
- set_output_port_for_preview(0)
-
func _get_name() -> String:
return "RadialShear"
@@ -60,8 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_2D
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("RadialShearUV.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String
diff --git a/addons/ShaderLib/UV/RadialShearUV.gdshaderinc b/addons/ShaderLib/UV/RadialShearUV.gdshaderinc
deleted file mode 100644
index 27b0e66..0000000
--- a/addons/ShaderLib/UV/RadialShearUV.gdshaderinc
+++ /dev/null
@@ -1,6 +0,0 @@
-vec2 radial_shear_uv(vec2 uv, vec2 center, float strength, vec2 offset){
- vec2 _delta = uv - center;
- float _delta2 = dot(_delta.xy, _delta.xy);
- vec2 _delta_offset = vec2(_delta2 * strength);
- return uv + vec2(_delta.y, -_delta.x) * _delta_offset + offset;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/UV/RotateUV.gd b/addons/ShaderLib/UV/RotateUV.gd
index 908ebbe..c3388a6 100644
--- a/addons/ShaderLib/UV/RotateUV.gd
+++ b/addons/ShaderLib/UV/RotateUV.gd
@@ -1,9 +1,6 @@
@tool
class_name VisualShaderNodeUVRotate extends VisualShaderNodeCustom
-func _init() -> void:
- set_output_port_for_preview(0)
-
func _get_name() -> String:
return "Rotate"
@@ -68,8 +65,7 @@ func _get_property_options(index: int) -> PackedStringArray:
return ["Degrees", "Radians"]
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("RotateUV.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String
diff --git a/addons/ShaderLib/UV/RotateUV.gdshaderinc b/addons/ShaderLib/UV/RotateUV.gdshaderinc
deleted file mode 100644
index 3569d18..0000000
--- a/addons/ShaderLib/UV/RotateUV.gdshaderinc
+++ /dev/null
@@ -1,13 +0,0 @@
-vec2 rotate_uv(vec2 uv, vec2 center, float rotation, bool use_degrees){
- float _angle = rotation;
- if(use_degrees){
- _angle = rotation * (3.1415926/180.0);
- }
- mat2 _rotation = mat2(
- vec2(cos(_angle), -sin(_angle)),
- vec2(sin(_angle), cos(_angle))
- );
- vec2 _delta = uv - center;
- _delta = _rotation * _delta;
- return _delta + center;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/UV/SpherizeUV.gd b/addons/ShaderLib/UV/SpherizeUV.gd
index 11f18cd..07e3886 100644
--- a/addons/ShaderLib/UV/SpherizeUV.gd
+++ b/addons/ShaderLib/UV/SpherizeUV.gd
@@ -1,9 +1,6 @@
@tool
class_name VisualShaderNodeUVSpherize extends VisualShaderNodeCustom
-func _init() -> void:
- set_output_port_for_preview(0)
-
func _get_name() -> String:
return "Spherize"
@@ -60,8 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_2D
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("SpherizeUV.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String
diff --git a/addons/ShaderLib/UV/SpherizeUV.gdshaderinc b/addons/ShaderLib/UV/SpherizeUV.gdshaderinc
deleted file mode 100644
index a44e3dd..0000000
--- a/addons/ShaderLib/UV/SpherizeUV.gdshaderinc
+++ /dev/null
@@ -1,7 +0,0 @@
-vec2 spherize_uv(vec2 uv, vec2 center, float strength, vec2 offset){
- vec2 _delta = uv - center;
- float _delta2 = dot(_delta.xy, _delta.xy);
- float _delta4 = _delta2 * _delta2;
- vec2 _delta_offset = vec2(_delta4 * strength);
- return uv + _delta * _delta_offset + offset;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/UV/SwirlUV.gd b/addons/ShaderLib/UV/SwirlUV.gd
index 49f4b4e..354025b 100644
--- a/addons/ShaderLib/UV/SwirlUV.gd
+++ b/addons/ShaderLib/UV/SwirlUV.gd
@@ -1,9 +1,6 @@
@tool
class_name VisualShaderNodeUVSwirl extends VisualShaderNodeCustom
-func _init() -> void:
- output_port_for_preview = 0
-
func _get_name() -> String:
return "Swirl"
@@ -60,8 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_2D
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("SwirlUV.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String
diff --git a/addons/ShaderLib/UV/SwirlUV.gdshaderinc b/addons/ShaderLib/UV/SwirlUV.gdshaderinc
deleted file mode 100644
index e427a7d..0000000
--- a/addons/ShaderLib/UV/SwirlUV.gdshaderinc
+++ /dev/null
@@ -1,10 +0,0 @@
-vec2 swirl_uv(vec2 uv, vec2 center, float strength, vec2 offset){
- vec2 _delta = uv - center;
- float _angle = strength * max(pow(1. - length(_delta), 3), 0);
- mat2 _rotation = mat2(
- vec2(cos(_angle), -sin(_angle)),
- vec2(sin(_angle), cos(_angle))
- );
- _delta = _rotation * _delta;
- return _delta + center;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/UV/TilingAndOffsetUV.gd b/addons/ShaderLib/UV/TilingAndOffsetUV.gd
index de4ae3f..30f7f8b 100644
--- a/addons/ShaderLib/UV/TilingAndOffsetUV.gd
+++ b/addons/ShaderLib/UV/TilingAndOffsetUV.gd
@@ -1,9 +1,6 @@
@tool
class_name VisualShaderNodeUVTilingAndOffset extends VisualShaderNodeCustom
-func _init() -> void:
- output_port_for_preview = 0
-
func _get_name() -> String:
return "TilingAndOffset"
diff --git a/addons/ShaderLib/UV/TwirlUV.gd b/addons/ShaderLib/UV/TwirlUV.gd
index 7832aef..b8d8e53 100644
--- a/addons/ShaderLib/UV/TwirlUV.gd
+++ b/addons/ShaderLib/UV/TwirlUV.gd
@@ -1,9 +1,6 @@
@tool
class_name VisualShaderNodeUVTwirl extends VisualShaderNodeCustom
-func _init() -> void:
- output_port_for_preview = 0
-
func _get_name() -> String:
return "Twirl"
@@ -60,8 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_2D
func _get_global_code(mode: Shader.Mode) -> String:
- var code: String = preload("TwirlUV.gdshaderinc").code
- return code
+ return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String
diff --git a/addons/ShaderLib/UV/TwirlUV.gdshaderinc b/addons/ShaderLib/UV/TwirlUV.gdshaderinc
deleted file mode 100644
index e4f492f..0000000
--- a/addons/ShaderLib/UV/TwirlUV.gdshaderinc
+++ /dev/null
@@ -1,10 +0,0 @@
-vec2 twirl_uv(vec2 uv, vec2 center, float strength, vec2 offset){
- vec2 _delta = uv - center;
- float _angle = strength * length(_delta);
- mat2 _rotation = mat2(
- vec2(cos(_angle), -sin(_angle)),
- vec2(sin(_angle), cos(_angle))
- );
- _delta = _rotation * _delta;
- return _delta + center;
-}
\ No newline at end of file
diff --git a/addons/ShaderLib/UV/UV.gdshaderinc b/addons/ShaderLib/UV/UV.gdshaderinc
new file mode 100644
index 0000000..67ffcf1
--- /dev/null
+++ b/addons/ShaderLib/UV/UV.gdshaderinc
@@ -0,0 +1,85 @@
+vec2 flipbook_uv(vec2 uv, int rows, int columns, float anim_speed){
+ int start_frame = 1;
+ int end_frame = rows * columns;
+ start_frame += int(fract(TIME * anim_speed) * float(end_frame));
+ float _frame = float(clamp(start_frame, 0, end_frame));
+ vec2 _off_per_frame = vec2((1.0 / float(columns)), (1.0 / float(rows)));
+ vec2 _sprite_size = vec2(uv.x / float(columns), uv.y / float(rows));
+ vec2 _current_sprite = vec2(0.0, 1.0 - _off_per_frame.y);
+ _current_sprite.x += _frame * _off_per_frame.x;
+ float _row_index;
+ float _mod = modf(_frame / float(columns), _row_index);
+ _current_sprite.y -= 1.0 - (_row_index * _off_per_frame.y);
+ _current_sprite.x -= _row_index * float(columns) * _off_per_frame.x;
+ vec2 _sprite_uv = (_sprite_size + _current_sprite);
+ return _sprite_uv;
+}
+
+vec2 parallax_mapping_uv_offset_1_step(float height, float amplitude, vec3 view_dir_tangent)
+{
+ height = height * amplitude - amplitude / 2.0;
+ vec3 _vector = view_dir_tangent;
+ _vector.y += 0.42;
+ return height * (_vector.xz / _vector.y);
+}
+
+vec2 parallax_mapping_uv(sampler2D height, float amplitude, vec2 uv, vec3 tangent, vec3 normal, vec3 binormal, vec3 view)
+{
+ float depth = amplitude / 10.0;
+ mat3 _tangent_matrix = mat3(tangent, normal, -binormal); // VIEW TO TANGENT SPACE
+ vec3 _view_tangent = transpose(_tangent_matrix) * view;
+ float _parallaxHeight = texture(height, uv).r;
+ vec2 _parallaxOffset = parallax_mapping_uv_offset_1_step(_parallaxHeight, depth, _view_tangent);
+ return _parallaxOffset + uv;
+}
+
+vec2 radial_shear_uv(vec2 uv, vec2 center, float strength, vec2 offset){
+ vec2 _delta = uv - center;
+ float _delta2 = dot(_delta.xy, _delta.xy);
+ vec2 _delta_offset = vec2(_delta2 * strength);
+ return uv + vec2(_delta.y, -_delta.x) * _delta_offset + offset;
+}
+
+vec2 rotate_uv(vec2 uv, vec2 center, float rotation, bool use_degrees){
+ float _angle = rotation;
+ if(use_degrees){
+ _angle = rotation * (3.1415926/180.0);
+ }
+ mat2 _rotation = mat2(
+ vec2(cos(_angle), -sin(_angle)),
+ vec2(sin(_angle), cos(_angle))
+ );
+ vec2 _delta = uv - center;
+ _delta = _rotation * _delta;
+ return _delta + center;
+}
+
+vec2 spherize_uv(vec2 uv, vec2 center, float strength, vec2 offset){
+ vec2 _delta = uv - center;
+ float _delta2 = dot(_delta.xy, _delta.xy);
+ float _delta4 = _delta2 * _delta2;
+ vec2 _delta_offset = vec2(_delta4 * strength);
+ return uv + _delta * _delta_offset + offset;
+}
+
+vec2 swirl_uv(vec2 uv, vec2 center, float strength, vec2 offset){
+ vec2 _delta = uv - center;
+ float _angle = strength * max(pow(1. - length(_delta), 3), 0);
+ mat2 _rotation = mat2(
+ vec2(cos(_angle), -sin(_angle)),
+ vec2(sin(_angle), cos(_angle))
+ );
+ _delta = _rotation * _delta;
+ return _delta + center;
+}
+
+vec2 twirl_uv(vec2 uv, vec2 center, float strength, vec2 offset){
+ vec2 _delta = uv - center;
+ float _angle = strength * length(_delta);
+ mat2 _rotation = mat2(
+ vec2(cos(_angle), -sin(_angle)),
+ vec2(sin(_angle), cos(_angle))
+ );
+ _delta = _rotation * _delta;
+ return _delta + center;
+}
\ No newline at end of file
diff --git a/documentation/Nodes/Artistic/Adjustment/ContrastNode.md b/documentation/Nodes/Artistic/Adjustment/ContrastNode.md
index 5ee9865..c40733e 100644
--- a/documentation/Nodes/Artistic/Adjustment/ContrastNode.md
+++ b/documentation/Nodes/Artistic/Adjustment/ContrastNode.md
@@ -14,7 +14,7 @@ Adjusts the contrast of input in by the amount of input cont
|out|vec3|None|Output value|
**ShaderInc location**
-
`res://addons/ShaderLib/Artistic/Adjustment/Contrast.gdshaderinc`
+
`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
**Method signature**
`vec3 contrast(input, contrast)`
diff --git a/documentation/Nodes/Artistic/Adjustment/HueNode.md b/documentation/Nodes/Artistic/Adjustment/HueNode.md
index 8d88180..b570e8d 100644
--- a/documentation/Nodes/Artistic/Adjustment/HueNode.md
+++ b/documentation/Nodes/Artistic/Adjustment/HueNode.md
@@ -19,7 +19,7 @@ Offsets the hue of input in by the amount of input offset`res://addons/ShaderLib/Artistic/Adjustment/Hue.gdshaderinc`
+
`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
**Method signature**
`vec3 hue(input, offset, range_index)`
diff --git a/documentation/Nodes/Artistic/Adjustment/ReplaceColorNode.md b/documentation/Nodes/Artistic/Adjustment/ReplaceColorNode.md
index 393ebef..3c7fc08 100644
--- a/documentation/Nodes/Artistic/Adjustment/ReplaceColorNode.md
+++ b/documentation/Nodes/Artistic/Adjustment/ReplaceColorNode.md
@@ -17,7 +17,7 @@ Replaces values in input in equal to input from to t
|out|vec3|None|Output value|
**ShaderInc location**
-
`res://addons/ShaderLib/Artistic/Adjustment/ReplaceColor.gdshaderinc`
+
`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
**Method signature**
`vec3 replace_color(input, from, to, range, fuzziness)`
diff --git a/documentation/Nodes/Artistic/Adjustment/SaturationNode.md b/documentation/Nodes/Artistic/Adjustment/SaturationNode.md
index 7343ef6..8b4e0dc 100644
--- a/documentation/Nodes/Artistic/Adjustment/SaturationNode.md
+++ b/documentation/Nodes/Artistic/Adjustment/SaturationNode.md
@@ -14,7 +14,7 @@ Adjusts the saturation of input in by the amount of input sa
|out|vec3|None|Output value|
**ShaderInc location**
-
`res://addons/ShaderLib/Artistic/Adjustment/Saturation.gdshaderinc`
+
`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
**Method signature**
`vec3 saturation(input, saturation)`
diff --git a/documentation/Nodes/Artistic/Adjustment/WhiteBalanceNode.md b/documentation/Nodes/Artistic/Adjustment/WhiteBalanceNode.md
index 73367cc..31d1630 100644
--- a/documentation/Nodes/Artistic/Adjustment/WhiteBalanceNode.md
+++ b/documentation/Nodes/Artistic/Adjustment/WhiteBalanceNode.md
@@ -15,7 +15,7 @@ Adjusts the temperature and tint of input in by the amount of inpu
|out|vec3|None|Output value|
**ShaderInc location**
-
`res://addons/ShaderLib/Artistic/Adjustment/WhiteBalance.gdshaderinc`
+
`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
**Method signature**
`vec3 white_balance(input, temperature, tint)`
diff --git a/documentation/Nodes/Artistic/Mask/ColorMaskNode.md b/documentation/Nodes/Artistic/Mask/ColorMaskNode.md
index 5b21afa..e9e3651 100644
--- a/documentation/Nodes/Artistic/Mask/ColorMaskNode.md
+++ b/documentation/Nodes/Artistic/Mask/ColorMaskNode.md
@@ -16,7 +16,7 @@ Creates a mask from values in input in equal to input mask c
|out|vec3|None|Output mask value|
**ShaderInc location**
-
`res://addons/ShaderLib/Artistic/Mask/ColorMask.gdshaderinc`
+
`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
**Method signature**
`vec4 color_mask(input, mask_color, range, fuzziness)`
diff --git a/documentation/Nodes/Geometry/Mesh.md b/documentation/Nodes/Geometry/Mesh.md
index 2d702f5..c4f0138 100644
--- a/documentation/Nodes/Geometry/Mesh.md
+++ b/documentation/Nodes/Geometry/Mesh.md
@@ -9,7 +9,7 @@ Provides accees to node's position and scale in world space.
|scale|vec3|None|Node/object scale in world space|
**ShaderInc location**
-
`res://addons/ShaderLib/Geometry/MeshNode.gdshaderinc`
+
`res://addons/ShaderLib/Geometry/Geometry.gdshaderinc`
**Method signature**
`vec3 geometry_node_scale_world(mat4 model_matrix)`
diff --git a/documentation/Nodes/Maths/Scalar/SmoothMax.md b/documentation/Nodes/Maths/Scalar/SmoothMax.md
index 550e437..e42b13f 100644
--- a/documentation/Nodes/Maths/Scalar/SmoothMax.md
+++ b/documentation/Nodes/Maths/Scalar/SmoothMax.md
@@ -15,7 +15,7 @@ Returns the maximum value between A and B, but smooths out the intersections of
|op|float|None|Smooth maximum between A and B|
**ShaderInc location**
-
`res://addons/ShaderLib/Maths/Scalar/SmoothMax.gdshaderinc`
+
`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
`float smoothmax(float a, float b, float t)`
diff --git a/documentation/Nodes/Maths/Scalar/SmoothMin.md b/documentation/Nodes/Maths/Scalar/SmoothMin.md
index 08d6829..13ebc40 100644
--- a/documentation/Nodes/Maths/Scalar/SmoothMin.md
+++ b/documentation/Nodes/Maths/Scalar/SmoothMin.md
@@ -15,7 +15,7 @@ Returns the minimum value between A and B, but smooths out the intersections of
|op|float|None|Smooth minimum between A and B|
**ShaderInc location**
-
`res://addons/ShaderLib/Maths/Scalar/SmoothMin.gdshaderinc`
+
`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
`float smoothmin(float a, float b, float t)`
diff --git a/documentation/Nodes/Maths/Vector/Distance/ChebyshevDistance.md b/documentation/Nodes/Maths/Vector/Distance/ChebyshevDistance.md
index 8da8ff2..af75df9 100644
--- a/documentation/Nodes/Maths/Vector/Distance/ChebyshevDistance.md
+++ b/documentation/Nodes/Maths/Vector/Distance/ChebyshevDistance.md
@@ -20,8 +20,7 @@ Returns the distance between two points using Chebyshev distance matrix.
|distance|float|None|Distance between 2 points|
**ShaderInc location**
-
For 2D - `res://addons/ShaderLib/Maths/Vector/Distance/Chebyshev2D.gdshaderinc`
-
For 3D - `res://addons/ShaderLib/Maths/Vector/Distance/Chebyshev3D.gdshaderinc`
+
`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
For 2D - `float chebyshev_distance_2d(vec2 point1, vec2 point2, float power)`
diff --git a/documentation/Nodes/Maths/Vector/Distance/ManhattanDistance.md b/documentation/Nodes/Maths/Vector/Distance/ManhattanDistance.md
index 245a61c..0d85b73 100644
--- a/documentation/Nodes/Maths/Vector/Distance/ManhattanDistance.md
+++ b/documentation/Nodes/Maths/Vector/Distance/ManhattanDistance.md
@@ -19,8 +19,7 @@ Returns the distance between two points using Manhattan distance matrix.
|distance|float|None|Distance between 2 points|
**ShaderInc location**
-
For 2D - `res://addons/ShaderLib/Maths/Vector/Distance/Manhattan2D.gdshaderinc`
-
For 3D - `res://addons/ShaderLib/Maths/Vector/Distance/Manhattan3D.gdshaderinc`
+
`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
For 2D - `float manhattan_distance_2d(vec2 point1, vec2 point2)`
diff --git a/documentation/Nodes/Maths/Vector/Project.md b/documentation/Nodes/Maths/Vector/Project.md
index f06413b..fd6aafb 100644
--- a/documentation/Nodes/Maths/Vector/Project.md
+++ b/documentation/Nodes/Maths/Vector/Project.md
@@ -19,7 +19,7 @@ Projects vector A onto vector B.
|vector|vector3|None|Output vector|
**ShaderInc location**
-
`res://addons/ShaderLib/Maths/Vector/Project.gdshaderinc`
+
`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
`vec2 project_2d(vec2 a, vec2 b)`
diff --git a/documentation/Nodes/Maths/Vector/ProjectOnPlane.md b/documentation/Nodes/Maths/Vector/ProjectOnPlane.md
index e5442fc..52aa884 100644
--- a/documentation/Nodes/Maths/Vector/ProjectOnPlane.md
+++ b/documentation/Nodes/Maths/Vector/ProjectOnPlane.md
@@ -14,7 +14,7 @@ Projects a vector onto a plane defined by a normal orthogonal to the plane.
|vector|vector3|None|Output vector|
**ShaderInc location**
-
`res://addons/ShaderLib/Maths/Vector/ProjectOnPlane.gdshaderinc`
+
`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
`vec3 project_on_plane(vec3 vector, vec3 plane_normal)`
diff --git a/documentation/Nodes/Maths/Wave/NoiseSineWave.md b/documentation/Nodes/Maths/Wave/NoiseSineWave.md
index 0199d13..88b6a6a 100644
--- a/documentation/Nodes/Maths/Wave/NoiseSineWave.md
+++ b/documentation/Nodes/Maths/Wave/NoiseSineWave.md
@@ -19,7 +19,7 @@ Returns the sine of the value of input in. For variance, psuedo-ra
|out|Dynamic vector|None|Output value|
**ShaderInc location**
-
`res://addons/ShaderLib/Maths/Wave/NoiseSineWave.gdshaderinc`
+
`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
`vec4 noise_sine_wave(vec4 input, vec2 min_max)`
diff --git a/documentation/Nodes/Maths/Wave/SawtoothWave.md b/documentation/Nodes/Maths/Wave/SawtoothWave.md
index 424c8f1..0a82040 100644
--- a/documentation/Nodes/Maths/Wave/SawtoothWave.md
+++ b/documentation/Nodes/Maths/Wave/SawtoothWave.md
@@ -18,7 +18,7 @@ Returns a sawtooth wave from the value of input in. Resulting outp
|out|Dynamic vector|None|Output value|
**ShaderInc location**
-
`res://addons/ShaderLib/Maths/Wave/SawtoothWave.gdshaderinc`
+
`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
`vec4 sawtooth_wave(vec4 input)`
diff --git a/documentation/Nodes/Maths/Wave/SquareWave.md b/documentation/Nodes/Maths/Wave/SquareWave.md
index 822243c..6c0c98d 100644
--- a/documentation/Nodes/Maths/Wave/SquareWave.md
+++ b/documentation/Nodes/Maths/Wave/SquareWave.md
@@ -18,7 +18,7 @@ Returns a square wave from the value of input in. Resulting output
|out|Dynamic vector|None|Output value|
**ShaderInc location**
-
`res://addons/ShaderLib/Maths/Wave/SquareWave.gdshaderinc`
+
`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
`vec4 square _wave(vec4 input)`
diff --git a/documentation/Nodes/Maths/Wave/TriangleWave.md b/documentation/Nodes/Maths/Wave/TriangleWave.md
index 70740e0..07f985e 100644
--- a/documentation/Nodes/Maths/Wave/TriangleWave.md
+++ b/documentation/Nodes/Maths/Wave/TriangleWave.md
@@ -18,7 +18,7 @@ Returns a triangle wave from the value of input in. Resulting outp
|out|Dynamic vector|None|Output value|
**ShaderInc location**
-
`res://addons/ShaderLib/Maths/Wave/TriangleWave.gdshaderinc`
+
`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
`vec4 triangle_wave(vec4 input)`
diff --git a/documentation/Nodes/Procedural/CheckerBoard.md b/documentation/Nodes/Procedural/CheckerBoard.md
index fc7b6ea..b0dfa02 100644
--- a/documentation/Nodes/Procedural/CheckerBoard.md
+++ b/documentation/Nodes/Procedural/CheckerBoard.md
@@ -16,7 +16,7 @@ Generates a checkerboard of alternating colors between inputs color A<
|output|vec3|None|Output checkerboard value|
**ShaderInc location**
-
`res://addons/ShaderLib/Procedural/CheckerBoard.gdshaderinc`
+
`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
`vec3 checker_board(vec2 uv, vec3 color_a, vec3 color_b, vec2 frequency)`
diff --git a/documentation/Nodes/Procedural/Fractals/KochFractal.md b/documentation/Nodes/Procedural/Fractals/KochFractal.md
index 3148133..d23ceb6 100644
--- a/documentation/Nodes/Procedural/Fractals/KochFractal.md
+++ b/documentation/Nodes/Procedural/Fractals/KochFractal.md
@@ -18,7 +18,7 @@ Generates an koch curve similar to ice fractal shape based on input UV at the si
|uv|vec2|None|Output UV value|
**ShaderInc location**
-
`res://addons/ShaderLib/Procedural/Fractals/KochFractal.gdshaderinc`
+
`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
`float koch_fractal(vec2 uv, float outline, int iteration, float shape_width, float shape_height, out vec2 koch_uv)`
diff --git a/documentation/Nodes/Procedural/Noise/GradientNoise.md b/documentation/Nodes/Procedural/Noise/GradientNoise.md
index 393af87..9f1c436 100644
--- a/documentation/Nodes/Procedural/Noise/GradientNoise.md
+++ b/documentation/Nodes/Procedural/Noise/GradientNoise.md
@@ -14,7 +14,7 @@ Generates a gradient, or Perlin noise based on input UV. The resulting out
|output|float|None|Output noise value|
**ShaderInc location**
-
`res://addons/ShaderLib/Procedural/Noise/GradientNoise.gdshaderinc`
+
`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
`float gradient_noise(vec2 uv, float scale)`
diff --git a/documentation/Nodes/Procedural/Noise/GyroidNoise.md b/documentation/Nodes/Procedural/Noise/GyroidNoise.md
index 4f81839..5ec8ab7 100644
--- a/documentation/Nodes/Procedural/Noise/GyroidNoise.md
+++ b/documentation/Nodes/Procedural/Noise/GyroidNoise.md
@@ -17,7 +17,7 @@ Generates a gyroid noise based on input UV. The resulting output v
|output|float|None|Output noise value|
**ShaderInc location**
-
`res://addons/ShaderLib/Procedural/Noise/GyroidNoise.gdshaderinc`
+
`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
`float gyroid_noise(vec2 uv, float scale, vec2 ratio, float height, float thickness)`
diff --git a/documentation/Nodes/Procedural/Noise/PseudoRandomNoise.md b/documentation/Nodes/Procedural/Noise/PseudoRandomNoise.md
index 85ca577..345c760 100644
--- a/documentation/Nodes/Procedural/Noise/PseudoRandomNoise.md
+++ b/documentation/Nodes/Procedural/Noise/PseudoRandomNoise.md
@@ -11,4 +11,16 @@ Generates a pseudo random noise based on input seed. The resulting output<
|Name|Type|Binding|Description|
|---|---|---|---|
|output|float|None|Output noise value|
+
+**ShaderInc location**
+
`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
+
+**Method signature**
+
`float pseudo_random_noise(vec2 uv, float seed)`
+
+**Parameters**
+|Name|Type|Description|
+|---|---|---|
+|uv|vec2|Input UV value|
+|seed|float|Noise seed|
___
\ No newline at end of file
diff --git a/documentation/Nodes/Procedural/Noise/SimpleNoise.md b/documentation/Nodes/Procedural/Noise/SimpleNoise.md
index 40d7d3e..472ba71 100644
--- a/documentation/Nodes/Procedural/Noise/SimpleNoise.md
+++ b/documentation/Nodes/Procedural/Noise/SimpleNoise.md
@@ -15,7 +15,7 @@ Generates a simplex, or value noise based on input UV. The resulting outpu
|output|float|None|Output noise value|
**ShaderInc location**
-
`res://addons/ShaderLib/Procedural/Noise/SimpleNoise.gdshaderinc`
+
`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
`float simple_noise(vec2 uv, float scale, int octaves)`
diff --git a/documentation/Nodes/Procedural/Noise/Voronoi.md b/documentation/Nodes/Procedural/Noise/Voronoi.md
index 4cedceb..9099384 100644
--- a/documentation/Nodes/Procedural/Noise/Voronoi.md
+++ b/documentation/Nodes/Procedural/Noise/Voronoi.md
@@ -22,7 +22,7 @@ Generates a Voronoi or Worley noise based on input UV. Voronoi noise is generate
|cells|float|None|Raw cell data|
**ShaderInc location**
-
`res://addons/ShaderLib/Procedural/Noise/Voronoi.gdshaderinc`
+
`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
`void voronoi_noise(vec2 uv, float cell_density, float angle_offset, int distance_index, float chebyshev_power, out float output, out float cells)`
diff --git a/documentation/Nodes/Procedural/Shapes/Ellipse.md b/documentation/Nodes/Procedural/Shapes/Ellipse.md
index 27abcb9..ce3b8e4 100644
--- a/documentation/Nodes/Procedural/Shapes/Ellipse.md
+++ b/documentation/Nodes/Procedural/Shapes/Ellipse.md
@@ -15,7 +15,7 @@ Generates an ellipse shape based on input UV at the size specified by inputs
|output|float|None|Output ellipse value|
**ShaderInc location**
-
`res://addons/ShaderLib/Procedural/Shapes/Ellipse.gdshaderinc`
+
`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
`float ellipse_shape(vec2 uv, float width, float height)`
diff --git a/documentation/Nodes/Procedural/Shapes/Polygon.md b/documentation/Nodes/Procedural/Shapes/Polygon.md
index 97435f4..cb271ba 100644
--- a/documentation/Nodes/Procedural/Shapes/Polygon.md
+++ b/documentation/Nodes/Procedural/Shapes/Polygon.md
@@ -16,7 +16,7 @@ Generates a regular polygon shape based on input UV at the size specified by inp
|output|float|None|Output polygon value|
**ShaderInc location**
-
`res://addons/ShaderLib/Procedural/Shapes/Polygon.gdshaderinc`
+
`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
`float polygon_shape(vec2 uv, int sides, float width, float height)`
diff --git a/documentation/Nodes/Procedural/Shapes/Rectangle.md b/documentation/Nodes/Procedural/Shapes/Rectangle.md
index d6d6312..d8231a6 100644
--- a/documentation/Nodes/Procedural/Shapes/Rectangle.md
+++ b/documentation/Nodes/Procedural/Shapes/Rectangle.md
@@ -15,7 +15,7 @@ Generates a rectangle shape based on input UV at the size specified by inputs `res://addons/ShaderLib/Procedural/Shapes/Rectangle.gdshaderinc`
+
`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
`float rectangle_shape(vec2 uv, float width, float height)`
diff --git a/documentation/Nodes/Procedural/Shapes/RoundedPolygon.md b/documentation/Nodes/Procedural/Shapes/RoundedPolygon.md
index 3049728..793e8d8 100644
--- a/documentation/Nodes/Procedural/Shapes/RoundedPolygon.md
+++ b/documentation/Nodes/Procedural/Shapes/RoundedPolygon.md
@@ -17,7 +17,7 @@ Generates a rounded polygon shape based on input UV at the size specified by inp
|output|float|None|Output rounded polygon value|
**ShaderInc location**
-
`res://addons/ShaderLib/Procedural/Shapes/RoundedPolygon.gdshaderinc`
+
`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
`float rounded_polygon_shape(vec2 uv, float width, float height, float sides, float roundness)`
diff --git a/documentation/Nodes/Procedural/Shapes/RoundedRectangle.md b/documentation/Nodes/Procedural/Shapes/RoundedRectangle.md
index 119664f..e1c0409 100644
--- a/documentation/Nodes/Procedural/Shapes/RoundedRectangle.md
+++ b/documentation/Nodes/Procedural/Shapes/RoundedRectangle.md
@@ -16,7 +16,7 @@ Generates a rounded rectangle shape based on input UV at the size specified by i
|output|float|None|Output rounded rectangle value|
**ShaderInc location**
-
`res://addons/ShaderLib/Procedural/Shapes/RoundedRectangle.gdshaderinc`
+
`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
`float rounded_rectangle_shape(vec2 uv, float width, float height, float radius)`
diff --git a/documentation/Nodes/RayMarching/RayMarch.md b/documentation/Nodes/RayMarching/RayMarch.md
index 42f243e..1d58ae9 100644
--- a/documentation/Nodes/RayMarching/RayMarch.md
+++ b/documentation/Nodes/RayMarching/RayMarch.md
@@ -46,12 +46,12 @@ A simple ray marcher for primitive shapes.
Extras
-This node is only simple ray marching example, the true power of raymarching can only be achieved by custom SDFs. At the moment I am unable to inject the custom code via visual shaders, so I have provided the custom template at the following location.
+This node is only simple ray marching example, the true power of raymarching can only be achieved by custom SDFs. At the moment I am unable to inject the custom code via visual shaders, so I have provided the custom template at the following location. If you want to know more about raymarching check out this playlist.
The default location can be found at
-`res://addons/ShaderLib/RayMarching/RayMarchCustom.gdshaderinc`
+`res://addons/ShaderLib/RayMarching/RayMarchCustomTemplate.gdshaderinc`
-You can copy the code from `RayMarchCustom.gdshaderinc` and then create a Global Expression node and paste it in your visual shader.
+You can copy the code from `RayMarchCustomTemplate.gdshaderinc` and then create a Global Expression node and paste it in your visual shader.
![Global Expression Node](GlobalExpression.jpg)
Lastly you also need to create an Expression node, define required input and output parameters and call the custom ray marching function as below.
![Expression Node](Expression.jpg)
diff --git a/documentation/Nodes/UV/Flipbook.md b/documentation/Nodes/UV/Flipbook.md
index 112f984..3418afc 100644
--- a/documentation/Nodes/UV/Flipbook.md
+++ b/documentation/Nodes/UV/Flipbook.md
@@ -17,7 +17,7 @@ This node can be used to create a texture animation functionality, commonly used
|uv|vec2|None|Output UV value|
**ShaderInc location**
-
`res://addons/ShaderLib/UV/FlipbookUV.gdshaderinc`
+
`res://addons/ShaderLib/UV/UV.gdshaderinc`
**Method signature**
`vec2 flipbook_uv(vec2 uv, int rows, int columns, float anim_speed)`
diff --git a/documentation/Nodes/UV/ParallaxMapping.md b/documentation/Nodes/UV/ParallaxMapping.md
index dee1ed2..ccb4109 100644
--- a/documentation/Nodes/UV/ParallaxMapping.md
+++ b/documentation/Nodes/UV/ParallaxMapping.md
@@ -14,7 +14,7 @@ The Parallax Mapping node lets you create a parallax effect that displaces a Mat
|uv|vec2|None|Output UV value|
**ShaderInc location**
-
`res://addons/ShaderLib/UV/ParallaxMappingUV.gdshaderinc`
+
`res://addons/ShaderLib/UV/UV.gdshaderinc`
**Method signature**
`vec2 parallax_mapping_uv(sampler2D height, float amplitude, vec2 uv, vec3 tangent, vec3 normal, vec3 binormal, vec3 view)`
diff --git a/documentation/Nodes/UV/RadialShear.md b/documentation/Nodes/UV/RadialShear.md
index dd5724d..53ac490 100644
--- a/documentation/Nodes/UV/RadialShear.md
+++ b/documentation/Nodes/UV/RadialShear.md
@@ -16,7 +16,7 @@ Applies a radial shear warping effect similar to a wave to the value of input UV
|uv|vec2|None|Output UV value|
**ShaderInc location**
-
`res://addons/ShaderLib/UV/RadialShearUV.gdshaderinc`
+
`res://addons/ShaderLib/UV/UV.gdshaderinc`
**Method signature**
`vec2 radial_shear_uv(vec2 uv, vec2 center, float strength, vec2 offset)`
diff --git a/documentation/Nodes/UV/Rotate.md b/documentation/Nodes/UV/Rotate.md
index 053c2e8..199d92c 100644
--- a/documentation/Nodes/UV/Rotate.md
+++ b/documentation/Nodes/UV/Rotate.md
@@ -20,7 +20,7 @@ Rotates value of input UV around a reference point defined by input center
|uv|vec2|None|Output UV value|
**ShaderInc location**
-
`res://addons/ShaderLib/UV/RotateUV.gdshaderinc`
+
`res://addons/ShaderLib/UV/UV.gdshaderinc`
**Method signature**
`vec2 rotate_uv(vec2 uv, vec2 center, float rotation, bool use_degrees)`
diff --git a/documentation/Nodes/UV/Spherize.md b/documentation/Nodes/UV/Spherize.md
index 087366e..df3a275 100644
--- a/documentation/Nodes/UV/Spherize.md
+++ b/documentation/Nodes/UV/Spherize.md
@@ -16,7 +16,7 @@ Applies a spherical warping effect similar to a fisheye camera lens to the value
|uv|vec2|None|Output UV value|
**ShaderInc location**
-
`res://addons/ShaderLib/UV/SpherizeUV.gdshaderinc`
+
`res://addons/ShaderLib/UV/UV.gdshaderinc`
**Method signature**
`vec2 spherize_uv(vec2 uv, vec2 center, float strength, vec2 offset)`
diff --git a/documentation/Nodes/UV/Swirl.md b/documentation/Nodes/UV/Swirl.md
index b7df4b5..df33d44 100644
--- a/documentation/Nodes/UV/Swirl.md
+++ b/documentation/Nodes/UV/Swirl.md
@@ -16,7 +16,7 @@ Applies a swirl warping effect similar to a black hole to the value of input UV.
|uv|vec2|None|Output UV value|
**ShaderInc location**
-
`res://addons/ShaderLib/UV/SwirlUV.gdshaderinc`
+
`res://addons/ShaderLib/UV/UV.gdshaderinc`
**Method signature**
`vec2 swirl_uv(vec2 uv, vec2 center, float strength, vec2 offset)`
diff --git a/documentation/Nodes/UV/Twirl.md b/documentation/Nodes/UV/Twirl.md
index bf0ec5c..2100bbe 100644
--- a/documentation/Nodes/UV/Twirl.md
+++ b/documentation/Nodes/UV/Twirl.md
@@ -16,7 +16,7 @@ Applies a twirl warping effect similar to a black hole to the value of input UV.
|uv|vec2|None|Output UV value|
**ShaderInc location**
-
`res://addons/ShaderLib/UV/TwirlUV.gdshaderinc`
+
`res://addons/ShaderLib/UV/UV.gdshaderinc`
**Method signature**
`vec2 twirl_uv(vec2 uv, vec2 center, float strength, vec2 offset)`