From fb19605155c52cccae18edd03b9c9883024dac80 Mon Sep 17 00:00:00 2001 From: Digvijaysinh Gohil Date: Fri, 27 Sep 2024 23:58:41 +0530 Subject: [PATCH 1/4] HeightToNormal Node added for feature request #5 --- addons/ShaderLib/Procedural/HeightToNormal.gd | 65 +++++++++++++++++++ .../Procedural/Procedural.gdshaderinc | 15 +++++ project.godot | 2 +- 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 addons/ShaderLib/Procedural/HeightToNormal.gd diff --git a/addons/ShaderLib/Procedural/HeightToNormal.gd b/addons/ShaderLib/Procedural/HeightToNormal.gd new file mode 100644 index 0000000..e7d13cb --- /dev/null +++ b/addons/ShaderLib/Procedural/HeightToNormal.gd @@ -0,0 +1,65 @@ +@tool +class_name VisualShaderNodeProceduralHeightToNormal extends VisualShaderNodeCustom + +func _get_name() -> String: + return "HeightToNormal" + +func _get_category() -> String: + return "Procedural" + +func _get_description() -> String: + return "Generates a normal map from a height map." + +func _get_return_icon_type() -> PortType: + return PORT_TYPE_VECTOR_3D + +func _get_input_port_count() -> int: + return 3 + +func _get_input_port_name(port: int) -> String: + match port: + 0: + return "height map" + 1: + return "uv" + 2: + return "bump strength" + return "" + +func _get_input_port_type(port: int) -> PortType: + match port: + 0: + return PORT_TYPE_SAMPLER + 1: + return PORT_TYPE_VECTOR_2D + _: + return PORT_TYPE_SCALAR + +func _get_input_port_default_value(port: int) -> Variant: + match port: + 2: + return 8.0 + _: + return null + +func _get_output_port_count() -> int: + return 1 + +func _get_output_port_name(port: int) -> String: + return "normal" + +func _get_output_port_type(port: int) -> PortType: + return PORT_TYPE_VECTOR_3D + +func _get_global_code(mode: Shader.Mode) -> String: + 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" + if input_vars[1]: + uv = input_vars[1] + + var sampler: String = input_vars[0] + var bump: String = input_vars[2] + + return output_vars[0] + " = heigth_to_normal(%s, %s, %s);" % [sampler, uv, bump] diff --git a/addons/ShaderLib/Procedural/Procedural.gdshaderinc b/addons/ShaderLib/Procedural/Procedural.gdshaderinc index 9b4b7ca..594a9ae 100644 --- a/addons/ShaderLib/Procedural/Procedural.gdshaderinc +++ b/addons/ShaderLib/Procedural/Procedural.gdshaderinc @@ -229,4 +229,19 @@ float rounded_rectangle_shape(vec2 uv, float width, float height, float radius){ uv = abs(uv * 2.0 - 1.0) - vec2(width, height) + radius; float dist = length(max(vec2(0.0), uv)) / radius; return clamp((1.0 - dist) / fwidth(dist), 0.0, 1.0); +} + +vec3 heigth_to_normal(sampler2D height_map, vec2 uv, float bump_strength) { + float pixel_width = .002; + float height = texture(height_map, uv).r; + float r = height - texture(height_map, uv + vec2(pixel_width, 0)).r; + float l = height - texture(height_map, uv - vec2(pixel_width, 0)).r; + float u = height - texture(height_map, uv + vec2(0, pixel_width)).r; + float d = height - texture(height_map, uv - vec2(0, pixel_width)).r; + float h = (r - l) / pixel_width; + float v = (u - d) / pixel_width; + vec3 n = vec3(h, v, 1.); + n.x = n.x * (pixel_width * bump_strength * .5) + .5; + n.y = n.y * (pixel_width * bump_strength * .5) + .5; + return normalize(n); } \ No newline at end of file diff --git a/project.godot b/project.godot index 32979cd..245a2ff 100644 --- a/project.godot +++ b/project.godot @@ -12,5 +12,5 @@ config_version=5 config/name="Godot-shader-lib" config/tags=PackedStringArray("addons") -config/features=PackedStringArray("4.2", "Forward Plus") +config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://icons/icon.png" From 199f4a772ad878b45784282d87573c318cb6b46c Mon Sep 17 00:00:00 2001 From: Digvijaysinh Gohil Date: Sat, 28 Sep 2024 00:07:16 +0530 Subject: [PATCH 2/4] HeightToNormal node documentation added --- documentation/Documentation.md | 1 + .../Nodes/Procedural/HeightToNormal.md | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 documentation/Nodes/Procedural/HeightToNormal.md diff --git a/documentation/Documentation.md b/documentation/Documentation.md index b55c4c3..dbebbf4 100644 --- a/documentation/Documentation.md +++ b/documentation/Documentation.md @@ -56,6 +56,7 @@ For example if you want to rotate UV in your **_.gdshader_** file, you can use `

Procedural nodes

 Checker Board node

+

 Height To Normal node

 Fractals

diff --git a/documentation/Nodes/Procedural/HeightToNormal.md b/documentation/Nodes/Procedural/HeightToNormal.md new file mode 100644 index 0000000..b56e63d --- /dev/null +++ b/documentation/Nodes/Procedural/HeightToNormal.md @@ -0,0 +1,29 @@ +# Height To Normal node +Generates a normal map from a height map. +
+ +**Inputs** +|Name|Type|Binding|Description| +|---|---|---|---| +|height map|sampler2D|none|Height map| +|uv|vec2|UV|Input UV value| +|bump strength|float|none|Bump strength for the height| + +**Outputs** +|Name|Type|Binding|Description| +|---|---|---|---| +|Normal|vec3|None|Normal map| + +**ShaderInc location** +
`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc` + +**Method signature** +
`vec3 heigth_to_normal(sampler2D height_map, vec2 uv, float bump_strength)` + +**Parameters** +|Name|Type|Description| +|---|---|---| +|height_map|sampler2D|Height map| +|uv|vec2|Input UV value| +|bump_strength|float|Bump strength for the height| +___ \ No newline at end of file From a98305fa5feae5de34f3f09e9dccfc691c86fd5a Mon Sep 17 00:00:00 2001 From: Digvijaysinh Gohil Date: Sat, 28 Sep 2024 00:45:16 +0530 Subject: [PATCH 3/4] Code refactored to incorporate #6 --- .../Artistic/Adjustment/Contrast.gd | 4 ++-- .../Artistic/Adjustment/Hue.gd | 4 ++-- .../Artistic/Adjustment/ReplaceColor.gd | 4 ++-- .../Artistic/Adjustment/Saturation.gd | 4 ++-- .../Artistic/Adjustment/WhiteBalance.gd | 4 ++-- .../Artistic/Artistic.gdshaderinc | 0 .../Artistic/Mask/ColorMask.gd | 4 ++-- .../Geometry/Geometry.gdshaderinc | 0 addons/{ShaderLib => ShaderLib_v2_2_4}/Geometry/MeshNode.gd | 4 ++-- addons/{ShaderLib => ShaderLib_v2_2_4}/LICENSE | 0 .../{ShaderLib => ShaderLib_v2_2_4}/Maths/Maths.gdshaderinc | 0 .../Maths/Scalar/SmoothMax.gd | 4 ++-- .../Maths/Scalar/SmoothMin.gd | 4 ++-- .../Maths/Vector/Distance/ChebyshevDistance.gd | 5 ++--- .../Maths/Vector/Distance/ManhattanDistance.gd | 5 ++--- .../{ShaderLib => ShaderLib_v2_2_4}/Maths/Vector/Project.gd | 4 ++-- .../Maths/Vector/ProjectOnPlane.gd | 4 ++-- .../Maths/Vector/VectorTransform.gd | 4 ++-- .../Maths/Wave/NoiseSineWave.gd | 4 ++-- .../Maths/Wave/SawtoothWave.gd | 4 ++-- .../{ShaderLib => ShaderLib_v2_2_4}/Maths/Wave/SquareWave.gd | 4 ++-- .../Maths/Wave/TriangleWave.gd | 4 ++-- .../Procedural/CheckerBoard.gd | 4 ++-- .../Procedural/Fractals/KochFractal.gd | 5 ++--- .../Procedural/HeightToNormal.gd | 4 ++-- .../Procedural/Noise/GradientNoise.gd | 4 ++-- .../Procedural/Noise/GyroidNoise.gd | 4 ++-- .../Procedural/Noise/PseudoRandomNoise.gd | 5 ++++- .../Procedural/Noise/SimpleNoise.gd | 4 ++-- .../Procedural/Noise/Voronoi.gd | 4 ++-- .../Procedural/Procedural.gdshaderinc | 2 +- .../Procedural/Shapes/Ellipse.gd | 4 ++-- .../Procedural/Shapes/Polygon.gd | 4 ++-- .../Procedural/Shapes/Rectangle.gd | 4 ++-- .../Procedural/Shapes/RoundedPolygon.gd | 4 ++-- .../Procedural/Shapes/RoundedRectangle.gd | 4 ++-- .../{ShaderLib => ShaderLib_v2_2_4}/RayMarching/RayMarch.gd | 5 ++--- .../RayMarching/RayMarchCustomTemplate.gdshaderinc | 0 .../RayMarching/SignedDistanceFunctions.gdshaderinc | 0 addons/ShaderLib_v2_2_4/ShaderLib.gd | 3 +++ addons/{ShaderLib => ShaderLib_v2_2_4}/UV/FlipbookUV.gd | 4 ++-- .../{ShaderLib => ShaderLib_v2_2_4}/UV/ParallaxMappingUV.gd | 4 ++-- addons/{ShaderLib => ShaderLib_v2_2_4}/UV/RadialShearUV.gd | 4 ++-- addons/{ShaderLib => ShaderLib_v2_2_4}/UV/RotateUV.gd | 4 ++-- addons/{ShaderLib => ShaderLib_v2_2_4}/UV/SpherizeUV.gd | 4 ++-- addons/{ShaderLib => ShaderLib_v2_2_4}/UV/SwirlUV.gd | 4 ++-- .../{ShaderLib => ShaderLib_v2_2_4}/UV/TilingAndOffsetUV.gd | 2 +- addons/{ShaderLib => ShaderLib_v2_2_4}/UV/TwirlUV.gd | 4 ++-- addons/{ShaderLib => ShaderLib_v2_2_4}/UV/UV.gdshaderinc | 0 49 files changed, 85 insertions(+), 83 deletions(-) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Artistic/Adjustment/Contrast.gd (89%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Artistic/Adjustment/Hue.gd (91%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Artistic/Adjustment/ReplaceColor.gd (91%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Artistic/Adjustment/Saturation.gd (89%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Artistic/Adjustment/WhiteBalance.gd (90%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Artistic/Artistic.gdshaderinc (100%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Artistic/Mask/ColorMask.gd (90%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Geometry/Geometry.gdshaderinc (100%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Geometry/MeshNode.gd (88%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/LICENSE (100%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Maths/Maths.gdshaderinc (100%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Maths/Scalar/SmoothMax.gd (89%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Maths/Scalar/SmoothMin.gd (89%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Maths/Vector/Distance/ChebyshevDistance.gd (93%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Maths/Vector/Distance/ManhattanDistance.gd (92%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Maths/Vector/Project.gd (92%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Maths/Vector/ProjectOnPlane.gd (87%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Maths/Vector/VectorTransform.gd (97%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Maths/Wave/NoiseSineWave.gd (94%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Maths/Wave/SawtoothWave.gd (93%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Maths/Wave/SquareWave.gd (94%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Maths/Wave/TriangleWave.gd (93%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/CheckerBoard.gd (91%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/Fractals/KochFractal.gd (91%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/HeightToNormal.gd (89%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/Noise/GradientNoise.gd (89%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/Noise/GyroidNoise.gd (90%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/Noise/PseudoRandomNoise.gd (83%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/Noise/SimpleNoise.gd (89%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/Noise/Voronoi.gd (94%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/Procedural.gdshaderinc (99%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/Shapes/Ellipse.gd (90%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/Shapes/Polygon.gd (91%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/Shapes/Rectangle.gd (90%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/Shapes/RoundedPolygon.gd (91%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/Procedural/Shapes/RoundedRectangle.gd (90%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/RayMarching/RayMarch.gd (97%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/RayMarching/RayMarchCustomTemplate.gdshaderinc (100%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/RayMarching/SignedDistanceFunctions.gdshaderinc (100%) create mode 100644 addons/ShaderLib_v2_2_4/ShaderLib.gd rename addons/{ShaderLib => ShaderLib_v2_2_4}/UV/FlipbookUV.gd (92%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/UV/ParallaxMappingUV.gd (91%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/UV/RadialShearUV.gd (92%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/UV/RotateUV.gd (93%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/UV/SpherizeUV.gd (92%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/UV/SwirlUV.gd (92%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/UV/TilingAndOffsetUV.gd (95%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/UV/TwirlUV.gd (92%) rename addons/{ShaderLib => ShaderLib_v2_2_4}/UV/UV.gdshaderinc (100%) diff --git a/addons/ShaderLib/Artistic/Adjustment/Contrast.gd b/addons/ShaderLib_v2_2_4/Artistic/Adjustment/Contrast.gd similarity index 89% rename from addons/ShaderLib/Artistic/Adjustment/Contrast.gd rename to addons/ShaderLib_v2_2_4/Artistic/Adjustment/Contrast.gd index 1062590..cd01633 100644 --- a/addons/ShaderLib/Artistic/Adjustment/Contrast.gd +++ b/addons/ShaderLib_v2_2_4/Artistic/Adjustment/Contrast.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeAdjustmentContrast extends VisualShaderNodeCustom +class_name VisualShaderNodeAdjustmentContrast extends ShaderLib func _get_name() -> String: return "Contrast" @@ -47,7 +47,7 @@ func _get_output_port_type(port: int) -> PortType: return PORT_TYPE_VECTOR_3D func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Artistic/Artistic.gdshaderinc\"" % [version] 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/Hue.gd b/addons/ShaderLib_v2_2_4/Artistic/Adjustment/Hue.gd similarity index 91% rename from addons/ShaderLib/Artistic/Adjustment/Hue.gd rename to addons/ShaderLib_v2_2_4/Artistic/Adjustment/Hue.gd index ba87b4a..a5e8f4b 100644 --- a/addons/ShaderLib/Artistic/Adjustment/Hue.gd +++ b/addons/ShaderLib_v2_2_4/Artistic/Adjustment/Hue.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeAdjustmentHue extends VisualShaderNodeCustom +class_name VisualShaderNodeAdjustmentHue extends ShaderLib func _get_name() -> String: return "Hue" @@ -59,7 +59,7 @@ func _get_property_options(index: int) -> PackedStringArray: return ["Degrees", "Normalize"] func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Artistic/Artistic.gdshaderinc\"" % [version] 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/ReplaceColor.gd b/addons/ShaderLib_v2_2_4/Artistic/Adjustment/ReplaceColor.gd similarity index 91% rename from addons/ShaderLib/Artistic/Adjustment/ReplaceColor.gd rename to addons/ShaderLib_v2_2_4/Artistic/Adjustment/ReplaceColor.gd index a0f6246..b4adb41 100644 --- a/addons/ShaderLib/Artistic/Adjustment/ReplaceColor.gd +++ b/addons/ShaderLib_v2_2_4/Artistic/Adjustment/ReplaceColor.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeAdjustmentReplaceColor extends VisualShaderNodeCustom +class_name VisualShaderNodeAdjustmentReplaceColor extends ShaderLib func _get_name() -> String: return "ReplaceColor" @@ -55,7 +55,7 @@ func _get_output_port_type(port: int) -> PortType: return PORT_TYPE_VECTOR_3D func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Artistic/Artistic.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Artistic/Adjustment/Saturation.gd similarity index 89% rename from addons/ShaderLib/Artistic/Adjustment/Saturation.gd rename to addons/ShaderLib_v2_2_4/Artistic/Adjustment/Saturation.gd index 186896c..a8721a2 100644 --- a/addons/ShaderLib/Artistic/Adjustment/Saturation.gd +++ b/addons/ShaderLib_v2_2_4/Artistic/Adjustment/Saturation.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeAdjustmentSaturation extends VisualShaderNodeCustom +class_name VisualShaderNodeAdjustmentSaturation extends ShaderLib func _get_name() -> String: @@ -48,7 +48,7 @@ func _get_output_port_type(port: int) -> PortType: return PORT_TYPE_VECTOR_3D func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Artistic/Artistic.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Artistic/Adjustment/WhiteBalance.gd similarity index 90% rename from addons/ShaderLib/Artistic/Adjustment/WhiteBalance.gd rename to addons/ShaderLib_v2_2_4/Artistic/Adjustment/WhiteBalance.gd index 6415eac..67274ea 100644 --- a/addons/ShaderLib/Artistic/Adjustment/WhiteBalance.gd +++ b/addons/ShaderLib_v2_2_4/Artistic/Adjustment/WhiteBalance.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeWhiteBalance extends VisualShaderNodeCustom +class_name VisualShaderNodeWhiteBalance extends ShaderLib func _get_name() -> String: return "WhiteBalance" @@ -49,7 +49,7 @@ func _get_output_port_type(port: int) -> PortType: return PORT_TYPE_VECTOR_3D func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Artistic/Artistic.gdshaderinc\"" % [version] 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/Artistic.gdshaderinc b/addons/ShaderLib_v2_2_4/Artistic/Artistic.gdshaderinc similarity index 100% rename from addons/ShaderLib/Artistic/Artistic.gdshaderinc rename to addons/ShaderLib_v2_2_4/Artistic/Artistic.gdshaderinc diff --git a/addons/ShaderLib/Artistic/Mask/ColorMask.gd b/addons/ShaderLib_v2_2_4/Artistic/Mask/ColorMask.gd similarity index 90% rename from addons/ShaderLib/Artistic/Mask/ColorMask.gd rename to addons/ShaderLib_v2_2_4/Artistic/Mask/ColorMask.gd index c598ed0..1582b4f 100644 --- a/addons/ShaderLib/Artistic/Mask/ColorMask.gd +++ b/addons/ShaderLib_v2_2_4/Artistic/Mask/ColorMask.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeMaskColorMask extends VisualShaderNodeCustom +class_name VisualShaderNodeMaskColorMask extends ShaderLib func _get_name() -> String: return "ColorMask" @@ -53,7 +53,7 @@ func _get_output_port_type(port: int) -> PortType: return PORT_TYPE_VECTOR_4D func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Artistic/Artistic.gdshaderinc\"" % [version] 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/Geometry/Geometry.gdshaderinc b/addons/ShaderLib_v2_2_4/Geometry/Geometry.gdshaderinc similarity index 100% rename from addons/ShaderLib/Geometry/Geometry.gdshaderinc rename to addons/ShaderLib_v2_2_4/Geometry/Geometry.gdshaderinc diff --git a/addons/ShaderLib/Geometry/MeshNode.gd b/addons/ShaderLib_v2_2_4/Geometry/MeshNode.gd similarity index 88% rename from addons/ShaderLib/Geometry/MeshNode.gd rename to addons/ShaderLib_v2_2_4/Geometry/MeshNode.gd index 22e6bef..3a8be37 100644 --- a/addons/ShaderLib/Geometry/MeshNode.gd +++ b/addons/ShaderLib_v2_2_4/Geometry/MeshNode.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeGeometryMeshNode extends VisualShaderNodeCustom +class_name VisualShaderNodeGeometryMeshNode extends ShaderLib func _get_name() -> String: return "MeshNode" @@ -42,7 +42,7 @@ func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool: return false func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Geometry/Geometry.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Geometry/Geometry.gdshaderinc\"" % [version] 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/LICENSE b/addons/ShaderLib_v2_2_4/LICENSE similarity index 100% rename from addons/ShaderLib/LICENSE rename to addons/ShaderLib_v2_2_4/LICENSE diff --git a/addons/ShaderLib/Maths/Maths.gdshaderinc b/addons/ShaderLib_v2_2_4/Maths/Maths.gdshaderinc similarity index 100% rename from addons/ShaderLib/Maths/Maths.gdshaderinc rename to addons/ShaderLib_v2_2_4/Maths/Maths.gdshaderinc diff --git a/addons/ShaderLib/Maths/Scalar/SmoothMax.gd b/addons/ShaderLib_v2_2_4/Maths/Scalar/SmoothMax.gd similarity index 89% rename from addons/ShaderLib/Maths/Scalar/SmoothMax.gd rename to addons/ShaderLib_v2_2_4/Maths/Scalar/SmoothMax.gd index 002f111..e774287 100644 --- a/addons/ShaderLib/Maths/Scalar/SmoothMax.gd +++ b/addons/ShaderLib_v2_2_4/Maths/Scalar/SmoothMax.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeScalarSmoothMax extends VisualShaderNodeCustom +class_name VisualShaderNodeScalarSmoothMax extends ShaderLib func _get_name() -> String: return "SmoothMax" @@ -45,7 +45,7 @@ func _get_output_port_type(port: int) -> PortType: return PORT_TYPE_SCALAR func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Maths/Maths.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Maths/Scalar/SmoothMin.gd similarity index 89% rename from addons/ShaderLib/Maths/Scalar/SmoothMin.gd rename to addons/ShaderLib_v2_2_4/Maths/Scalar/SmoothMin.gd index 6d0384d..8a199e2 100644 --- a/addons/ShaderLib/Maths/Scalar/SmoothMin.gd +++ b/addons/ShaderLib_v2_2_4/Maths/Scalar/SmoothMin.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeScalarSmoothMin extends VisualShaderNodeCustom +class_name VisualShaderNodeScalarSmoothMin extends ShaderLib func _get_name() -> String: return "SmoothMin" @@ -45,7 +45,7 @@ func _get_output_port_type(port: int) -> PortType: return PORT_TYPE_SCALAR func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Maths/Maths.gdshaderinc\"" % [version] 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/Vector/Distance/ChebyshevDistance.gd b/addons/ShaderLib_v2_2_4/Maths/Vector/Distance/ChebyshevDistance.gd similarity index 93% rename from addons/ShaderLib/Maths/Vector/Distance/ChebyshevDistance.gd rename to addons/ShaderLib_v2_2_4/Maths/Vector/Distance/ChebyshevDistance.gd index 5bedb8a..d5987a1 100644 --- a/addons/ShaderLib/Maths/Vector/Distance/ChebyshevDistance.gd +++ b/addons/ShaderLib_v2_2_4/Maths/Vector/Distance/ChebyshevDistance.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeMathsChebyshevDistance extends VisualShaderNodeCustom +class_name VisualShaderNodeMathsChebyshevDistance extends ShaderLib func _get_name() -> String: return "ChebyshevDistance" @@ -66,7 +66,7 @@ func _get_property_options(index: int) -> PackedStringArray: return ["Vector2", "Vector3"] func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Maths/Maths.gdshaderinc\"" % [version] func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String: var point_a: String @@ -92,4 +92,3 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad return output_vars[0] + " = chebyshev_distance_2d(%s, %s, %s);" % [point_a, point_b, power] _: return output_vars[0] + " = chebyshev_distance_3d(%s, %s, %s);" % [point_a, point_b, power] - diff --git a/addons/ShaderLib/Maths/Vector/Distance/ManhattanDistance.gd b/addons/ShaderLib_v2_2_4/Maths/Vector/Distance/ManhattanDistance.gd similarity index 92% rename from addons/ShaderLib/Maths/Vector/Distance/ManhattanDistance.gd rename to addons/ShaderLib_v2_2_4/Maths/Vector/Distance/ManhattanDistance.gd index 03173b9..4fc2bc4 100644 --- a/addons/ShaderLib/Maths/Vector/Distance/ManhattanDistance.gd +++ b/addons/ShaderLib_v2_2_4/Maths/Vector/Distance/ManhattanDistance.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeMathsManhattanDistance extends VisualShaderNodeCustom +class_name VisualShaderNodeMathsManhattanDistance extends ShaderLib func _get_name() -> String: return "ManhattanDistance" @@ -53,7 +53,7 @@ func _get_property_options(index: int) -> PackedStringArray: return ["Vector2", "Vector3"] func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Maths/Maths.gdshaderinc\"" % [version] func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String: var point_a: String @@ -78,4 +78,3 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad return output_vars[0] + " = manhattan_distance_2d(%s, %s);" % [point_a, point_b] _: return output_vars[0] + " = manhattan_distance_3d(%s, %s);" % [point_a, point_b] - diff --git a/addons/ShaderLib/Maths/Vector/Project.gd b/addons/ShaderLib_v2_2_4/Maths/Vector/Project.gd similarity index 92% rename from addons/ShaderLib/Maths/Vector/Project.gd rename to addons/ShaderLib_v2_2_4/Maths/Vector/Project.gd index 68db8fd..3fce7ae 100644 --- a/addons/ShaderLib/Maths/Vector/Project.gd +++ b/addons/ShaderLib_v2_2_4/Maths/Vector/Project.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeVectorProject extends VisualShaderNodeCustom +class_name VisualShaderNodeVectorProject extends ShaderLib func _get_name() -> String: return "Project" @@ -63,7 +63,7 @@ func _get_property_options(index: int) -> PackedStringArray: return ["Vector2", "Vector3"] func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Maths/Maths.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Maths/Vector/ProjectOnPlane.gd similarity index 87% rename from addons/ShaderLib/Maths/Vector/ProjectOnPlane.gd rename to addons/ShaderLib_v2_2_4/Maths/Vector/ProjectOnPlane.gd index d7b2bac..b81f4b5 100644 --- a/addons/ShaderLib/Maths/Vector/ProjectOnPlane.gd +++ b/addons/ShaderLib_v2_2_4/Maths/Vector/ProjectOnPlane.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeVectorProjectOnPlane extends VisualShaderNodeCustom +class_name VisualShaderNodeVectorProjectOnPlane extends ShaderLib func _get_name() -> String: return "ProjectOnPlane" @@ -36,7 +36,7 @@ func _get_output_port_type(port: int) -> PortType: return PORT_TYPE_VECTOR_3D func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Maths/Maths.gdshaderinc\"" % [version] 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/VectorTransform.gd b/addons/ShaderLib_v2_2_4/Maths/Vector/VectorTransform.gd similarity index 97% rename from addons/ShaderLib/Maths/Vector/VectorTransform.gd rename to addons/ShaderLib_v2_2_4/Maths/Vector/VectorTransform.gd index 062abdf..44c7ea3 100644 --- a/addons/ShaderLib/Maths/Vector/VectorTransform.gd +++ b/addons/ShaderLib_v2_2_4/Maths/Vector/VectorTransform.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeVectorTransform extends VisualShaderNodeCustom +class_name VisualShaderNodeVectorTransform extends ShaderLib func _get_name() -> String: return "VectorTransform" @@ -55,7 +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: - return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Maths/Maths.gdshaderinc\"" % [version] 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_v2_2_4/Maths/Wave/NoiseSineWave.gd similarity index 94% rename from addons/ShaderLib/Maths/Wave/NoiseSineWave.gd rename to addons/ShaderLib_v2_2_4/Maths/Wave/NoiseSineWave.gd index 0064741..91df2d4 100644 --- a/addons/ShaderLib/Maths/Wave/NoiseSineWave.gd +++ b/addons/ShaderLib_v2_2_4/Maths/Wave/NoiseSineWave.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeMathsNoiseSineWave extends VisualShaderNodeCustom +class_name VisualShaderNodeMathsNoiseSineWave extends ShaderLib func _get_name() -> String: return "NoiseSineWave" @@ -87,7 +87,7 @@ func _get_property_options(index: int) -> PackedStringArray: return ["Vector1", "Vector2", "Vector3", "Vector4"] func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Maths/Maths.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Maths/Wave/SawtoothWave.gd similarity index 93% rename from addons/ShaderLib/Maths/Wave/SawtoothWave.gd rename to addons/ShaderLib_v2_2_4/Maths/Wave/SawtoothWave.gd index 33d7a70..11aceb3 100644 --- a/addons/ShaderLib/Maths/Wave/SawtoothWave.gd +++ b/addons/ShaderLib_v2_2_4/Maths/Wave/SawtoothWave.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeMathsSawtoothWave extends VisualShaderNodeCustom +class_name VisualShaderNodeMathsSawtoothWave extends ShaderLib func _get_name() -> String: return "SawtoothWave" @@ -71,7 +71,7 @@ func _get_property_options(index: int) -> PackedStringArray: return ["Vector1", "Vector2", "Vector3", "Vector4"] func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Maths/Maths.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Maths/Wave/SquareWave.gd similarity index 94% rename from addons/ShaderLib/Maths/Wave/SquareWave.gd rename to addons/ShaderLib_v2_2_4/Maths/Wave/SquareWave.gd index fb5f02e..cb64cbc 100644 --- a/addons/ShaderLib/Maths/Wave/SquareWave.gd +++ b/addons/ShaderLib_v2_2_4/Maths/Wave/SquareWave.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeMathsSquareWave extends VisualShaderNodeCustom +class_name VisualShaderNodeMathsSquareWave extends ShaderLib func _get_name() -> String: @@ -72,7 +72,7 @@ func _get_property_options(index: int) -> PackedStringArray: return ["Vector1", "Vector2", "Vector3", "Vector4"] func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Maths/Maths.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Maths/Wave/TriangleWave.gd similarity index 93% rename from addons/ShaderLib/Maths/Wave/TriangleWave.gd rename to addons/ShaderLib_v2_2_4/Maths/Wave/TriangleWave.gd index da8e90b..0680389 100644 --- a/addons/ShaderLib/Maths/Wave/TriangleWave.gd +++ b/addons/ShaderLib_v2_2_4/Maths/Wave/TriangleWave.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeMathsTriangleWave extends VisualShaderNodeCustom +class_name VisualShaderNodeMathsTriangleWave extends ShaderLib func _get_name() -> String: return "TriangleWave" @@ -70,7 +70,7 @@ func _get_property_options(index: int) -> PackedStringArray: return ["Vector1", "Vector2", "Vector3", "Vector4"] func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Maths/Maths.gdshaderinc\"" % [version] 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/Procedural/CheckerBoard.gd b/addons/ShaderLib_v2_2_4/Procedural/CheckerBoard.gd similarity index 91% rename from addons/ShaderLib/Procedural/CheckerBoard.gd rename to addons/ShaderLib_v2_2_4/Procedural/CheckerBoard.gd index b49e5e0..42e8f63 100644 --- a/addons/ShaderLib/Procedural/CheckerBoard.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/CheckerBoard.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeProceduralCheckerBoard extends VisualShaderNodeCustom +class_name VisualShaderNodeProceduralCheckerBoard extends ShaderLib func _init() -> void: output_port_for_preview = 0 @@ -60,7 +60,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_VECTOR_3D func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Procedural/Procedural.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Procedural/Fractals/KochFractal.gd similarity index 91% rename from addons/ShaderLib/Procedural/Fractals/KochFractal.gd rename to addons/ShaderLib_v2_2_4/Procedural/Fractals/KochFractal.gd index ef45355..9d06095 100644 --- a/addons/ShaderLib/Procedural/Fractals/KochFractal.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/Fractals/KochFractal.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeProceduralKochFractal extends VisualShaderNodeCustom +class_name VisualShaderNodeProceduralKochFractal extends ShaderLib func _init() -> void: output_port_for_preview = 0 @@ -68,7 +68,7 @@ func _get_output_port_type(port: int) -> PortType: return PORT_TYPE_SCALAR func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Procedural/Procedural.gdshaderinc\"" % [version] func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String: var uv: String = "UV" @@ -82,4 +82,3 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad var height: String = input_vars[4] return output_vars[0] + " = koch_fractal(%s, %s, %s, %s, %s, %s);" % [uv, thickness, iterations, width, height, output_vars[1]] - diff --git a/addons/ShaderLib/Procedural/HeightToNormal.gd b/addons/ShaderLib_v2_2_4/Procedural/HeightToNormal.gd similarity index 89% rename from addons/ShaderLib/Procedural/HeightToNormal.gd rename to addons/ShaderLib_v2_2_4/Procedural/HeightToNormal.gd index e7d13cb..0c89307 100644 --- a/addons/ShaderLib/Procedural/HeightToNormal.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/HeightToNormal.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeProceduralHeightToNormal extends VisualShaderNodeCustom +class_name VisualShaderNodeProceduralHeightToNormal extends ShaderLib func _get_name() -> String: return "HeightToNormal" @@ -52,7 +52,7 @@ func _get_output_port_type(port: int) -> PortType: return PORT_TYPE_VECTOR_3D func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Procedural/Procedural.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Procedural/Noise/GradientNoise.gd similarity index 89% rename from addons/ShaderLib/Procedural/Noise/GradientNoise.gd rename to addons/ShaderLib_v2_2_4/Procedural/Noise/GradientNoise.gd index 7421215..d89da59 100644 --- a/addons/ShaderLib/Procedural/Noise/GradientNoise.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/Noise/GradientNoise.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeProceduralGradientNoise extends VisualShaderNodeCustom +class_name VisualShaderNodeProceduralGradientNoise extends ShaderLib func _init() -> void: output_port_for_preview = 0 @@ -52,7 +52,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_SCALAR func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Procedural/Procedural.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Procedural/Noise/GyroidNoise.gd similarity index 90% rename from addons/ShaderLib/Procedural/Noise/GyroidNoise.gd rename to addons/ShaderLib_v2_2_4/Procedural/Noise/GyroidNoise.gd index be1b836..c189805 100644 --- a/addons/ShaderLib/Procedural/Noise/GyroidNoise.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/Noise/GyroidNoise.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeProceduralGyroidNoise extends VisualShaderNodeCustom +class_name VisualShaderNodeProceduralGyroidNoise extends ShaderLib func _init() -> void: output_port_for_preview = 0 @@ -62,7 +62,7 @@ func _get_output_port_type(port: int) -> PortType: return PORT_TYPE_SCALAR func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Procedural/Procedural.gdshaderinc\"" % [version] 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/PseudoRandomNoise.gd b/addons/ShaderLib_v2_2_4/Procedural/Noise/PseudoRandomNoise.gd similarity index 83% rename from addons/ShaderLib/Procedural/Noise/PseudoRandomNoise.gd rename to addons/ShaderLib_v2_2_4/Procedural/Noise/PseudoRandomNoise.gd index 7d9432e..f5cab30 100644 --- a/addons/ShaderLib/Procedural/Noise/PseudoRandomNoise.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/Noise/PseudoRandomNoise.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodePseudoRandomNoise extends VisualShaderNodeCustom +class_name VisualShaderNodePseudoRandomNoise extends ShaderLib func _init() -> void: output_port_for_preview = 0 @@ -41,5 +41,8 @@ func _get_output_port_name(port: int) -> String: func _get_output_port_type(port: int) -> PortType: return PORT_TYPE_SCALAR +func _get_global_code(mode: Shader.Mode) -> String: + return "#include \"res://addons/ShaderLib_%s/Procedural/Procedural.gdshaderinc\"" % [version] + func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String: return output_vars[0] + " = pseudo_random_noise(UV, %s);" % input_vars[0] diff --git a/addons/ShaderLib/Procedural/Noise/SimpleNoise.gd b/addons/ShaderLib_v2_2_4/Procedural/Noise/SimpleNoise.gd similarity index 89% rename from addons/ShaderLib/Procedural/Noise/SimpleNoise.gd rename to addons/ShaderLib_v2_2_4/Procedural/Noise/SimpleNoise.gd index 57784be..0e3f63a 100644 --- a/addons/ShaderLib/Procedural/Noise/SimpleNoise.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/Noise/SimpleNoise.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeProceduralSimpleNoise extends VisualShaderNodeCustom +class_name VisualShaderNodeProceduralSimpleNoise extends ShaderLib func _init() -> void: output_port_for_preview = 0 @@ -56,7 +56,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_SCALAR func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Procedural/Procedural.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Procedural/Noise/Voronoi.gd similarity index 94% rename from addons/ShaderLib/Procedural/Noise/Voronoi.gd rename to addons/ShaderLib_v2_2_4/Procedural/Noise/Voronoi.gd index 25ea313..0ccdec2 100644 --- a/addons/ShaderLib/Procedural/Noise/Voronoi.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/Noise/Voronoi.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeProceduralVoronoi extends VisualShaderNodeCustom +class_name VisualShaderNodeProceduralVoronoi extends ShaderLib func _init() -> void: output_port_for_preview = 0 @@ -101,7 +101,7 @@ func _get_property_options(index: int) -> PackedStringArray: return ["Euclidean", "Manhattan", "Chebyshev"] func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Procedural/Procedural.gdshaderinc\"" % [version] 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/Procedural.gdshaderinc b/addons/ShaderLib_v2_2_4/Procedural/Procedural.gdshaderinc similarity index 99% rename from addons/ShaderLib/Procedural/Procedural.gdshaderinc rename to addons/ShaderLib_v2_2_4/Procedural/Procedural.gdshaderinc index 594a9ae..6263de2 100644 --- a/addons/ShaderLib/Procedural/Procedural.gdshaderinc +++ b/addons/ShaderLib_v2_2_4/Procedural/Procedural.gdshaderinc @@ -1,4 +1,4 @@ -#include "res://addons/ShaderLib/Maths/Maths.gdshaderinc" +#include "res://addons/ShaderLib_v2_2_4/Maths/Maths.gdshaderinc" vec3 checker_board(vec2 uv, vec3 color_a, vec3 color_b, vec2 frequency) { uv = (uv.xy + 0.5) * frequency; diff --git a/addons/ShaderLib/Procedural/Shapes/Ellipse.gd b/addons/ShaderLib_v2_2_4/Procedural/Shapes/Ellipse.gd similarity index 90% rename from addons/ShaderLib/Procedural/Shapes/Ellipse.gd rename to addons/ShaderLib_v2_2_4/Procedural/Shapes/Ellipse.gd index 2b20403..24d2f42 100644 --- a/addons/ShaderLib/Procedural/Shapes/Ellipse.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/Shapes/Ellipse.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeProceduralEllipse extends VisualShaderNodeCustom +class_name VisualShaderNodeProceduralEllipse extends ShaderLib func _init() -> void: output_port_for_preview = 0 @@ -54,7 +54,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_SCALAR func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Procedural/Procedural.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Procedural/Shapes/Polygon.gd similarity index 91% rename from addons/ShaderLib/Procedural/Shapes/Polygon.gd rename to addons/ShaderLib_v2_2_4/Procedural/Shapes/Polygon.gd index d575571..2332b6b 100644 --- a/addons/ShaderLib/Procedural/Shapes/Polygon.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/Shapes/Polygon.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeProceduralPolygon extends VisualShaderNodeCustom +class_name VisualShaderNodeProceduralPolygon extends ShaderLib func _init() -> void: output_port_for_preview = 0 @@ -60,7 +60,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_SCALAR func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Procedural/Procedural.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Procedural/Shapes/Rectangle.gd similarity index 90% rename from addons/ShaderLib/Procedural/Shapes/Rectangle.gd rename to addons/ShaderLib_v2_2_4/Procedural/Shapes/Rectangle.gd index 19173c6..7463091 100644 --- a/addons/ShaderLib/Procedural/Shapes/Rectangle.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/Shapes/Rectangle.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeProceduralRectangle extends VisualShaderNodeCustom +class_name VisualShaderNodeProceduralRectangle extends ShaderLib func _init() -> void: output_port_for_preview = 0 @@ -54,7 +54,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_SCALAR func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Procedural/Procedural.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Procedural/Shapes/RoundedPolygon.gd similarity index 91% rename from addons/ShaderLib/Procedural/Shapes/RoundedPolygon.gd rename to addons/ShaderLib_v2_2_4/Procedural/Shapes/RoundedPolygon.gd index 4798498..53058a9 100644 --- a/addons/ShaderLib/Procedural/Shapes/RoundedPolygon.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/Shapes/RoundedPolygon.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeProceduralRoundedPolygon extends VisualShaderNodeCustom +class_name VisualShaderNodeProceduralRoundedPolygon extends ShaderLib func _init() -> void: output_port_for_preview = 0 @@ -61,7 +61,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_SCALAR func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Procedural/Procedural.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/Procedural/Shapes/RoundedRectangle.gd similarity index 90% rename from addons/ShaderLib/Procedural/Shapes/RoundedRectangle.gd rename to addons/ShaderLib_v2_2_4/Procedural/Shapes/RoundedRectangle.gd index f1b4473..b87288d 100644 --- a/addons/ShaderLib/Procedural/Shapes/RoundedRectangle.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/Shapes/RoundedRectangle.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeProceduralRoundedRectangle extends VisualShaderNodeCustom +class_name VisualShaderNodeProceduralRoundedRectangle extends ShaderLib func _init() -> void: output_port_for_preview = 0 @@ -58,7 +58,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_SCALAR func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/Procedural/Procedural.gdshaderinc\"" % [version] 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/RayMarching/RayMarch.gd b/addons/ShaderLib_v2_2_4/RayMarching/RayMarch.gd similarity index 97% rename from addons/ShaderLib/RayMarching/RayMarch.gd rename to addons/ShaderLib_v2_2_4/RayMarching/RayMarch.gd index 4fc3f9b..4cb4d28 100644 --- a/addons/ShaderLib/RayMarching/RayMarch.gd +++ b/addons/ShaderLib_v2_2_4/RayMarching/RayMarch.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeRayMarch extends VisualShaderNodeCustom +class_name VisualShaderNodeRayMarch extends ShaderLib func _get_name() -> String: return "RayMarch" @@ -183,7 +183,7 @@ func _get_output_port_type(port: int) -> PortType: return PORT_TYPE_SCALAR func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/RayMarching/SignedDistanceFunctions.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/RayMarching/SignedDistanceFunctions.gdshaderinc\"" % [version] 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) @@ -222,4 +222,3 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad var small_radius: String = input_vars[7] var big_radius: String = input_vars[8] return output_vars[0] + " = ray_march_sd_torus(%s, %s, %s, %s, %s, %s, %s, %s, %s);" % [ray_origin, ray_direction, max_steps, max_dist, dist_threshold, torus_pos, eulers, small_radius, big_radius] - diff --git a/addons/ShaderLib/RayMarching/RayMarchCustomTemplate.gdshaderinc b/addons/ShaderLib_v2_2_4/RayMarching/RayMarchCustomTemplate.gdshaderinc similarity index 100% rename from addons/ShaderLib/RayMarching/RayMarchCustomTemplate.gdshaderinc rename to addons/ShaderLib_v2_2_4/RayMarching/RayMarchCustomTemplate.gdshaderinc diff --git a/addons/ShaderLib/RayMarching/SignedDistanceFunctions.gdshaderinc b/addons/ShaderLib_v2_2_4/RayMarching/SignedDistanceFunctions.gdshaderinc similarity index 100% rename from addons/ShaderLib/RayMarching/SignedDistanceFunctions.gdshaderinc rename to addons/ShaderLib_v2_2_4/RayMarching/SignedDistanceFunctions.gdshaderinc diff --git a/addons/ShaderLib_v2_2_4/ShaderLib.gd b/addons/ShaderLib_v2_2_4/ShaderLib.gd new file mode 100644 index 0000000..5fe4a73 --- /dev/null +++ b/addons/ShaderLib_v2_2_4/ShaderLib.gd @@ -0,0 +1,3 @@ +class_name ShaderLib extends VisualShaderNodeCustom + +var version: String = "v2_2_4" diff --git a/addons/ShaderLib/UV/FlipbookUV.gd b/addons/ShaderLib_v2_2_4/UV/FlipbookUV.gd similarity index 92% rename from addons/ShaderLib/UV/FlipbookUV.gd rename to addons/ShaderLib_v2_2_4/UV/FlipbookUV.gd index a6e2404..a5155ba 100644 --- a/addons/ShaderLib/UV/FlipbookUV.gd +++ b/addons/ShaderLib_v2_2_4/UV/FlipbookUV.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeUVFlipbook extends VisualShaderNodeCustom +class_name VisualShaderNodeUVFlipbook extends ShaderLib func _get_name() -> String: return "Flipbook" @@ -57,7 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_VECTOR_2D func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/UV/UV.gdshaderinc\"" % [version] func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool: match mode: diff --git a/addons/ShaderLib/UV/ParallaxMappingUV.gd b/addons/ShaderLib_v2_2_4/UV/ParallaxMappingUV.gd similarity index 91% rename from addons/ShaderLib/UV/ParallaxMappingUV.gd rename to addons/ShaderLib_v2_2_4/UV/ParallaxMappingUV.gd index 50b35bf..5685f44 100644 --- a/addons/ShaderLib/UV/ParallaxMappingUV.gd +++ b/addons/ShaderLib_v2_2_4/UV/ParallaxMappingUV.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeUVParallaxMapping extends VisualShaderNodeCustom +class_name VisualShaderNodeUVParallaxMapping extends ShaderLib func _get_name() -> String: return "ParallaxMapping" @@ -55,7 +55,7 @@ func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool: return false func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/UV/UV.gdshaderinc\"" % [version] 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/RadialShearUV.gd b/addons/ShaderLib_v2_2_4/UV/RadialShearUV.gd similarity index 92% rename from addons/ShaderLib/UV/RadialShearUV.gd rename to addons/ShaderLib_v2_2_4/UV/RadialShearUV.gd index 03a4a01..3d159f2 100644 --- a/addons/ShaderLib/UV/RadialShearUV.gd +++ b/addons/ShaderLib_v2_2_4/UV/RadialShearUV.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeUVRadialShear extends VisualShaderNodeCustom +class_name VisualShaderNodeUVRadialShear extends ShaderLib func _get_name() -> String: return "RadialShear" @@ -57,7 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_VECTOR_2D func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/UV/UV.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/UV/RotateUV.gd similarity index 93% rename from addons/ShaderLib/UV/RotateUV.gd rename to addons/ShaderLib_v2_2_4/UV/RotateUV.gd index c3388a6..a47ffb4 100644 --- a/addons/ShaderLib/UV/RotateUV.gd +++ b/addons/ShaderLib_v2_2_4/UV/RotateUV.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeUVRotate extends VisualShaderNodeCustom +class_name VisualShaderNodeUVRotate extends ShaderLib func _get_name() -> String: return "Rotate" @@ -65,7 +65,7 @@ func _get_property_options(index: int) -> PackedStringArray: return ["Degrees", "Radians"] func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/UV/UV.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/UV/SpherizeUV.gd similarity index 92% rename from addons/ShaderLib/UV/SpherizeUV.gd rename to addons/ShaderLib_v2_2_4/UV/SpherizeUV.gd index 07e3886..9229392 100644 --- a/addons/ShaderLib/UV/SpherizeUV.gd +++ b/addons/ShaderLib_v2_2_4/UV/SpherizeUV.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeUVSpherize extends VisualShaderNodeCustom +class_name VisualShaderNodeUVSpherize extends ShaderLib func _get_name() -> String: return "Spherize" @@ -57,7 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_VECTOR_2D func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/UV/UV.gdshaderinc\"" % [version] 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.gd b/addons/ShaderLib_v2_2_4/UV/SwirlUV.gd similarity index 92% rename from addons/ShaderLib/UV/SwirlUV.gd rename to addons/ShaderLib_v2_2_4/UV/SwirlUV.gd index 354025b..e822b6e 100644 --- a/addons/ShaderLib/UV/SwirlUV.gd +++ b/addons/ShaderLib_v2_2_4/UV/SwirlUV.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeUVSwirl extends VisualShaderNodeCustom +class_name VisualShaderNodeUVSwirl extends ShaderLib func _get_name() -> String: return "Swirl" @@ -57,7 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_VECTOR_2D func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/UV/UV.gdshaderinc\"" % [version] 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/TilingAndOffsetUV.gd b/addons/ShaderLib_v2_2_4/UV/TilingAndOffsetUV.gd similarity index 95% rename from addons/ShaderLib/UV/TilingAndOffsetUV.gd rename to addons/ShaderLib_v2_2_4/UV/TilingAndOffsetUV.gd index 30f7f8b..0b101bf 100644 --- a/addons/ShaderLib/UV/TilingAndOffsetUV.gd +++ b/addons/ShaderLib_v2_2_4/UV/TilingAndOffsetUV.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeUVTilingAndOffset extends VisualShaderNodeCustom +class_name VisualShaderNodeUVTilingAndOffset extends ShaderLib func _get_name() -> String: return "TilingAndOffset" diff --git a/addons/ShaderLib/UV/TwirlUV.gd b/addons/ShaderLib_v2_2_4/UV/TwirlUV.gd similarity index 92% rename from addons/ShaderLib/UV/TwirlUV.gd rename to addons/ShaderLib_v2_2_4/UV/TwirlUV.gd index b8d8e53..5f150d8 100644 --- a/addons/ShaderLib/UV/TwirlUV.gd +++ b/addons/ShaderLib_v2_2_4/UV/TwirlUV.gd @@ -1,5 +1,5 @@ @tool -class_name VisualShaderNodeUVTwirl extends VisualShaderNodeCustom +class_name VisualShaderNodeUVTwirl extends ShaderLib func _get_name() -> String: return "Twirl" @@ -57,7 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_VECTOR_2D func _get_global_code(mode: Shader.Mode) -> String: - return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\"" + return "#include \"res://addons/ShaderLib_%s/UV/UV.gdshaderinc\"" % [version] 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/UV.gdshaderinc b/addons/ShaderLib_v2_2_4/UV/UV.gdshaderinc similarity index 100% rename from addons/ShaderLib/UV/UV.gdshaderinc rename to addons/ShaderLib_v2_2_4/UV/UV.gdshaderinc From afae2c766e19bca6d10742e1795e3e0f8e960e47 Mon Sep 17 00:00:00 2001 From: Digvijaysinh Gohil Date: Sun, 29 Sep 2024 23:42:44 +0530 Subject: [PATCH 4/4] Voronoi noise functions refactored --- .../Procedural/Noise/Voronoi.gd | 19 +++--- .../Procedural/Procedural.gdshaderinc | 64 +++++++++++++++---- .../Nodes/Procedural/Noise/Voronoi.md | 6 +- 3 files changed, 63 insertions(+), 26 deletions(-) diff --git a/addons/ShaderLib_v2_2_4/Procedural/Noise/Voronoi.gd b/addons/ShaderLib_v2_2_4/Procedural/Noise/Voronoi.gd index 0ccdec2..7607946 100644 --- a/addons/ShaderLib_v2_2_4/Procedural/Noise/Voronoi.gd +++ b/addons/ShaderLib_v2_2_4/Procedural/Noise/Voronoi.gd @@ -1,9 +1,6 @@ @tool class_name VisualShaderNodeProceduralVoronoi extends ShaderLib -func _init() -> void: - output_port_for_preview = 0 - func _get_name() -> String: return "Voronoi" @@ -63,7 +60,7 @@ func _get_input_port_default_value(port: int) -> Variant: 2: return 2.0 3: - return 2.0 + return 5.0 _: return null _: @@ -113,13 +110,15 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad var cell_density: String = input_vars[1] var angle_offset: String = input_vars[2] - var chebyshev_power: String = "0." - - if distance_index == 2: - if input_vars[3]: - chebyshev_power = input_vars[3] var output: String = output_vars[0] var cells: String = output_vars[1] - return "voronoi_noise(%s, %s, %s, %s, %s, %s, %s);" % [uv, cell_density, angle_offset, distance_index, chebyshev_power, output, cells] + match distance_index: + 1: + return "%s = voronoi_noise_manhattan(%s, %s, %s, %s);" % [output, uv, cell_density, angle_offset, cells] + 2: + var chebyshev_power: String = input_vars[3] + return "%s = voronoi_noise_chebyshev(%s, %s, %s, %s, %s);" % [output, uv, cell_density, angle_offset, chebyshev_power, cells] + _: + return "%s = voronoi_noise_euclidean(%s, %s, %s, %s);" % [output, uv, cell_density, angle_offset, cells] diff --git a/addons/ShaderLib_v2_2_4/Procedural/Procedural.gdshaderinc b/addons/ShaderLib_v2_2_4/Procedural/Procedural.gdshaderinc index 6263de2..1ca1bdc 100644 --- a/addons/ShaderLib_v2_2_4/Procedural/Procedural.gdshaderinc +++ b/addons/ShaderLib_v2_2_4/Procedural/Procedural.gdshaderinc @@ -130,7 +130,7 @@ vec2 voronoi_random_vector(vec2 p) { 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){ +float voronoi_noise_euclidean(vec2 uv, float cell_density, float angle_offset, out float cells){ vec2 grid_uv = fract(uv * cell_density); vec2 grid_id = floor(uv * cell_density); vec2 cell_id = vec2(0); @@ -142,18 +142,31 @@ void voronoi_noise(vec2 uv, float cell_density, float angle_offset, int distance 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; + d = distance(grid_uv, p); + if(d < min_dist) { + min_dist = d; + cell_id = voronoi_random_vector(grid_id + offset); } + } + } + + cells = cell_id.y; + return min_dist; +} + +float voronoi_noise_manhattan(vec2 uv, float cell_density, float angle_offset, 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; + d = manhattan_distance_2d(grid_uv, p); if(d < min_dist) { min_dist = d; @@ -162,8 +175,33 @@ void voronoi_noise(vec2 uv, float cell_density, float angle_offset, int distance } } - output = min_dist; cells = cell_id.y; + return min_dist; +} + +float voronoi_noise_chebyshev(vec2 uv, float cell_density, float angle_offset, float chebyshev_power, 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; + d = chebyshev_distance_2d(grid_uv, p, chebyshev_power); + + if(d < min_dist) { + min_dist = d; + cell_id = voronoi_random_vector(grid_id + offset); + } + } + } + + cells = cell_id.y; + return min_dist; } float ellipse_shape(vec2 uv, float width, float height) { diff --git a/documentation/Nodes/Procedural/Noise/Voronoi.md b/documentation/Nodes/Procedural/Noise/Voronoi.md index 9099384..6d1a212 100644 --- a/documentation/Nodes/Procedural/Noise/Voronoi.md +++ b/documentation/Nodes/Procedural/Noise/Voronoi.md @@ -25,7 +25,9 @@ Generates a Voronoi or Worley noise based on input UV. Voronoi noise is generate
`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)` +
`float voronoi_noise_euclidean(vec2 uv, float cell_density, float angle_offset, out float cells)` +
`float voronoi_noise_manhattan(vec2 uv, float cell_density, float angle_offset, out float cells)` +
`float voronoi_noise_chebyshev(vec2 uv, float cell_density, float angle_offset, float chebyshev_power, out float cells)` **Parameters** |Name|Type|Description| @@ -33,8 +35,6 @@ Generates a Voronoi or Worley noise based on input UV. Voronoi noise is generate |uv|vec2|Input UV value| |cell_density|float|Density of generated cells| |angle_offset|float|Offset values for points| -|distance_index|int|Distance matrix to use for Voronoi, 0 = Euclidean, 1 = Manhattan, 2 = Chebyshev| |chebyshev_power|float|Power for Chebyshev distance| -|output|out float|Output noise value| |cells|out float|Output raw cell data| ___ \ No newline at end of file