1
0
mirror of https://github.com/DigvijaysinhGohil/Godot-Shader-Lib.git synced 2025-09-20 04:15:58 +08:00

99 Commits

Author SHA1 Message Date
51ee380503 Vector Transform Node revamped 2024-09-30 18:30:06 +05:30
c1c786f345 Merge branch 'godot-4.2' 2024-09-29 23:44:09 +05:30
afae2c766e Voronoi noise functions refactored 2024-09-29 23:42:44 +05:30
a98305fa5f Code refactored to incorporate #6 2024-09-28 00:45:16 +05:30
199f4a772a HeightToNormal node documentation added 2024-09-28 00:07:16 +05:30
fb19605155 HeightToNormal Node added for feature request #5 2024-09-27 23:58:41 +05:30
85fc207dc0 Merge branch 'godot-4.2' 2024-09-11 18:04:01 +05:30
d72153b7c4 ShaderIncl files refactored 2024-08-06 16:23:43 +05:30
21213d657e #9 issue fix 2024-08-06 16:00:49 +05:30
1b66431979 Merge branch 'godot-4.2' 2024-07-21 16:46:24 +05:30
56eaa9e7b1 Documentation updated 2024-07-21 16:45:45 +05:30
e33f70baa9 ShaderInc files refactored for the ease of future improvements 2024-07-21 16:39:45 +05:30
506c677307 Merge branch 'godot-4.2' 2024-07-03 00:29:20 +05:30
0a8948118f Update Documentation.md 2024-07-03 00:24:36 +05:30
6c7221cbb7 Documentation updated 2024-07-03 00:22:30 +05:30
dc049b857b Documentation updated 2024-07-03 00:20:02 +05:30
3cf0e2d38a Maths nodes refactored, Smoothmin and Smoothmax nodes added 2024-07-03 00:01:09 +05:30
8bac036b66 Merge branch 'godot-4.2' 2024-05-31 00:24:45 +05:30
45ddc1f6a2 Update SwirlUV.gdshaderinc 2024-05-31 00:24:27 +05:30
009b94277f Merge branch 'godot-4.2' 2024-05-30 00:06:55 +05:30
ce44d78559 RotateUV, SwirlUV and TwirlUV algorithms updated 2024-05-30 00:06:38 +05:30
e0cd7320e7 Merge branch 'godot-4.2' 2024-04-15 23:06:00 +05:30
9f8087e91d UV nodes documentation updated 2024-04-15 23:04:10 +05:30
0b22ea2ce1 Update Documentation.md 2024-04-15 22:53:59 +05:30
6bd06becac Update RoundedPolygon.md 2024-04-15 22:52:55 +05:30
2dadda73fc Procedural nodes documentation updated 2024-04-15 22:50:04 +05:30
8a036a2abf Maths node documentation updated 2024-04-15 22:29:35 +05:30
b7c13a973a Update Mesh.md 2024-04-15 22:20:05 +05:30
b1411a809c Artistic nodes documentation updated 2024-04-10 18:26:14 +05:30
7b3fe34b9b Update ContrastNode.md 2024-04-10 18:14:52 +05:30
f7e9fddd00 Update ContrastNode.md 2024-04-10 18:13:18 +05:30
9c9907580c Document typo 2024-04-10 18:13:08 +05:30
6576785b47 Merge branch 'godot-4.2' 2024-03-27 11:48:44 +05:30
57d3027b6c Update RayMarch.md 2024-03-27 11:44:59 +05:30
6f447b39af Update RayMarch.md 2024-03-27 11:25:12 +05:30
b9bd4c3a3d Ray marching node finalized 2024-03-27 11:23:17 +05:30
033b54ea93 Ray march node documentation added. 2024-03-27 11:21:47 +05:30
6b57a43325 Update .gitignore 2024-03-27 11:21:19 +05:30
f8c0bc1e4e Update RayMarch.md 2024-03-27 10:48:02 +05:30
e921ecebad Update SimpleNoise.gd
- Compilation error fixed.
2024-03-27 08:40:59 +05:30
0b9c1235fa Update VectorTransform.gdshaderinc 2024-03-26 21:16:07 +05:30
c4e47d37eb Update RayMarch.md 2024-03-26 11:00:59 +05:30
1d15214565 Ray march node added 2024-03-26 10:59:07 +05:30
6cfeaaec5e Update GyroidNoise.md 2024-03-26 10:52:51 +05:30
beeee0e556 Update GyroidNoise.md 2024-03-26 10:34:22 +05:30
a7467b8bfd Gyroid noise node added 2024-03-26 10:20:51 +05:30
4686b20c51 Chebyshev Distance node added 2024-03-19 19:47:24 +05:30
0d5c68fb1f Manhattan Distance node added 2024-03-19 19:43:02 +05:30
41f016feca Update Voronoi.gdshaderinc 2024-03-19 19:38:22 +05:30
55039f4c6b Update Voronoi.gdshaderinc 2024-03-19 18:40:25 +05:30
de8d5e472e Simple noise node revamped 2024-03-19 18:22:06 +05:30
600079e3e5 Voronoi node revamped 2024-03-19 13:03:56 +05:30
f06a680212 Update VectorTransform.gdshaderinc 2024-03-18 22:45:48 +05:30
217bf0a24e Merge branch 'godot-4.2' 2024-03-18 11:28:45 +05:30
ae40a2f349 Update Documentation.md 2024-03-15 13:32:34 +05:30
4844686953 Merge branch 'godot-4.2' 2024-03-14 19:30:47 +05:30
c51785f3b5 Artistic nodes finalized 2024-03-14 19:30:27 +05:30
9d7cf5e9e9 Update ReplaceColor.gd 2024-03-12 17:50:44 +05:30
8b3f23fbea Color mask node added 2024-03-12 17:47:32 +05:30
506b4c9563 Koch fractal node refactored 2024-03-12 16:55:37 +05:30
f0dad0ce8e White balance node added 2024-03-12 16:45:47 +05:30
088c80aa2b Artistic nodes code refactored 2024-03-12 16:45:35 +05:30
578a78df0b Saturation node added 2024-03-12 15:01:30 +05:30
6b62f15a7d Replace color node added 2024-03-12 14:58:22 +05:30
151e40d0fb Contrast node added 2024-03-12 12:30:05 +05:30
eaa074f68f Hue node added 2024-03-12 12:14:55 +05:30
64df7fb100 Update KochFractal.md 2024-03-11 12:18:29 +05:30
9ebc2ddf76 Update KochFractal.md 2024-03-11 12:13:56 +05:30
ba9ee716b4 Update KochFractal.md 2024-03-11 12:13:22 +05:30
b2ba78fa43 Koch Fractal node added 2024-03-11 12:11:57 +05:30
b41d1dff80 Documentation updated 2024-02-27 23:12:19 +05:30
7adea627e0 Wave nodes updated 2024-02-27 23:11:12 +05:30
bd86743d0f Documentation formatting 2024-02-27 22:39:14 +05:30
4cc91847ed Documentation formatting 2024-02-27 22:23:58 +05:30
23b35b99da Documentation added for Project and ProjectOnPlane 2024-02-27 22:22:36 +05:30
f83b238e5a ProjectOnPlane node added 2024-02-27 22:15:06 +05:30
0037db566e Project node added 2024-02-27 22:14:50 +05:30
8e9910a8d3 Merge branch 'godot-4.2' 2024-02-26 22:33:08 +05:30
154214e248 Update Documentation.md 2024-02-26 22:29:34 +05:30
2d187facab Update Documentation.md 2024-02-26 22:27:12 +05:30
4c6b6910fb Update Documentation.md 2024-02-26 22:18:45 +05:30
47c437f10c Update Documentation.md 2024-02-26 22:16:57 +05:30
e73385e903 Documentation overhaul 2024-02-26 22:13:45 +05:30
a4640eed2f Merge branch 'godot-4.2' 2024-02-22 16:25:44 +05:30
931fc113db Update README.md
Documentation updated
2024-02-22 16:23:43 +05:30
93f6927a1f #4 resolved 2024-02-22 16:21:09 +05:30
5cc50c533f Merge branch 'godot-4.2' 2024-02-13 21:04:17 +05:30
f8ea3cd71e Update README.md 2024-02-13 21:01:52 +05:30
3a05a667c9 Update MeshNode.gd
- Scale now outputs the expected result
2024-02-13 20:59:12 +05:30
571098f3d9 Merge branch 'godot-4.2' 2024-01-13 19:03:34 +05:30
d19bca6369 Update README.md 2024-01-13 19:00:18 +05:30
4125d1d412 NodeScaleWorld node refactored to Mesh node 2024-01-13 18:55:31 +05:30
2828af7503 VectorTransform node availability updated for shader modes 2024-01-12 18:49:41 +05:30
13971eeab6 Documentation for VectorTransform node added 2024-01-12 18:33:43 +05:30
d3397cf87c VectorTransform node finalized 2024-01-12 18:21:24 +05:30
4205904cb5 Issue #2 resolved 2024-01-12 16:53:06 +05:30
a0aaf91ef3 VectorTransform node initial implementation 2024-01-12 16:19:35 +05:30
64dead8a82 RotateUV node updated
- RotateUV node now has a much intuitive dropdown for Degrees and Radians.
2024-01-12 00:36:04 +05:30
fae913cea6 Create FUNDING.yml 2024-01-12 00:03:09 +05:30
120 changed files with 4257 additions and 1087 deletions

13
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,13 @@
# These are supported funding model platforms
github: DigvijaysinhGohil
patreon: DigvijaysinhG
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
# Godot 4+ specific ignores
.godot/
tests/
*.import

444
README.md
View File

@ -1,446 +1,6 @@
# Godot-Shader-Lib
Visual shader node library for Godot engine. The addon supports Godot versions 4.x!
Visual shader node library for Godot engine. Supports all 4.2.0+ versions!
Adds various extra nodes to use in built-in visual shader editor.
# Installation
Copy the contents of **_addons/ShaderLib_** into the same folder in your project. No activation needed. Custom visual shader nodes work the same way as standard visual shader nodes.
If you don't immediatly see new nodes under **_Addons_** category, simply reload your project.
# Uninstallation
Delete the contents of **_addons/ShaderLib_** folder from your project. Make sure to delete it using the Godot editor instead of your default file system program.
# Nodes documentation
<details open>
<summary><h1>Geometry nodes</h1></summary>
<details>
<summary><h3>Node Scale World node</h3></summary>
Provides accees to node scale in world space.
<hr>
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|scale|vec3|None|Node/object scale in world space|
___
</details>
</details>
<hr>
<details open>
<summary><h1>Maths nodes</h1></summary>
<details open>
<summary><h2>Wave</h2></summary>
<details>
<summary><h3>Noise Sine Wave node</h3></summary>
Returns the sine of the value of input <b><i>in</i></b>. For variance, psuedo-random noise is added to the amplitude of the sine wave, within a range determined by input <b><i>min max</i></b>.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|Dynamic vector|none|Input value|
|min max|vec2|none|Minimum and Maximum values for noise intensity|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|Dynamic vector|None|Output value|
___
</details>
<details>
<summary><h3>Sawtooth Wave node</h3></summary>
Returns a sawtooth wave from the value of input <b><i>in</i></b>. Resulting output values will be between -1 and 1.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|Dynamic vector|none|Input value|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|Dynamic vector|None|Output value|
___
</details>
<details>
<summary><h3>Square Wave node</h3></summary>
Returns a square wave from the value of input <b><i>in</i></b>. Resulting output values will be between -1 and 1.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|Dynamic vector|none|Input value|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|Dynamic vector|None|Output value|
___
</details>
<details>
<summary><h3>Triangle Wave node</h3></summary>
Returns a triangle wave from the value of input <b><i>in</i></b>. Resulting output values will be between -1 and 1.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|Dynamic vector|none|Input value|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|Dynamic vector|None|Output value|
___
</details>
</details>
</details>
<hr>
<details open>
<summary><h1>Procedural nodes</h1></summary>
<details>
<summary><h3>Checker Board node</h3></summary>
Generates a checkerboard of alternating colors between inputs <b><i>color A</i></b> and <b><i>color B</i></b> based on input UV.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|color a|vec3|none|First checker color|
|color b|vec3|none|Second checker color|
|frequency|vec2|none|Scale of checkerboard per axis|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|vec3|None|Output checkerboard value|
___
</details>
<details open>
<summary><h2>Noise</h2></summary>
<details>
<summary><h3>Gradient Noise node</h3></summary>
Generates a gradient, or Perlin noise based on input UV. The resulting <b><i>output</i></b> values will be between -1 and 1.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|scale|float|none|Noise scale|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|float|None|Output noise value|
___
</details>
<details>
<summary><h3>Pseudo Random Noise node</h3></summary>
Generates a pseudo random noise based on input seed. The resulting <b><i>output</i></b> values will be between 0 and 1.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|seed|float|none|Input seed|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|float|None|Output noise value|
___
</details>
<details>
<summary><h3>Simple Noise node</h3></summary>
Generates a simplex, or value noise based on input UV. The resulting <b><i>output</i></b> values will be between 0 and 1.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|scale|float|none|Noise scale|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|float|None|Output noise value|
___
</details>
<details>
<summary><h3>Voronoi node</h3></summary>
Generates a Voronoi or Worley noise based on input UV. Voronoi noise is generated by calculating distances between a pixel and a lattice of points. By offsetting these points by a pseudo-random number, controlled by <b><i>angle offset</i></b>, a cluster of cells can be generated.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|cell density|float|none|Density of generated cells|
|angle offset|float|none|Offset values for points|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|float|None|Output noise value|
|cells|float|None|Raw cell data|
___
</details>
</details>
<details open>
<summary><h2>Shapes</h2></summary>
<details>
<summary><h3>Ellipse node</h3></summary>
Generates an ellipse shape based on input UV at the size specified by inputs <b><i>width</i></b> and <b><i>height</i></b>. The generated shape can be offset or tiled by connecting a <b><i>TilingAndOffset</i></b> node. Note that in order to preserve the ability to offset the shape within the UV space the shape will not automatically repeat if tiled. To achieve a repeating dot effect first connect your <b><i>TilingAndOffset</i></b> output through a <b><i>Fract</i></b> node.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|width|float|none|Ellipse width|
|height|float|none|Ellipse height|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|float|None|Output ellipse value|
___
</details>
<details>
<summary><h3>Polygon node</h3></summary>
Generates a regular polygon shape based on input UV at the size specified by inputs <b><i>width</i></b> and <b><i>height</i></b>. The polygon's amount of sides is determined by input <b><i>sides</i></b>. The generated shape can be offset or tiled by connecting a <b><i>TilingAndOffset</i></b> node. Note that in order to preserve the ability to offset the shape within the UV space the shape will not automatically repeat if tiled. To achieve a repeating polygon effect first connect your <b><i>TilingAndOffset</i></b> output through a <b><i>Fract</i></b> node.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|sides|int|none|Number of sides of the polygon|
|width|float|none|Polygon width|
|height|float|none|Polygon height|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|float|None|Output polygon value|
___
</details>
<details>
<summary><h3>Rectangle node</h3></summary>
Generates a rectangle shape based on input UV at the size specified by inputs <b><i>width</i></b> and <b><i>height</i></b>. The generated shape can be offset or tiled by connecting a <b><i>TilingAndOffset</i></b> node. Note that in order to preserve the ability to offset the shape within the UV space the shape will not automatically repeat if tiled. To achieve a repeating rectangle effect first connect your <b><i>TilingAndOffset</i></b> output through a <b><i>Fract</i></b> node.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|width|float|none|Rectangle width|
|height|float|none|Rectangle height|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|float|None|Output rectangle value|
___
</details>
<details>
<summary><h3>Rounded Polygon node</h3></summary>
Generates a rounded polygon shape based on input UV at the size specified by inputs <b><i>width</i></b> and <b><i>height</i></b>. The polygon's amount of sides is determined by input <b><i>sides</i></b>. The radius of each corner is defined by input <b><i>roundnesss</i></b>. The generated shape can be offset or tiled by connecting a <b><i>TilingAndOffset</i></b> node. Note that in order to preserve the ability to offset the shape within the UV space the shape will not automatically repeat if tiled. To achieve a repeating rounded polygon effect first connect your <b><i>TilingAndOffset</i></b> output through a <b><i>Fract</i></b> node.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|width|float|none|Rounded polygon width|
|height|float|none|Rounded polygon height|
|sides|int|none|Number of sides of the polygon|
|roundness|float|none|Corner radius|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|float|None|Output rounded polygon value|
___
</details>
<details>
<summary><h3>Rounded Rectangle node</h3></summary>
Generates a rounded rectangle shape based on input UV at the size specified by inputs <b><i>width</i></b> and <b><i>height</i></b>. The radius of each corner is defined by input <b><i>radius</i></b>. The generated shape can be offset or tiled by connecting a <b><i>TilingAndOffset</i></b> node. Note that in order to preserve the ability to offset the shape within the UV space the shape will not automatically repeat if tiled. To achieve a repeating rounded rectangle effect first connect your <b><i>TilingAndOffset</i></b> output through a <b><i>Fract</i></b> node.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|width|float|none|Rounded rectangle width|
|height|float|none|Rounded rectangle height|
|radius|float|none|Corner radius|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|float|None|Output rounded rectangle value|
___
</details>
</details>
</details>
<hr>
<details open>
<summary><h1>UV nodes</h1></summary>
Default value for uv input will be vec2(0, 0) for shader modes <i>PARTICLES</i>, <i>SKY</i> and <i>FOG</i> to avoid errors becouse UV variable is not available for these modes.
<details>
<summary><h3>Flipbook node</h3></summary>
Creates a flipbook, or texture sheet animation, of the UVs supplied to input UV. The amount of tiles on the sheet are defined by the values of the inputs <b><i>rows</i></b> and <b><i>columns</i></b>.
This node can be used to create a texture animation functionality, commonly used for particle effects and sprites.<br><br><i>This node is only available in shader modes SPATIAL and CANVAS ITEM.</i>
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|rows|int|none|Amount of horizontal tiles in texture sheet|
|columns|int|none|Amount of vertical tiles in texture sheet|
|start frame|int|none|Start tile index texture sheet|
|end frame|int|none|End tile index texture sheet|
|anim speed|float|none|Animation speed|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|None|Output UV value|
___
</details>
<details>
<summary><h3>Parallax mapping node</h3></summary>
The Parallax Mapping node lets you create a parallax effect that displaces a Material's UVs to create the illusion of depth inside a Material.<br><br><i>This node is only available in shader modes SPATIAL and CANVAS ITEM.</i>
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|height map|sampler2D|none|Height map texture|
|amplitude|float|none|amplitude or depth of the effect|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|None|Output UV value|
___
</details>
<details>
<summary><h3>Radial Shear node</h3></summary>
Applies a radial shear warping effect similar to a wave to the value of input UV.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|center|vec2|none|Center reference point|
|strength|float|none|Strength of the effect|
|offset|vec2|none|Individual channel offsets|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|None|Output UV value|
___
</details>
<details>
<summary><h3>Rotate node</h3></summary>
Rotates value of input UV around a reference point defined by input <b><i>center</i></b> by the amount of input <b><i>rotation</i></b>.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|center|vec2|none|Center reference point|
|rotation|float|none|Rotation amount in radians|
|use degrees|bool|none|Use degrees instead of radians for <b><i>rotation</i></b> amount|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|None|Output UV value|
___
</details>
<details>
<summary><h3>Spherize node</h3></summary>
Applies a spherical warping effect similar to a fisheye camera lens to the value of input UV.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|center|vec2|none|Center reference point|
|strength|float|none|Strength of the effect|
|offset|vec2|none|Individual channel offsets|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|None|Output UV value|
___
</details>
<details>
<summary><h3>Swirl node</h3></summary>
Applies a swirl warping effect similar to a black hole to the value of input UV. Very similar to <b><i>Twirl node</b></i>, key difference is it uses the inverse of vector length (One minus).
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|center|vec2|none|Center reference point|
|strength|float|none|Strength of the effect|
|offset|vec2|none|Individual channel offsets|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|None|Output UV value|
___
</details>
<details>
<summary><h3>Tiling and Offset node</h3></summary>
Tiles and offsets the value of input UV by the inputs <b><i>tiling</i></b> and <b><i>offset</i></b> respectively. This is commonly used for detail maps and scrolling textures over TIME.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|tiling|vec2|none|Amount of tiling to apply per channel|
|offset|vec2|none|Amount of offset to apply per channel|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|None|Output UV value|
___
</details>
<details>
<summary><h3>Twirl node</h3></summary>
Applies a twirl warping effect similar to a black hole to the value of input UV. Very similar to <b><i>Swirl node</b></i>, key difference is it uses the length of a vector.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|center|vec2|none|Center reference point|
|strength|float|none|Strength of the effect|
|offset|vec2|none|Individual channel offsets|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|None|Output UV value|
___
</details>
</details>
[Documentation can be found here.](/documentation/Documentation.md)

View File

@ -1,11 +0,0 @@
vec3 geometry_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;
float _scale_x = length(_axis_x);
float _scale_y = length(_axis_y);
float _scale_z = length(_axis_z);
return vec3(_scale_x, _scale_y, _scale_z);
}

View File

@ -1,56 +0,0 @@
@tool
class_name VisualShaderNodeMathsNoiseSineWave extends VisualShaderNodeCustom
func _init() -> void:
set_input_port_default_value(1, Vector2(0.0, 1.0))
func _get_name() -> String:
return "NoiseSineWave"
func _get_category() -> String:
return "Maths/Wave"
func _get_description() -> String:
return "Returns the sine of the value of input in. For variance, psuedo-random noise is added to the amplitude of the sine wave, within a range determined by input min max."
func _get_return_icon_type() -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_4D
func _get_input_port_count() -> int:
return 2
func _get_input_port_name(port: int) -> String:
match port:
0:
return "in"
1, _:
return "min max"
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
match port:
0:
return PORT_TYPE_VECTOR_4D
1:
return PORT_TYPE_VECTOR_2D
return PORT_TYPE_SCALAR
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_4D
func _get_global_code(mode: Shader.Mode) -> String:
var code: String = preload("NoiseSineWave.gdshaderinc").code
return code
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var input: String = "vec4(0.0)"
if input_vars[0]:
input = input_vars[0]
var min_max: String = input_vars[1]
return output_vars[0] + " = noise_sine_wave(%s, %s);" % [input, min_max]

View File

@ -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);
}

View File

@ -1,38 +0,0 @@
@tool
class_name VisualShaderNodeMathsSawtoothWave extends VisualShaderNodeCustom
func _get_name() -> String:
return "SawtoothWave"
func _get_category() -> String:
return "Maths/Wave"
func _get_description() -> String:
return "Returns a sawtooth wave from the value of input in. Resulting output values will be between -1 and 1."
func _get_return_icon_type() -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_4D
func _get_input_port_count() -> int:
return 1
func _get_input_port_name(port: int) -> String:
return "in"
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_4D
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_4D
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var input: String = "vec4(0.0)"
if input_vars[0]:
input = input_vars[0]
return output_vars[0] + " = 2.0 * (%s - floor(0.5 + %s));" % [input, input]

View File

@ -1,39 +0,0 @@
@tool
class_name VisualShaderNodeMathsSquareWave extends VisualShaderNodeCustom
func _get_name() -> String:
return "SquareWave"
func _get_category() -> String:
return "Maths/Wave"
func _get_description() -> String:
return "Returns a square wave from the value of input in. Resulting output values will be between -1 and 1."
func _get_return_icon_type() -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_4D
func _get_input_port_count() -> int:
return 1
func _get_input_port_name(port: int) -> String:
return "input"
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_4D
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_4D
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var input: String = "vec4(0.0)"
if input_vars[0]:
input = input_vars[0]
return output_vars[0] + " = 1.0 - 2.0 * round(fract(%s));" % [input]

View File

@ -1,37 +0,0 @@
@tool
class_name VisualShaderNodeMathsTriangleWave extends VisualShaderNodeCustom
func _get_name() -> String:
return "TriangleWave"
func _get_category() -> String:
return "Maths/Wave"
func _get_description() -> String:
return "Returns a triangle wave from the value of input in. Resulting output values will be between -1 and 1."
func _get_return_icon_type() -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_4D
func _get_input_port_count() -> int:
return 1
func _get_input_port_name(port: int) -> String:
return "in"
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_4D
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_4D
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var input: String = "vec4(0.0)"
if input_vars[0]:
input = input_vars[0]
return output_vars[0] + " = 2.0 * abs(2.0 * (%s - floor(0.5 + %s))) - 1.0;" % [input, input]

View File

@ -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);
}

View File

@ -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;
}

View File

@ -1,32 +0,0 @@
float noise_random_value(vec2 uv){
return fract(sin(dot(uv.xy, vec2(12.9898,78.233))) * 43758.5453123);
}
float value_noise(vec2 uv){
vec2 _floor = floor(uv);
vec2 _fraction = fract(uv);
_fraction = _fraction * _fraction * (3.0 - 2.0 * _fraction);
vec2 _corner = vec2(1.0, 0.0);
float _c0 = noise_random_value(_floor + _corner.yy);
float _c1 = noise_random_value(_floor + _corner.xy);
float _c2 = noise_random_value(_floor + _corner.yx);
float _c3 = noise_random_value(_floor + _corner.xx);
vec2 _blur = smoothstep(0.0, 1.0, _fraction);
float mix_one = mix(_c0, _c1, _blur.x) + (_c2 - _c0) * _blur.y * (1.0 - _blur.x) + (_c3 - _c1) * _blur.x * _blur.y;
return mix_one;
}
float simple_noise(vec2 uv, float scale){
int octaves = 6;
float amplitude = 0.25;
float value = 0.0;
for(int i = 0; i < octaves; i++) {
value += amplitude * value_noise(scale * uv);
amplitude *= 0.85;
scale *= 3.0;
}
return value;
}

View File

@ -1,72 +0,0 @@
@tool
class_name VisualShaderNodeProceduralVoronoi extends VisualShaderNodeCustom
func _init() -> void:
_set_input_port_default_value(1, 5.0)
_set_input_port_default_value(2, 2.0)
output_port_for_preview = 0
func _get_name() -> String:
return "Voronoi"
func _get_category() -> String:
return "Procedural/Noise"
func _get_description() -> String:
return "Generates a Voronoi or Worley noise based on input UV."
func _get_return_icon_type() -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
func _get_input_port_count() -> int:
return 3
func _get_input_port_name(port: int) -> String:
match port:
0:
return "uv"
1:
return "cell density"
2:
return "angle offset"
return ""
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
match port:
0:
return PORT_TYPE_VECTOR_2D
1, 2:
return PORT_TYPE_SCALAR
return PORT_TYPE_SCALAR
func _get_output_port_count() -> int:
return 2
func _get_output_port_name(port: int) -> String:
match port:
0:
return "output"
1:
return "cells"
return ""
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("Voronoi.gdshaderinc").code
return code
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[0]:
uv = input_vars[0]
var cell_density: String = input_vars[1]
var angle_offset: String = input_vars[2]
var output: String = output_vars[0]
var cells: String = output_vars[1]
return "voronoi_noise(%s,%s, %s, %s, %s);" % [uv, cell_density, angle_offset, output, cells]

View File

@ -1,24 +0,0 @@
void voronoi_noise(vec2 uv, float cell_density, float angle_offset, out float output, out float cells){
vec2 _g = floor(uv * cell_density);
vec2 _f = fract(uv * cell_density);
vec3 _res = vec3(8.0, 0.0, 0.0);
mat2 _matrix = mat2(vec2(15.27, 47.63), vec2(99.41, 89.98));
for(int y=-1; y<=1; y++)
{
for(int x=-1; x<=1; x++)
{
vec2 lattice = vec2(float(x), float(y));
vec2 new_uv = lattice + _g;
new_uv = fract(sin(new_uv * _matrix) * 46839.32);
vec2 offset = vec2(sin(new_uv.y * angle_offset) * 0.5 + 0.5, cos(new_uv.x * angle_offset) * 0.5 + 0.5);
float d = distance(lattice + offset, _f);
if(d < _res.x)
{
_res = vec3(d, offset.x, offset.y);
output = _res.x;
cells = _res.y;
}
}
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -1,14 +0,0 @@
vec2 flipbook_uv(vec2 uv, int rows, int columns, int start_frame, int end_frame, float anim_speed){
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 -= _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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -1,10 +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);
}
vec2 _delta = uv - center;
float _x = cos(_angle) * _delta.x - sin(_angle) * _delta.y;
float _y = sin(_angle) * _delta.x + cos(_angle) * _delta.y;
return vec2(_x + center.x, _y + center.y);
}

View File

@ -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;
}

View File

@ -1,8 +0,0 @@
vec2 swirl_uv(vec2 uv, vec2 center, float strength, vec2 offset){
vec2 _delta = uv - center;
float _inverse_length = 1.0 - length(_delta);
float _angle = strength * _inverse_length;
float _x = cos(_angle) * _delta.x - sin(_angle) * _delta.y;
float _y = sin(_angle) * _delta.x + cos(_angle) * _delta.y;
return vec2(_x + center.x + offset.x, _y + center.y + offset.y);
}

View File

@ -1,7 +0,0 @@
vec2 twirl_uv(vec2 uv, vec2 center, float strength, vec2 offset){
vec2 _delta = uv - center;
float _angle = strength * length(_delta);
float _x = cos(_angle) * _delta.x - sin(_angle) * _delta.y;
float _y = sin(_angle) * _delta.x + cos(_angle) * _delta.y;
return vec2(_x + center.x + offset.x, _y + center.y + offset.y);
}

View File

@ -0,0 +1,59 @@
@tool
class_name VisualShaderNodeAdjustmentContrast extends ShaderLib
func _get_name() -> String:
return "Contrast"
func _get_category() -> String:
return "Artistic/Adjustment"
func _get_description() -> String:
return "Adjusts the contrast of input in by the amount of input contrast."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_input_port_count() -> int:
return 2
func _get_input_port_name(port: int) -> String:
match port:
0:
return "in"
_:
return "contrast"
func _get_input_port_type(port: int) -> PortType:
match port:
0:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return 1.0
_:
return Vector3(1.0, 1.0, 1.0)
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
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_%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)"
if input_vars[0]:
input = input_vars[0]
var contrast: String = input_vars[1]
return output_vars[0] + " = contrast(%s, %s);" % [input, contrast]

View File

@ -0,0 +1,72 @@
@tool
class_name VisualShaderNodeAdjustmentHue extends ShaderLib
func _get_name() -> String:
return "Hue"
func _get_category() -> String:
return "Artistic/Adjustment"
func _get_description() -> String:
return "Offsets the hue of input in by the amount of input offset."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_input_port_count() -> int:
return 2
func _get_input_port_name(port: int) -> String:
match port:
0:
return "in"
_:
return "offset"
func _get_input_port_type(port: int) -> PortType:
match port:
0:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return 0.0
_:
return Vector3(1.0, 1.0, 1.0)
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_property_count() -> int:
return 1
func _get_property_default_index(index: int) -> int:
return 0
func _get_property_name(index: int) -> String:
return "Range"
func _get_property_options(index: int) -> PackedStringArray:
return ["Degrees", "Normalize"]
func _get_global_code(mode: Shader.Mode) -> String:
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)
var input: String = "vec3(1.0)"
var offset: String = input_vars[1]
if input_vars[0]:
input = input_vars[0]
return output_vars[0] + " = hue(%s, %s, %s);" % [input, offset, range_index]

View File

@ -0,0 +1,77 @@
@tool
class_name VisualShaderNodeAdjustmentReplaceColor extends ShaderLib
func _get_name() -> String:
return "ReplaceColor"
func _get_category() -> String:
return "Artistic/Adjustment"
func _get_description() -> String:
return "Replaces values in input \"in\" equal to input \"from\" to the value of input \"to\"."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_input_port_count() -> int:
return 5
func _get_input_port_name(port: int) -> String:
match port:
0:
return "in"
1:
return "from"
2:
return "to"
3:
return "range"
_:
return "fuzziness"
func _get_input_port_type(port: int) -> PortType:
match port:
0, 1, 2:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1, 2:
return Vector3(0.0, 0.0, 0.0)
3, 4:
return 0.0
_:
return Vector3(1.0, 1.0, 1.0)
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
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_%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)"
var from: String = "vec3(1.0)"
var to: String = "vec3(1.0)"
if input_vars[0]:
input = input_vars[0]
if input_vars[1]:
from = input_vars[1]
if input_vars[2]:
to = input_vars[2]
var range: String = input_vars[3]
var fuzziness: String = input_vars[4]
return output_vars[0] + " = replace_color(%s, %s, %s, %s, %s);" % [input, from, to, range, fuzziness]

View File

@ -0,0 +1,60 @@
@tool
class_name VisualShaderNodeAdjustmentSaturation extends ShaderLib
func _get_name() -> String:
return "Saturation"
func _get_category() -> String:
return "Artistic/Adjustment"
func _get_description() -> String:
return "Adjusts the saturation of input \"in\" by the amount of input \"saturation\"."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_input_port_count() -> int:
return 2
func _get_input_port_name(port: int) -> String:
match port:
0:
return "in"
_:
return "saturation"
func _get_input_port_type(port: int) -> PortType:
match port:
0:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
0:
return Vector3(1.0, 1.0, 1.0)
_:
return 1.0
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
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_%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)"
if input_vars[0]:
input = input_vars[0]
var saturation = input_vars[1]
return output_vars[0] + " = saturation(%s, %s);" % [input, saturation]

View File

@ -0,0 +1,63 @@
@tool
class_name VisualShaderNodeWhiteBalance extends ShaderLib
func _get_name() -> String:
return "WhiteBalance"
func _get_category() -> String:
return "Artistic/Adjustment"
func _get_description() -> String:
return "Adjusts the temperature and tint of input \"in\" by the amount of inputs \"temperature\" and \"tint\" respectively."
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 "in"
1:
return "temperature"
_:
return "tint"
func _get_input_port_type(port: int) -> PortType:
match port:
0:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1, 2:
return 0.0
_:
return Vector3(1.0, 1.0, 1.0)
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
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_%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)"
if input_vars[0]:
input = input_vars[0]
var temperature: String = input_vars[1]
var tint: String = input_vars[2]
return output_vars[0] + " = white_balance(%s, %s, %s);" % [input, temperature, tint]

View File

@ -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.));
}

View File

@ -0,0 +1,68 @@
@tool
class_name VisualShaderNodeMaskColorMask extends ShaderLib
func _get_name() -> String:
return "ColorMask"
func _get_category() -> String:
return "Artistic/Mask"
func _get_description() -> String:
return "Creates a mask from values in input \"in\" equal to input \"mask color\"."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_VECTOR_4D
func _get_input_port_count() -> int:
return 4
func _get_input_port_name(port: int) -> String:
match port:
0:
return "in"
1:
return "color mask"
2:
return "range"
_:
return "fuzziness"
func _get_input_port_type(port: int) -> PortType:
match port:
0, 1:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
0:
return Vector3(1.0, 1.0, 1.0)
1:
return Vector3(0.0, 0.0, 0.0)
_:
return 0.0
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
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_%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)"
if input_vars[0]:
input = input_vars[0]
var color_mask: String = input_vars[1]
var range: String = input_vars[2]
var fuzziness: String = input_vars[3]
return output_vars[0] + " = color_mask(%s, %s, %s, %s);" % [input, color_mask, range, fuzziness]

View File

@ -0,0 +1,11 @@
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;
float scale_x = length(axis_x);
float scale_y = length(axis_y);
float scale_z = length(axis_z);
return vec3(scale_x, scale_y, scale_z);
}

View File

@ -1,8 +1,8 @@
@tool
class_name VisualShaderNodeGeometryNodeScaleWorld extends VisualShaderNodeCustom
class_name VisualShaderNodeGeometryMeshNode extends ShaderLib
func _get_name() -> String:
return "NodeScaleWorld"
return "MeshNode"
func _get_category() -> String:
return "Geometry"
@ -20,10 +20,14 @@ func _get_return_icon_type() -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_3D
func _get_output_port_count() -> int:
return 1
return 2
func _get_output_port_name(port: int) -> String:
return "scale"
match port:
0:
return "position"
_:
return "scale"
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_3D
@ -38,8 +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("NodeScaleWorld.gdshaderinc").code
return code
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:
return output_vars[0] + " = geometry_node_scale_world(MODEL_MATRIX);"
var code: String
code = "%s = NODE_POSITION_WORLD;" % output_vars[0]
code += "\n%s = node_scale_world(MODEL_MATRIX);" % output_vars[1]
return code

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Digvijaysinh Gohil
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,61 @@
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);
}
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.;
}

View File

@ -0,0 +1,55 @@
@tool
class_name VisualShaderNodeScalarSmoothMax extends ShaderLib
func _get_name() -> String:
return "SmoothMax"
func _get_category() -> String:
return "Maths/Scalar"
func _get_description() -> String:
return "Returns the maximum value between A and B, but smooths out the intersections of A and B based on T."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_SCALAR
func _get_input_port_count() -> int:
return 3
func _get_input_port_name(port: int) -> String:
match port:
0:
return "a"
1:
return "b"
_:
return "t"
func _get_input_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
2:
return 0.5
_:
return 0.0
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "op"
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/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]
var b: String = input_vars[1]
var t: String = input_vars[2]
return output_vars[0] + " = smoothmax(%s, %s, %s);" % [a, b, t]

View File

@ -0,0 +1,55 @@
@tool
class_name VisualShaderNodeScalarSmoothMin extends ShaderLib
func _get_name() -> String:
return "SmoothMin"
func _get_category() -> String:
return "Maths/Scalar"
func _get_description() -> String:
return "Returns the minimum value between A and B, but smooths out the intersections of A and B based on T."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_SCALAR
func _get_input_port_count() -> int:
return 3
func _get_input_port_name(port: int) -> String:
match port:
0:
return "a"
1:
return "b"
_:
return "t"
func _get_input_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
2:
return 0.5
_:
return 0.0
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "op"
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/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]
var b: String = input_vars[1]
var t: String = input_vars[2]
return output_vars[0] + " = smoothmin(%s, %s, %s);" % [a, b, t]

View File

@ -0,0 +1,94 @@
@tool
class_name VisualShaderNodeMathsChebyshevDistance extends ShaderLib
func _get_name() -> String:
return "ChebyshevDistance"
func _get_category() -> String:
return "Maths/Vector/Distance"
func _get_description() -> String:
return "Returns the distance between two points using Chebyshev distance matrix."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_SCALAR
func _get_input_port_count() -> int:
return 3
func _get_input_port_name(port: int) -> String:
match port:
0:
return "a"
1:
return "b"
_:
return "power"
func _get_input_port_type(port: int) -> PortType:
var vector_index: int = get_option_index(0)
match port:
2:
return PORT_TYPE_SCALAR
_:
match vector_index:
0:
return PORT_TYPE_VECTOR_2D
_:
return PORT_TYPE_VECTOR_3D
func _get_input_port_default_value(port: int) -> Variant:
match port:
2:
return 2.0
_:
return null
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "distance"
func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
func _get_property_count() -> int:
return 1
func _get_property_name(index: int) -> String:
return ""
func _get_property_default_index(index: int) -> int:
return 0
func _get_property_options(index: int) -> PackedStringArray:
return ["Vector2", "Vector3"]
func _get_global_code(mode: Shader.Mode) -> String:
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
var point_b: String
var power: String = input_vars[2]
var vector_index: int = get_option_index(0)
match vector_index:
0:
point_a = "vec2(0)"
point_b = "vec2(0)"
_:
point_b = "vec3(0)"
point_a = "vec3(0)"
if input_vars[0]:
point_a = input_vars[0]
if input_vars[1]:
point_b = input_vars[1]
match vector_index:
0:
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]

View File

@ -0,0 +1,80 @@
@tool
class_name VisualShaderNodeMathsManhattanDistance extends ShaderLib
func _get_name() -> String:
return "ManhattanDistance"
func _get_category() -> String:
return "Maths/Vector/Distance"
func _get_description() -> String:
return "Returns the distance between two points using Manhattan distance matrix."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_SCALAR
func _get_input_port_count() -> int:
return 2
func _get_input_port_name(port: int) -> String:
match port:
0:
return "a"
_:
return "b"
func _get_input_port_type(port: int) -> PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_VECTOR_2D
_:
return PORT_TYPE_VECTOR_3D
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "distance"
func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
func _get_property_count() -> int:
return 1
func _get_property_name(index: int) -> String:
return ""
func _get_property_default_index(index: int) -> int:
return 0
func _get_property_options(index: int) -> PackedStringArray:
return ["Vector2", "Vector3"]
func _get_global_code(mode: Shader.Mode) -> String:
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
var point_b: String
var vector_index: int = get_option_index(0)
match vector_index:
0:
point_a = "vec2(0)"
point_b = "vec2(0)"
_:
point_b = "vec3(0)"
point_a = "vec3(0)"
if input_vars[0]:
point_a = input_vars[0]
if input_vars[1]:
point_b = input_vars[1]
match vector_index:
0:
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]

View File

@ -0,0 +1,77 @@
@tool
class_name VisualShaderNodeVectorProject extends ShaderLib
func _get_name() -> String:
return "Project"
func _get_category() -> String:
return "Maths/Vector"
func _get_description() -> String:
return "Projects vector A onto vector B."
func _get_return_icon_type() -> PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_VECTOR_2D
_:
return PORT_TYPE_VECTOR_3D
func _get_input_port_count() -> int:
return 2
func _get_input_port_name(port: int) -> String:
match port:
0:
return "vector A"
_:
return "vector B"
func _get_input_port_type(port: int) -> PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_VECTOR_2D
_:
return PORT_TYPE_VECTOR_3D
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "vector"
func _get_output_port_type(port: int) -> PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_VECTOR_2D
_:
return PORT_TYPE_VECTOR_3D
func _get_property_count() -> int:
return 1
func _get_property_default_index(index: int) -> int:
return 0
func _get_property_name(index: int) -> String:
return ""
func _get_property_options(index: int) -> PackedStringArray:
return ["Vector2", "Vector3"]
func _get_global_code(mode: Shader.Mode) -> String:
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]
var vector_b: String = input_vars[1]
var vector_index: int = get_option_index(0)
match vector_index:
0:
return output_vars[0] + " = project_2d(%s, %s);" % [vector_a, vector_b]
_:
return output_vars[0] + " = project_3d(%s, %s);" % [vector_a, vector_b]

View File

@ -0,0 +1,44 @@
@tool
class_name VisualShaderNodeVectorProjectOnPlane extends ShaderLib
func _get_name() -> String:
return "ProjectOnPlane"
func _get_category() -> String:
return "Maths/Vector"
func _get_description() -> String:
return "Projects a vector onto a plane defined by a normal orthogonal to the plane."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_input_port_count() -> int:
return 2
func _get_input_port_name(port: int) -> String:
match port:
0:
return "vector"
_:
return "plane normal"
func _get_input_port_type(port: int) -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "vector"
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_%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]
var plane_normal: String = input_vars[1]
return output_vars[0] + " = project_on_plane(%s, %s);" % [vector_a, plane_normal]

View File

@ -0,0 +1,153 @@
@tool
class_name VisualShaderNodeVectorTransform extends ShaderLib
func _get_name() -> String:
return "VectorTransform"
func _get_category() -> String:
return "Maths/Vector"
func _get_description() -> String:
return "Returns the transformed vector of the input value from one coordinate space to another."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_input_port_count() -> int:
return 1
func _get_input_port_name(port: int) -> String:
return "in"
func _get_input_port_type(port: int) -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_VECTOR_3D
func _get_property_count() -> int:
return 3
func _get_property_default_index(index: int) -> int:
match index:
0, 1:
return 0
_:
return 1
func _get_property_name(index: int) -> String:
match index:
0:
return "Vector Type"
1:
return "From"
_:
return "To"
func _get_property_options(index: int) -> PackedStringArray:
match index:
0:
return ["Positional", "Directional"]
_:
return ["Local", "World", "View", "Clip", "Tangent"]
func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool:
return mode == Shader.MODE_SPATIAL
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var code: String
var vector_type: int = get_option_index(0)
var from_coord_space_index: int = get_option_index(1)
var to_coord_space_index: int = get_option_index(2)
var input_vector: String = input_vars[0] if input_vars[0] else "vec3(0.0, 0.0, 0.0)"
var w_component: String = "1.0" if vector_type == 0 else "0.0"
match from_coord_space_index:
0:
match to_coord_space_index:
0:
code = "%s = %s;" % [output_vars[0], input_vector]
1:
code = "%s = (MODEL_MATRIX * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
2:
code = "%s = (VIEW_MATRIX * MODEL_MATRIX * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
3:
code = "%s = (PROJECTION_MATRIX * VIEW_MATRIX * MODEL_MATRIX * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
4:
code = """
vec3 normal = (inverse(MODEL_MATRIX) * INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz;
mat4 local_to_tangent_mat = mat4(vec4(TANGENT, 1.0), vec4(BINORMAL, 1.0), vec4(normal, 1.0), vec4(0.0, 0.0, 0.0, 1.0));
"""
code += "%s = (local_to_tangent_mat * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
1:
match to_coord_space_index:
0:
code = "%s = (inverse(MODEL_MATRIX) * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
1:
code = "%s = %s;" % [output_vars[0], input_vector]
2:
code = "%s = (VIEW_MATRIX * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
3:
code = "%s =(PROJECTION_MATRIX * VIEW_MATRIX * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
4:
code = """
vec3 normal = (inverse(MODEL_MATRIX) * INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz;
mat4 local_to_tangent_mat = mat4(vec4(TANGENT, 1.0), vec4(BINORMAL, 1.0), vec4(normal, 1.0), vec4(0.0, 0.0, 0.0, 1.0));
"""
code += "%s = (local_to_tangent_mat * inverse(MODEL_MATRIX) * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
2:
match to_coord_space_index:
0:
code = "%s = (inverse(MODEL_MATRIX) * INV_VIEW_MATRIX * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
1:
code = "%s = (INV_VIEW_MATRIX * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
2:
code = "%s = %s;" % [output_vars[0], input_vector]
3:
code = "%s = (PROJECTION_MATRIX * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
4:
code = """
vec3 normal = (inverse(MODEL_MATRIX) * INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz;
mat4 local_to_tangent_mat = mat4(vec4(TANGENT, 1.0), vec4(BINORMAL, 1.0), vec4(normal, 1.0), vec4(0.0, 0.0, 0.0, 1.0));
"""
code += "%s = (local_to_tangent_mat * inverse(MODEL_MATRIX) * INV_VIEW_MATRIX * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
3:
match to_coord_space_index:
0:
code = "%s = (inverse(MODEL_MATRIX) * INV_VIEW_MATRIX * INV_PROJECTION_MATRIX * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
1:
code = "%s = (INV_VIEW_MATRIX * INV_PROJECTION_MATRIX * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
2:
code = "%s = (INV_PROJECTION_MATRIX * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
3:
code = "%s = %s;" % [output_vars[0], input_vector]
4:
code = """
vec3 normal = (inverse(MODEL_MATRIX) * INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz;
mat4 local_to_tangent_mat = mat4(vec4(TANGENT, 1.0), vec4(BINORMAL, 1.0), vec4(normal, 1.0), vec4(0.0, 0.0, 0.0, 1.0));
"""
code += "%s = (local_to_tangent_mat * inverse(MODEL_MATRIX) * INV_VIEW_MATRIX * INV_PROJECTION_MATRIX * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
4:
code = """
vec3 normal = (inverse(MODEL_MATRIX) * INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz;
mat4 tangent_to_local_mat = inverse(mat4(vec4(TANGENT, 1.0), vec4(BINORMAL, 1.0), vec4(normal, 1.0), vec4(0.0, 0.0, 0.0, 1.0)));
"""
match to_coord_space_index:
0:
code += "%s = (tangent_to_local_mat * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
1:
code += "%s = (MODEL_MATRIX * tangent_to_local_mat * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
2:
code += "%s = (VIEW_MATRIX * MODEL_MATRIX * tangent_to_local_mat * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
3:
code += "%s = (PROJECTION_MATRIX * VIEW_MATRIX * MODEL_MATRIX * tangent_to_local_mat * vec4(%s, %s)).xyz;" % [output_vars[0], input_vector, w_component]
4:
code = "%s = %s;" % [output_vars[0], input_vector]
return code

View File

@ -0,0 +1,118 @@
@tool
class_name VisualShaderNodeMathsNoiseSineWave extends ShaderLib
func _get_name() -> String:
return "NoiseSineWave"
func _get_category() -> String:
return "Maths/Wave"
func _get_description() -> String:
return "Returns the sine of the value of input in. For variance, psuedo-random noise is added to the amplitude of the sine wave, within a range determined by input min max."
func _get_return_icon_type() -> VisualShaderNode.PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_SCALAR
1:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_VECTOR_4D
func _get_input_port_count() -> int:
return 2
func _get_input_port_name(port: int) -> String:
match port:
0:
return "in"
1, _:
return "min max"
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
match port:
0:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_SCALAR
1:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_VECTOR_4D
1:
return PORT_TYPE_VECTOR_2D
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return Vector2(0.0, 1.0)
_:
return null
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_SCALAR
1:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_VECTOR_4D
func _get_property_count() -> int:
return 1
func _get_property_default_index(index: int) -> int:
return 0
func _get_property_name(index: int) -> String:
return ""
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_%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
var vector_index: int = get_option_index(0)
match vector_index:
0:
input = "0.0"
1:
input = "vec2(0.0)"
2:
input = "vec3(0.0)"
_:
input = "vec4(0.0)"
if input_vars[0]:
input = input_vars[0]
var min_max: String = input_vars[1]
match vector_index:
0:
return output_vars[0] + " = noise_sine_wave(vec4(%s), %s).x;" % [input, min_max]
1:
return output_vars[0] + " = noise_sine_wave(vec4(%s, 0.0, 0.0), %s).xy;" % [input, min_max]
2:
return output_vars[0] + " = noise_sine_wave(vec4(%s, 0.0), %s).xyz;" % [input, min_max]
_:
return output_vars[0] + " = noise_sine_wave(%s, %s);" % [input, min_max]

View File

@ -0,0 +1,100 @@
@tool
class_name VisualShaderNodeMathsSawtoothWave extends ShaderLib
func _get_name() -> String:
return "SawtoothWave"
func _get_category() -> String:
return "Maths/Wave"
func _get_description() -> String:
return "Returns a sawtooth wave from the value of input in. Resulting output values will be between -1 and 1."
func _get_return_icon_type() -> VisualShaderNode.PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_SCALAR
1:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_VECTOR_4D
func _get_input_port_count() -> int:
return 1
func _get_input_port_name(port: int) -> String:
return "in"
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_SCALAR
1:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_VECTOR_4D
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_SCALAR
1:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_VECTOR_4D
func _get_property_count() -> int:
return 1
func _get_property_default_index(index: int) -> int:
return 0
func _get_property_name(index: int) -> String:
return ""
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_%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
var vector_index: int = get_option_index(0)
match vector_index:
0:
input = "0.0"
1:
input = "vec2(0.0)"
2:
input = "vec3(0.0)"
_:
input = "vec4(0.0)"
if input_vars[0]:
input = input_vars[0]
match vector_index:
0:
return output_vars[0] + " = sawtooth_wave(vec4(%s)).x;" % [input]
1:
return output_vars[0] + " = sawtooth_wave(vec4(%s, 0.0, 0.0)).xy;" % [input]
2:
return output_vars[0] + " = sawtooth_wave(vec4(%s, 0.0)).xyz;" % [input]
_:
return output_vars[0] + " = sawtooth_wave(%s);" % [input]

View File

@ -0,0 +1,101 @@
@tool
class_name VisualShaderNodeMathsSquareWave extends ShaderLib
func _get_name() -> String:
return "SquareWave"
func _get_category() -> String:
return "Maths/Wave"
func _get_description() -> String:
return "Returns a square wave from the value of input in. Resulting output values will be between -1 and 1."
func _get_return_icon_type() -> VisualShaderNode.PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_SCALAR
1:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_VECTOR_4D
func _get_input_port_count() -> int:
return 1
func _get_input_port_name(port: int) -> String:
return "input"
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_SCALAR
1:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_VECTOR_4D
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_SCALAR
1:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_VECTOR_4D
func _get_property_count() -> int:
return 1
func _get_property_default_index(index: int) -> int:
return 0
func _get_property_name(index: int) -> String:
return ""
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_%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
var vector_index: int = get_option_index(0)
match vector_index:
0:
input = "0.0"
1:
input = "vec2(0.0)"
2:
input = "vec3(0.0)"
_:
input = "vec4(0.0)"
if input_vars[0]:
input = input_vars[0]
match vector_index:
0:
return output_vars[0] + " = square_wave(vec4(%s)).x;" % [input]
1:
return output_vars[0] + " = square_wave(vec4(%s, 0.0, 0.0)).xy;" % [input]
2:
return output_vars[0] + " = square_wave(vec4(%s, 0.0)).xyz;" % [input]
_:
return output_vars[0] + " = square_wave(%s);" % [input]

View File

@ -0,0 +1,99 @@
@tool
class_name VisualShaderNodeMathsTriangleWave extends ShaderLib
func _get_name() -> String:
return "TriangleWave"
func _get_category() -> String:
return "Maths/Wave"
func _get_description() -> String:
return "Returns a triangle wave from the value of input in. Resulting output values will be between -1 and 1."
func _get_return_icon_type() -> VisualShaderNode.PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_SCALAR
1:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_VECTOR_4D
func _get_input_port_count() -> int:
return 1
func _get_input_port_name(port: int) -> String:
return "in"
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_SCALAR
1:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_VECTOR_4D
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "out"
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
var vector_index: int = get_option_index(0)
match vector_index:
0:
return PORT_TYPE_SCALAR
1:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_VECTOR_3D
_:
return PORT_TYPE_VECTOR_4D
func _get_property_count() -> int:
return 1
func _get_property_default_index(index: int) -> int:
return 0
func _get_property_name(index: int) -> String:
return ""
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_%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
var vector_index: int = get_option_index(0)
match vector_index:
0:
input = "0.0"
1:
input = "vec2(0.0)"
2:
input = "vec3(0.0)"
_:
input = "vec4(0.0)"
if input_vars[0]:
input = input_vars[0]
match vector_index:
0:
return output_vars[0] + " = triangle_wave(vec4(%s)).x;" % [input]
1:
return output_vars[0] + " = triangle_wave(vec4(%s, 0.0, 0.0)).xy;" % [input]
2:
return output_vars[0] + " = triangle_wave(vec4(%s, 0.0)).xyz;" % [input]
_:
return output_vars[0] + " = triangle_wave(%s);" % [input]

View File

@ -1,11 +1,7 @@
@tool
class_name VisualShaderNodeProceduralCheckerBoard extends VisualShaderNodeCustom
class_name VisualShaderNodeProceduralCheckerBoard extends ShaderLib
func _init() -> void:
_set_input_port_default_value(1, Vector3(1.0, 1.0, 1.0))
_set_input_port_default_value(2, Vector3(0.4, 0.4, 0.4))
_set_input_port_default_value(3, Vector2(1.0, 1.0))
output_port_for_preview = 0
func _get_name() -> String:
@ -43,6 +39,17 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_3D
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return Vector3(1.0, 1.0, 1.0)
2:
return Vector3(0.4, 0.4, 0.4)
3:
return Vector2(1.0, 1.0)
_:
return null
func _get_output_port_count() -> int:
return 1
@ -53,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_%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"
@ -66,4 +72,4 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad
var color_b: String = input_vars[2]
var frequency: String = input_vars[3]
return output_vars[0] + " = checker_board(%s, %s, %s, %s);" % [uv, color_a, color_b, frequency]
return output_vars[0] + " = checker_board(%s, %s.xyz, %s.xyz, %s);" % [uv, color_a, color_b, frequency]

View File

@ -0,0 +1,84 @@
@tool
class_name VisualShaderNodeProceduralKochFractal extends ShaderLib
func _init() -> void:
output_port_for_preview = 0
func _get_name() -> String:
return "KochFractal"
func _get_category() -> String:
return "Procedural/Fractals"
func _get_description() -> String:
return "Generates an koch curve similar to ice fractal shape based on input UV at the size specified by inputs width and height."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_SCALAR
func _get_input_port_count() -> int:
return 5
func _get_input_port_name(port: int) -> String:
match port:
0:
return "uv"
1:
return "thickness"
2:
return "iterations"
3:
return "widht"
_:
return "height"
func _get_input_port_type(port: int) -> PortType:
match port:
0:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_SCALAR_INT
_:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1, 3, 4:
return 1.0
2:
return 3
_:
return null
func _get_output_port_count() -> int:
return 2
func _get_output_port_name(port: int) -> String:
match port:
0:
return "out"
_:
return "uv"
func _get_output_port_type(port: int) -> PortType:
match port:
1:
return PORT_TYPE_VECTOR_2D
_:
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:
var uv: String = "UV"
if input_vars[0]:
uv = input_vars[0]
var thickness: String = input_vars[1]
var iterations: String = input_vars[2]
var width: String = input_vars[3]
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]]

View File

@ -0,0 +1,65 @@
@tool
class_name VisualShaderNodeProceduralHeightToNormal extends ShaderLib
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_%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"
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]

View File

@ -1,9 +1,7 @@
@tool
class_name VisualShaderNodeProceduralGradientNoise extends VisualShaderNodeCustom
class_name VisualShaderNodeProceduralGradientNoise extends ShaderLib
func _init() -> void:
set_input_port_default_value(1, 10.0)
output_port_for_preview = 0
func _get_name() -> String:
@ -37,6 +35,13 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return 10.0
_:
return null
func _get_output_port_count() -> int:
return 1
@ -47,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_%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"

View File

@ -0,0 +1,78 @@
@tool
class_name VisualShaderNodeProceduralGyroidNoise extends ShaderLib
func _init() -> void:
output_port_for_preview = 0
func _get_name() -> String:
return "GyroidNoise"
func _get_category() -> String:
return "Procedural/Noise"
func _get_description() -> String:
return "Generates a gyroid noise based on input UV."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_SCALAR
func _get_input_port_count() -> int:
return 5
func _get_input_port_name(port: int) -> String:
match port:
0:
return "uv"
1:
return "scale"
2:
return "ratio"
3:
return "height"
_:
return "thickness"
func _get_input_port_type(port: int) -> PortType:
match port:
0, 2:
return PORT_TYPE_VECTOR_2D
_:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return 2.0
2:
return Vector2(1, 1)
3:
return 0.5
4:
return 0.0
_:
return null
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "output"
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:
var uv: String = "UV"
if input_vars[0]:
uv = input_vars[0]
var scale: String = input_vars[1]
var ratio: String = input_vars[2]
var height: String = input_vars[3]
var thickness: String = input_vars[4]
return output_vars[0] + " = gyroid_noise(%s, %s, %s, %s, %s);" % [uv, scale, ratio, height, thickness]

View File

@ -1,8 +1,7 @@
@tool
class_name VisualShaderNodePseudoRandomNoise extends VisualShaderNodeCustom
class_name VisualShaderNodePseudoRandomNoise extends ShaderLib
func _init() -> void:
set_input_port_default_value(0, 0.0)
output_port_for_preview = 0
func _get_name() -> String:
@ -26,6 +25,13 @@ func _get_input_port_name(port: int) -> String:
func _get_input_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
0:
return 0.0
_:
return null
func _get_output_port_count() -> int:
return 1
@ -35,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] + " = 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]

View File

@ -1,9 +1,7 @@
@tool
class_name VisualShaderNodeProceduralSimpleNoise extends VisualShaderNodeCustom
class_name VisualShaderNodeProceduralSimpleNoise extends ShaderLib
func _init() -> void:
set_input_port_default_value(1, 10.0)
output_port_for_preview = 0
func _get_name() -> String:
@ -19,7 +17,7 @@ func _get_return_icon_type() -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
func _get_input_port_count() -> int:
return 2
return 3
func _get_input_port_name(port: int) -> String:
match port:
@ -27,7 +25,8 @@ func _get_input_port_name(port: int) -> String:
return "uv"
1:
return "scale"
return ""
_:
return "octaves"
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
match port:
@ -35,7 +34,17 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_2D
1:
return PORT_TYPE_SCALAR
return PORT_TYPE_SCALAR
_:
return PORT_TYPE_SCALAR_INT
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return 10.0
2:
return 6
_:
return null
func _get_output_port_count() -> int:
return 1
@ -47,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_%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"
@ -57,5 +65,6 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad
uv = input_vars[0]
var scale: String = input_vars[1]
var octaves: String = input_vars[2]
return output_vars[0] + " = simple_noise(%s, %s);" % [uv, scale]
return output_vars[0] + " = simple_noise(%s, %s, %s);" % [uv, scale, octaves]

View File

@ -0,0 +1,124 @@
@tool
class_name VisualShaderNodeProceduralVoronoi extends ShaderLib
func _get_name() -> String:
return "Voronoi"
func _get_category() -> String:
return "Procedural/Noise"
func _get_description() -> String:
return "Generates a Voronoi or Worley noise based on input UV."
func _get_return_icon_type() -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
func _get_input_port_count() -> int:
var distance_index: int = get_option_index(0)
match distance_index:
2:
return 4
_:
return 3
func _get_input_port_name(port: int) -> String:
var distance_index: int = get_option_index(0)
match distance_index:
2:
match port:
0:
return "uv"
1:
return "cell density"
2:
return "angle offset"
_:
return "chebyshev power"
_:
match port:
0:
return "uv"
1:
return "cell density"
_:
return "angle offset"
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
match port:
0:
return PORT_TYPE_VECTOR_2D
_:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
var distance_index: int = get_option_index(0)
match distance_index:
2:
match port:
1:
return 5.0
2:
return 2.0
3:
return 5.0
_:
return null
_:
match port:
1:
return 5.0
2:
return 2.0
_:
return null
func _get_output_port_count() -> int:
return 2
func _get_output_port_name(port: int) -> String:
match port:
0:
return "output"
_:
return "cells"
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
func _get_property_count() -> int:
return 1
func _get_property_name(index: int) -> String:
return "Distance"
func _get_property_default_index(index: int) -> int:
return 0
func _get_property_options(index: int) -> PackedStringArray:
return ["Euclidean", "Manhattan", "Chebyshev"]
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:
var uv: String = "UV"
if input_vars[0]:
uv = input_vars[0]
var distance_index: int = get_option_index(0)
var cell_density: String = input_vars[1]
var angle_offset: String = input_vars[2]
var output: String = output_vars[0]
var cells: String = output_vars[1]
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]

View File

@ -0,0 +1,285 @@
#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;
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);
}
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);
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 = 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;
cell_id = voronoi_random_vector(grid_id + offset);
}
}
}
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) {
float dist = length((uv * 2.0 - 1.0) / vec2(width, height));
return clamp((1.0 - dist) / fwidth(dist), 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 dist = cos(floor(0.5 + polar_coords / radius) * radius - polar_coords) * length(uv);
return clamp((1.0 - dist) / fwidth(dist), 0.0, 1.0);
}
float rectangle_shape(vec2 uv, float width, float height) {
vec2 dist = abs(uv * 2.0 - 1.0) - vec2(width, height);
dist = 1.0 - dist / fwidth(dist);
return clamp(min(dist.x, dist.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 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);
}

View File

@ -1,10 +1,7 @@
@tool
class_name VisualShaderNodeProceduralEllipse extends VisualShaderNodeCustom
class_name VisualShaderNodeProceduralEllipse extends ShaderLib
func _init() -> void:
_set_input_port_default_value(1, 0.5)
_set_input_port_default_value(2, 0.5)
output_port_for_preview = 0
func _get_name() -> String:
@ -40,6 +37,13 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1, 2:
return 0.5
_:
return null
func _get_output_port_count() -> int:
return 1
@ -50,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_%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"

View File

@ -1,11 +1,7 @@
@tool
class_name VisualShaderNodeProceduralPolygon extends VisualShaderNodeCustom
class_name VisualShaderNodeProceduralPolygon extends ShaderLib
func _init() -> void:
_set_input_port_default_value(1, 3)
_set_input_port_default_value(2, 0.5)
_set_input_port_default_value(3, 0.5)
output_port_for_preview = 0
func _get_name() -> String:
@ -45,6 +41,15 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return 3
2, 3:
return 0.5
_:
return null
func _get_output_port_count() -> int:
return 1
@ -55,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_%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"

View File

@ -1,10 +1,7 @@
@tool
class_name VisualShaderNodeProceduralRectangle extends VisualShaderNodeCustom
class_name VisualShaderNodeProceduralRectangle extends ShaderLib
func _init() -> void:
_set_input_port_default_value(1, 0.5)
_set_input_port_default_value(2, 0.5)
output_port_for_preview = 0
func _get_name() -> String:
@ -40,6 +37,13 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1, 2:
return 0.5
_:
return null
func _get_output_port_count() -> int:
return 1
@ -50,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_%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"

View File

@ -1,12 +1,7 @@
@tool
class_name VisualShaderNodeProceduralRoundedPolygon extends VisualShaderNodeCustom
class_name VisualShaderNodeProceduralRoundedPolygon extends ShaderLib
func _init() -> void:
_set_input_port_default_value(1, 0.5)
_set_input_port_default_value(2, 0.5)
_set_input_port_default_value(3, 3)
_set_input_port_default_value(4, 1.0)
output_port_for_preview = 0
func _get_name() -> String:
@ -45,6 +40,17 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
_:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1, 2:
return 0.5
3:
return 3
4:
return 1.0
_:
return null
func _get_output_port_count() -> int:
return 1
@ -55,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_%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"

View File

@ -1,11 +1,7 @@
@tool
class_name VisualShaderNodeProceduralRoundedRectangle extends VisualShaderNodeCustom
class_name VisualShaderNodeProceduralRoundedRectangle extends ShaderLib
func _init() -> void:
_set_input_port_default_value(1, 0.5)
_set_input_port_default_value(2, 0.5)
_set_input_port_default_value(3, 1.0)
output_port_for_preview = 0
func _get_name() -> String:
@ -43,6 +39,15 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1, 2:
return 0.5
3:
return 1.0
_:
return null
func _get_output_port_count() -> int:
return 1
@ -53,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_%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"

View File

@ -0,0 +1,224 @@
@tool
class_name VisualShaderNodeRayMarch extends ShaderLib
func _get_name() -> String:
return "RayMarch"
func _get_category() -> String:
return "RayMarching"
func _get_description() -> String:
return "A simple ray marcher for primitive shapes."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_SCALAR
func _get_input_port_count() -> int:
var sdf_index: int = get_option_index(0)
match sdf_index:
2, 3, 4:
return 9
_:
return 8
func _get_input_port_name(port: int) -> String:
var sdf_index: int = get_option_index(0)
match sdf_index:
0, 1:
match port:
0:
return "ray origin"
1:
return "ray direction"
2:
return "max steps"
3:
return "max distance"
4:
return "distance threshold"
5:
return "cube pos" if sdf_index == 0 else "sphere pos"
6:
return "cube eulers" if sdf_index == 0 else "sphere eulers"
_:
return "cube scale" if sdf_index == 0 else "sphere scale"
2, 3:
match port:
0:
return "ray origin"
1:
return "ray direction"
2:
return "max steps"
3:
return "max distance"
4:
return "distance threshold"
5:
return "capsule pos" if sdf_index == 2 else "cylinder pos"
6:
return "capsule eulers" if sdf_index == 2 else "cylinder eulers"
7:
return "capsule height" if sdf_index == 2 else "cylinder height"
_:
return "capsule radius" if sdf_index == 2 else "cylinder radius"
_:
match port:
0:
return "ray origin"
1:
return "ray direction"
2:
return "max steps"
3:
return "max distance"
4:
return "distance threshold"
5:
return "torus pos"
6:
return "torus eulers"
7:
return "torus small radius"
_:
return "torus big radius"
func _get_input_port_type(port: int) -> PortType:
var sdf_index: int = get_option_index(0)
match sdf_index:
0, 1:
match port:
0, 1, 5, 6, 7:
return PORT_TYPE_VECTOR_3D
2:
return PORT_TYPE_SCALAR_INT
_:
return PORT_TYPE_SCALAR
2, 3:
match port:
0, 1, 5, 6:
return PORT_TYPE_VECTOR_3D
2:
return PORT_TYPE_SCALAR_INT
_:
return PORT_TYPE_SCALAR
_:
match port:
0, 1, 5, 6:
return PORT_TYPE_VECTOR_3D
2:
return PORT_TYPE_SCALAR_INT
_:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
var sdf_index: int = get_option_index(0)
match sdf_index:
0, 1:
match port:
0, 5, 6:
return Vector3(0, 0, 0)
1:
return Vector3(0 ,0 ,-1)
2:
return 15
3:
return 15.0
7:
return Vector3(0.3, 0.3, 0.3)
_:
return 1e-2
2, 3:
match port:
0, 5, 6:
return Vector3(0, 0, 0)
1:
return Vector3(0 ,0 ,-1)
2:
return 15
3:
return 15.0
4:
return 1e-2
7:
return .5 if sdf_index == 2 else 1.0
_:
return .3
_:
match port:
0, 5, 6:
return Vector3(0, 0, 0)
1:
return Vector3(0 ,0 ,-1)
2:
return 15
3:
return 15.0
4:
return 1e-2
7:
return 0.1
_:
return 0.4
func _get_property_count() -> int:
return 1
func _get_property_default_index(index: int) -> int:
return 0
func _get_property_name(index: int) -> String:
return "SDF"
func _get_property_options(index: int) -> PackedStringArray:
return ["SDBox", "SDSphere", "SDCapsule", "SDCylinder", "SDTorus"]
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "distance"
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/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)
var ray_origin: String = input_vars[0]
var ray_direction: String = input_vars[1]
var max_steps: String = input_vars[2]
var max_dist: String = input_vars[3]
var dist_threshold: String = input_vars[4]
match sdf_index:
0:
var cube_pos: String = input_vars[5]
var eulers: String = input_vars[6]
var size: String = input_vars[7]
return output_vars[0] + " = ray_march_sd_box(%s, %s, %s, %s, %s, %s, %s, %s);" % [ray_origin, ray_direction, max_steps, max_dist, dist_threshold, cube_pos, eulers, size]
1:
var sphere_pos: String = input_vars[5]
var eulers: String = input_vars[6]
var scale: String = input_vars[7]
return output_vars[0] + " = ray_march_sd_sphere(%s, %s, %s, %s, %s, %s, %s, %s);" % [ray_origin, ray_direction, max_steps, max_dist, dist_threshold, sphere_pos, eulers, scale]
2:
var capsule_pos: String = input_vars[5]
var capsule_eulers: String = input_vars[6]
var capsule_height: String = input_vars[7]
var capsule_radius: String = input_vars[8]
return output_vars[0] + " = ray_march_sd_capsule(%s, %s, %s, %s, %s, %s, %s, %s, %s);" % [ray_origin, ray_direction, max_steps, max_dist, dist_threshold, capsule_pos, capsule_height, capsule_radius, capsule_eulers]
3:
var cylinder_pos: String = input_vars[5]
var cylinder_eulers: String = input_vars[6]
var cylinder_height: String = input_vars[7]
var cylinder_radius: String = input_vars[8]
return output_vars[0] + " = ray_march_sd_cylinder(%s, %s, %s, %s, %s, %s, %s, %s, %s);" % [ray_origin, ray_direction, max_steps, max_dist, dist_threshold, cylinder_pos, cylinder_height, cylinder_radius, cylinder_eulers]
_:
var torus_pos: String = input_vars[5]
var eulers: String = input_vars[6]
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]

View File

@ -0,0 +1,24 @@
// 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
float radius = .3;
return length(p) - radius;
}
float ray_march_custom(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold) {
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 = sdf_custom(point);
dist_from_origin += dist_to_surface;
if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
break;
}
return dist_from_origin;
}

View File

@ -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;
}

View File

@ -0,0 +1,3 @@
class_name ShaderLib extends VisualShaderNodeCustom
var version: String = "v2_2_4"

View File

@ -1,14 +1,5 @@
@tool
class_name VisualShaderNodeUVFlipbook extends VisualShaderNodeCustom
func _init() -> void:
set_input_port_default_value(1, 1)
set_input_port_default_value(2, 1)
set_input_port_default_value(3, 0)
set_input_port_default_value(4, 0)
set_input_port_default_value(5, 0.1)
set_output_port_for_preview(0)
class_name VisualShaderNodeUVFlipbook extends ShaderLib
func _get_name() -> String:
return "Flipbook"
@ -23,7 +14,7 @@ func _get_return_icon_type() -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_2D
func _get_input_port_count() -> int:
return 6
return 4
func _get_input_port_name(port: int) -> String:
match port:
@ -34,10 +25,6 @@ func _get_input_port_name(port: int) -> String:
2:
return "columns"
3:
return "start frame"
4:
return "end frame"
5:
return "anim speed"
return ""
@ -45,12 +32,21 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
match port:
0:
return PORT_TYPE_VECTOR_2D
1, 2, 3, 4:
1, 2:
return PORT_TYPE_SCALAR_INT
5:
3:
return PORT_TYPE_SCALAR
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1, 2:
return 1
3:
return 0.1
_:
return null
func _get_output_port_count() -> int:
return 1
@ -61,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_%s/UV/UV.gdshaderinc\"" % [version]
func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool:
match mode:
@ -85,8 +80,6 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad
var rows: String = input_vars[1]
var columns: String = input_vars[2]
var start_frame: String = input_vars[3]
var end_frame: String = input_vars[4]
var anim_speed: String = input_vars[5]
var anim_speed: String = input_vars[3]
return output_vars[0] + " = flipbook_uv(%s, %s, %s, %s, %s, %s);" % [uv, rows, columns, start_frame, end_frame, anim_speed]
return output_vars[0] + " = flipbook_uv(%s, %s, %s, %s);" % [uv, rows, columns, anim_speed]

View File

@ -1,8 +1,5 @@
@tool
class_name VisualShaderNodeUVParallaxMapping extends VisualShaderNodeCustom
func _init() -> void:
_set_input_port_default_value(1, 1.0)
class_name VisualShaderNodeUVParallaxMapping extends ShaderLib
func _get_name() -> String:
return "ParallaxMapping"
@ -34,6 +31,13 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
_:
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return 1.0
_:
return null
func _get_output_port_count() -> int:
return 1
@ -51,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_%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]

View File

@ -1,12 +1,5 @@
@tool
class_name VisualShaderNodeUVRadialShear extends VisualShaderNodeCustom
func _init() -> void:
_set_input_port_default_value(1, Vector2(0.5, 0.5))
_set_input_port_default_value(2, 10.0)
_set_input_port_default_value(3, Vector2(0.0, 0.0))
set_output_port_for_preview(0)
class_name VisualShaderNodeUVRadialShear extends ShaderLib
func _get_name() -> String:
return "RadialShear"
@ -43,6 +36,17 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return Vector2(0.5, 0.5)
2:
return 10.0
3:
return Vector2(0.0, 0.0)
_:
return null
func _get_output_port_count() -> int:
return 1
@ -53,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_%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

View File

@ -1,12 +1,5 @@
@tool
class_name VisualShaderNodeUVRotate extends VisualShaderNodeCustom
func _init() -> void:
_set_input_port_default_value(1, Vector2(0.5, 0.5))
_set_input_port_default_value(2, 0.0)
_set_input_port_default_value(3, false)
set_output_port_for_preview(0)
class_name VisualShaderNodeUVRotate extends ShaderLib
func _get_name() -> String:
return "Rotate"
@ -21,7 +14,7 @@ func _get_return_icon_type() -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_2D
func _get_input_port_count() -> int:
return 4
return 3
func _get_input_port_name(port: int) -> String:
match port:
@ -31,8 +24,6 @@ func _get_input_port_name(port: int) -> String:
return "center"
2:
return "rotation"
3:
return "use degrees"
return ""
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
@ -41,10 +32,17 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_2D
2:
return PORT_TYPE_SCALAR
3:
return PORT_TYPE_BOOLEAN
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return Vector2(0.5, 0.5)
2:
return 0.0
_:
return null
func _get_output_port_count() -> int:
return 1
@ -54,9 +52,20 @@ func _get_output_port_name(port: int) -> String:
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_2D
func _get_property_count() -> int:
return 1
func _get_property_default_index(index: int) -> int:
return 0
func _get_property_name(index: int) -> String:
return "Units"
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_%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
@ -72,6 +81,6 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad
var center: String = input_vars[1]
var rotation: String = input_vars[2]
var use_degrees: String = input_vars[3]
var use_degrees: String = "true" if get_option_index(0) == 0 else "false"
return output_vars[0] + " = rotate_uv(%s, %s, %s, %s);" % [uv, center, rotation, use_degrees]

View File

@ -1,12 +1,5 @@
@tool
class_name VisualShaderNodeUVSpherize extends VisualShaderNodeCustom
func _init() -> void:
_set_input_port_default_value(1, Vector2(0.5, 0.5));
_set_input_port_default_value(2, 10.0);
_set_input_port_default_value(3, Vector2(0.0, 0.0));
set_output_port_for_preview(0)
class_name VisualShaderNodeUVSpherize extends ShaderLib
func _get_name() -> String:
return "Spherize"
@ -43,6 +36,17 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return Vector2(0.5, 0.5)
2:
return 10.0
3:
return Vector2(0.0, 0.0)
_:
return null
func _get_output_port_count() -> int:
return 1
@ -53,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_%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

View File

@ -1,12 +1,5 @@
@tool
class_name VisualShaderNodeUVSwirl extends VisualShaderNodeCustom
func _init() -> void:
_set_input_port_default_value(1, Vector2(0.5, 0.5))
_set_input_port_default_value(2, 10.0)
_set_input_port_default_value(3, Vector2(0.0, 0.0))
output_port_for_preview = 0
class_name VisualShaderNodeUVSwirl extends ShaderLib
func _get_name() -> String:
return "Swirl"
@ -43,6 +36,17 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return Vector2(0.5, 0.5)
2:
return 10.0
3:
return Vector2(0.0, 0.0)
_:
return null
func _get_output_port_count() -> int:
return 1
@ -53,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_%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

View File

@ -1,11 +1,5 @@
@tool
class_name VisualShaderNodeUVTilingAndOffset extends VisualShaderNodeCustom
func _init() -> void:
_set_input_port_default_value(1, Vector2(1.0, 1.0))
_set_input_port_default_value(2, Vector2(0.0, 0.0))
output_port_for_preview = 0
class_name VisualShaderNodeUVTilingAndOffset extends ShaderLib
func _get_name() -> String:
return "TilingAndOffset"
@ -38,6 +32,15 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_2D
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return Vector2(1.0, 1.0)
2:
return Vector2(0.0, 0.0)
_:
return null
func _get_output_port_count() -> int:
return 1

View File

@ -1,12 +1,5 @@
@tool
class_name VisualShaderNodeUVTwirl extends VisualShaderNodeCustom
func _init() -> void:
_set_input_port_default_value(1, Vector2(0.5, 0.5))
_set_input_port_default_value(2, 10.0)
_set_input_port_default_value(3, Vector2(0.0, 0.0))
output_port_for_preview = 0
class_name VisualShaderNodeUVTwirl extends ShaderLib
func _get_name() -> String:
return "Twirl"
@ -43,6 +36,17 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return Vector2(0.5, 0.5)
2:
return 10.0
3:
return Vector2(0.0, 0.0)
_:
return null
func _get_output_port_count() -> int:
return 1
@ -53,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_%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

View File

@ -0,0 +1,77 @@
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;
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;
}
mat2 rotation_mat2(float angle) {
return mat2(
vec2(cos(angle), -sin(angle)),
vec2(sin(angle), cos(angle))
);
}
vec2 rotate_uv(vec2 uv, vec2 center, float rotation, bool use_degrees) {
float angle = rotation;
if(use_degrees){
angle = rotation * (3.1415926/180.0);
}
vec2 delta = uv - center;
delta = rotation_mat2(angle) * 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);
delta = rotation_mat2(angle) * delta;
return delta + center + offset;
}
vec2 twirl_uv(vec2 uv, vec2 center, float strength, vec2 offset) {
vec2 delta = uv - center;
float angle = strength * length(delta);
delta = rotation_mat2(angle) * delta;
return delta + center + offset;
}

View File

@ -0,0 +1,94 @@
# Installation
Hit download as zip button in the git repo. Copy the contents of **_addons/ShaderLib_** into the same folder in your project. No activation needed. Custom visual shader nodes work the same way as standard visual shader nodes.
If you don't immediatly see new nodes under **_Addons_** category, simply reload your project.
# Uninstallation
Delete the contents of **_addons/ShaderLib_** folder from your project. Make sure to delete it using the Godot editor instead of your default file system program.
# Special Note
Even if you don't use visual shader, you can still use this addon for writing your custom shaders.
For example if you want to rotate UV in your **_.gdshader_** file, you can use `rotate_uv()` of this addon using `#include` keyword as following.
`#include "res://addons/ShaderLib/UV/RotateUV.gdshaderinc"`
# Available Nodes
<h2>Artistic nodes</h2>
<h3>&emsp;Adjustment</h3>
<h4><a href="/documentation/Nodes/Artistic/Adjustment/ContrastNode.md">&emsp;&emsp;Contrast node</a></h4>
<h4><a href="/documentation/Nodes/Artistic/Adjustment/HueNode.md">&emsp;&emsp;Hue node</a></h4>
<h4><a href="/documentation/Nodes/Artistic/Adjustment/ReplaceColorNode.md">&emsp;&emsp;Replace Color node</a></h4>
<h4><a href="/documentation/Nodes/Artistic/Adjustment/SaturationNode.md">&emsp;&emsp;Saturation node</a></h4>
<h4><a href="/documentation/Nodes/Artistic/Adjustment/WhiteBalanceNode.md">&emsp;&emsp;White Balance node</a></h4>
<h3>&emsp;Mask</h3>
<h4><a href="/documentation/Nodes/Artistic/Mask/ColorMaskNode.md">&emsp;&emsp;Color Mask node</a></h4>
<h2>Geometry nodes</h2>
<h4><a href="/documentation/Nodes/Geometry/Mesh.md">&emsp;Mesh node</a></h4>
<h2>Maths nodes</h2>
<h3>&emsp;Scalar</h3>
<h4><a href="/documentation/Nodes/Maths/Scalar/SmoothMax.md">&emsp;&emsp;SmoothMax node</a></h4>
<h4><a href="/documentation/Nodes/Maths/Scalar/SmoothMin.md">&emsp;&emsp;SmoothMin node</a></h4>
<h3>&emsp;Vector</h3>
<h3>&emsp;&emsp;Distance</h3>
<h4><a href="/documentation/Nodes/Maths/Vector/Distance/ChebyshevDistance.md">&emsp;&emsp;&emsp;Chebyshev Distance node</a></h4>
<h4><a href="/documentation/Nodes/Maths/Vector/Distance/ManhattanDistance.md">&emsp;&emsp;&emsp;Manhattan Distance node</a></h4>
<h4><a href="/documentation/Nodes/Maths/Vector/Project.md">&emsp;&emsp;Project node</a></h4>
<h4><a href="/documentation/Nodes/Maths/Vector/ProjectOnPlane.md">&emsp;&emsp;Project On Plane node</a></h4>
<h4><a href="/documentation/Nodes/Maths/Vector/VectorTransform.md">&emsp;&emsp;Vector Transform node</a></h4>
<h3>&emsp;Wave</h3>
<h4><a href="/documentation/Nodes/Maths/Wave/NoiseSineWave.md">&emsp;&emsp;Noise Sine Wave node</a></h4>
<h4><a href="/documentation/Nodes/Maths/Wave/SawtoothWave.md">&emsp;&emsp;Sawtooth Wave node</a></h4>
<h4><a href="/documentation/Nodes/Maths/Wave/SquareWave.md">&emsp;&emsp;Square Wave node</a></h4>
<h4><a href="/documentation/Nodes/Maths/Wave/TriangleWave.md">&emsp;&emsp;Triangle Wave node</a></h4>
<h2>Procedural nodes</h2>
<h4><a href="/documentation/Nodes/Procedural/CheckerBoard.md">&emsp;Checker Board node</a></h4>
<h4><a href="/documentation/Nodes/Procedural/HeightToNormal.md">&emsp;Height To Normal node</a></h4>
<h3>&emsp;Fractals</h3>
<h4><a href="/documentation/Nodes/Procedural/Fractals/KochFractal.md">&emsp;&emsp;Koch Fractal node</a></h4>
<h3>&emsp;Noise</h3>
<h4><a href="/documentation/Nodes/Procedural/Noise/GradientNoise.md">&emsp;&emsp;Gradient Noise node</a></h4>
<h4><a href="/documentation/Nodes/Procedural/Noise/GyroidNoise.md">&emsp;&emsp;Gyroid Noise node</a></h4>
<h4><a href="/documentation/Nodes/Procedural/Noise/PseudoRandomNoise.md">&emsp;&emsp;Pseudo Random Noise node</a></h4>
<h4><a href="/documentation/Nodes/Procedural/Noise/SimpleNoise.md">&emsp;&emsp;Simple Noise node</a></h4>
<h4><a href="/documentation/Nodes/Procedural/Noise/Voronoi.md">&emsp;&emsp;Voronoi node</a></h4>
<h3>&emsp;Shapes</h3>
<h4><a href="/documentation/Nodes/Procedural/Shapes/Ellipse.md">&emsp;&emsp;Ellipse node</a></h4>
<h4><a href="/documentation/Nodes/Procedural/Shapes/Polygon.md">&emsp;&emsp;Polygon node</a></h4>
<h4><a href="/documentation/Nodes/Procedural/Shapes/Rectangle.md">&emsp;&emsp;Rectangle node</a></h4>
<h4><a href="/documentation/Nodes/Procedural/Shapes/RoundedPolygon.md">&emsp;&emsp;Rounded Polygon node</a></h4>
<h4><a href="/documentation/Nodes/Procedural/Shapes/RoundedRectangle.md">&emsp;&emsp;Rounded Rectangle node</a></h4>
<h2>Ray marching nodes</h2>
<h4><a href="/documentation/Nodes/RayMarching/RayMarch.md">&emsp;Ray March node</a></h4>
<h2>UV nodes</h2>
<h4><a href="/documentation/Nodes/UV/Flipbook.md">&emsp;Flipbook node</a></h4>
<h4><a href="/documentation/Nodes/UV/ParallaxMapping.md">&emsp;Parallax Mapping node</a></h4>
<h4><a href="/documentation/Nodes/UV/RadialShear.md">&emsp;Radial Shear node</a></h4>
<h4><a href="/documentation/Nodes/UV/Rotate.md">&emsp;Rotate node</a></h4>
<h4><a href="/documentation/Nodes/UV/Spherize.md">&emsp;Spherize node</a></h4>
<h4><a href="/documentation/Nodes/UV/Swirl.md">&emsp;Swirl node</a></h4>
<h4><a href="/documentation/Nodes/UV/TilingAndOffset.md">&emsp;Tiling and Offset node</a></h4>
<h4><a href="/documentation/Nodes/UV/Twirl.md">&emsp;Twirl node</a></h4>

View File

@ -0,0 +1,27 @@
# Contrast node
Adjusts the contrast of input <b><i>in</i></b> by the amount of input <b><i>contrast</i></b>. A contrast value of 1 will return the input unaltered. A contrast value of 0 will return the midpoint of the input.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|vec3|none|Input value|
|contrast|float|none|Contrast value|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|vec3|None|Output value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
**Method signature**
<br>`vec3 contrast(input, contrast)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|input|vec3|Input color|
|contrast|float|contrast value|
___

View File

@ -0,0 +1,33 @@
# Hue node
Offsets the hue of input <b><i>in</i></b> by the amount of input <b><i>offset</i></b>. The unit of the offset can be set with the parameter <b><i>Range</i></b>. Offset in <b><i>Degrees</i></b> is in the range -180 to 180. In <b><i>Normalize</b></i> it is -1 to 1.
<hr>
**Controls**
|Name|Options|Description|
|---|---|---|
|Range|Degrees, Normalize|The unit used for the input offset|
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|vec3|none|Input value|
|offset|float|none|Amount to offset hue|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|vec3|None|Output value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
**Method signature**
<br>`vec3 hue(input, offset, range_index)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|input|vec3|Input color|
|offset|vec3|Amount of offset hue|
|range_index|int|range index, 0 = use degrees as units, 1 = use radians as units|
___

View File

@ -0,0 +1,33 @@
# Replace Color node
Replaces values in input <b><i>in</i></b> equal to input <b><i>from</i></b> to the value of input <b><i>to</i></b>. Input <b><i>range</i></b> can be used to define a wider range of values around input <b><i>from</i></b> to replace. Input <b><i>fuzziness</i></b> can be used to soften the edges around the selection similar to anti-aliasing.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|vec3|none|Input value|
|from|vec3|none|Color to replace|
|to|vec3|none|Color to replace with|
|range|float|none|Replace colors within this range from input <b><i>from</i></b>|
|fuzziness|float|none|Soften edges around selection|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|vec3|None|Output value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
**Method signature**
<br>`vec3 replace_color(input, from, to, range, fuzziness)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|input|vec3|Input color|
|from|vec3|Color to replace|
|to|vec3|Color to replace with|
|range|float|Replace colors within this range from input <b><i>from</i></b>|
|fuzziness|float|Soften edges around selection|
___

View File

@ -0,0 +1,27 @@
# Saturation node
Adjusts the saturation of input <b><i>in</i></b> by the amount of input <b><i>saturation</i></b>. A Saturation value of 1 will return the input unaltered. A Saturation value of 0 will return the input completely desaturated.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|vec3|none|Input value|
|saturation|float|none|Saturation value|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|vec3|None|Output value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
**Method signature**
<br>`vec3 saturation(input, saturation)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|input|vec3|Input color|
|saturation|float|Saturation value|
___

View File

@ -0,0 +1,29 @@
# White Balance node
Adjusts the temperature and tint of input <b><i>in</i></b> by the amount of inputs <b><i>temperature</i></b> and <b><i>tint</i></b> respectively. Temperature has the effect of shifting the values towards yellow or blue. Tint has the effect of shifting towards pink or green.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|vec3|none|Input value|
|temperature|float|none|Temperature offset value|
|tint|float|none|Tint offset value|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|vec3|None|Output value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
**Method signature**
<br>`vec3 white_balance(input, temperature, tint)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|input|vec3|Input color|
|temperature|float|Temperature offset value|
|tint|float|Tint offset value|
___

View File

@ -0,0 +1,31 @@
# Color Mask node
Creates a mask from values in input <b><i>in</i></b> equal to input <b><i>mask color</i></b>. Input <b><i>range</i></b> can be used to define a wider range of values around input <b><i>mask color</i></b> to create the mask. Colors within this range will return 1, otherwise the node will return 0. Input <b><i>fuzziness</i></b> can be used to soften the edges around the selection similar to anti-aliasing.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|vec3|none|Input value|
|color mask|vec3|none|Color to use for mask|
|range|float|none|Select colors within this range from input <b><i>mask color</i></b>|
|fuzziness|float|none|Feather edges around selection. Higher values result in a softer selection mask.|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|vec3|None|Output mask value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
**Method signature**
<br>`vec4 color_mask(input, mask_color, range, fuzziness)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|input|vec3|Input color|
|mask_color|vec3|Color to use for mask|
|range|float|Select colors within this range from input <b><i>mask color</i></b>|
|fuzziness|float|Feather edges around selection. Higher values result in a softer selection mask.|
___

View File

@ -0,0 +1,21 @@
# Mesh node
Provides accees to node's position and scale in world space.
<hr>
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|position|vec3|None|Node/object position in world space|
|scale|vec3|None|Node/object scale in world space|
**ShaderInc location**
<br>`res://addons/ShaderLib/Geometry/Geometry.gdshaderinc`
**Method signature**
<br>`vec3 geometry_node_scale_world(mat4 model_matrix)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|model_matrix|mat4|Model matrix of the mesh|
___

View File

@ -0,0 +1,29 @@
# SmoothMax node
Returns the maximum value between A and B, but smooths out the intersections of A and B based on T. T is the smoothing value. If 0 is passed at T, function will act as a standard max(), if negative value is passed it will act as <b><i>[SmoothMin node](/documentation/Nodes/Maths/Scalar/SmoothMin.md)</b></i>.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|a|float|none|Input A|
|b|float|none|Input B|
|t|float|none|Smoothing input|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|op|float|None|Smooth maximum between A and B|
**ShaderInc location**
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
<br>`float smoothmax(float a, float b, float t)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|a|float|Input A|
|b|float|Input B|
|t|float|Smoothing input|
___

View File

@ -0,0 +1,29 @@
# SmoothMin node
Returns the minimum value between A and B, but smooths out the intersections of A and B based on T. T is the smoothing value. If 0 is passed at T, function will act as a standard min(), if negative value is passed it will act as <b><i>[SmoothMax node](/documentation/Nodes/Maths/Scalar/SmoothMax.md)</b></i>.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|a|float|none|Input A|
|b|float|none|Input B|
|t|float|none|Smoothing input|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|op|float|None|Smooth minimum between A and B|
**ShaderInc location**
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
<br>`float smoothmin(float a, float b, float t)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|a|float|Input A|
|b|float|Input B|
|t|float|Smoothing input|
___

View File

@ -0,0 +1,42 @@
# Chebyshev Distance node
Returns the distance between two points using Chebyshev distance matrix.
<hr>
**Controls**
|Options|Description|
|---|---|
|Vector2, Vector3|Vector type to use for calculation|
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|a|Dynamic vector|none|Point a|
|b|Dynamic vector|none|Point b|
|power|float|none|Power to use for Chebyshev distance|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|distance|float|None|Distance between 2 points|
**ShaderInc location**
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
<br>For 2D - `float chebyshev_distance_2d(vec2 point1, vec2 point2, float power)`
<br>For 3D - `float chebyshev_distance_3d(vec3 point1, vec3 point2, float power)`
**Parameters for 2D**
|Name|Type|Description|
|---|---|---|
|point1|vec2|Point a|
|point2|vec2|Point b|
|power|float|Power for Chebyshev distance|
**Parameters for 3D**
|Name|Type|Description|
|---|---|---|
|point1|vec3|Point a|
|point2|vec3|Point b|
|power|float|Power for Chebyshev distance|
___

View File

@ -0,0 +1,39 @@
# Manhattan Distance node
Returns the distance between two points using Manhattan distance matrix.
<hr>
**Controls**
|Options|Description|
|---|---|
|Vector2, Vector3|Vector type to use for calculation|
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|a|Dynamic vector|none|Point a|
|b|Dynamic vector|none|Point b|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|distance|float|None|Distance between 2 points|
**ShaderInc location**
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
<br>For 2D - `float manhattan_distance_2d(vec2 point1, vec2 point2)`
<br>For 3D - `float manhattan_distance_3d(vec3 point1, vec3 point2)`
**Parameters for 2D**
|Name|Type|Description|
|---|---|---|
|point1|vec2|Point a|
|point2|vec2|Point b|
**Parameters for 3D**
|Name|Type|Description|
|---|---|---|
|point1|vec3|Point a|
|point2|vec3|Point b|
___

View File

@ -0,0 +1,39 @@
# Project node
Projects <i><b>vector A</b></i> onto <i><b>vector B</b></i>.
<hr>
**Controls**
|Options|Description|
|---|---|
|Vector2, Vector3|Vector type to use for calculation|
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|vector A|Dynamic vector|none|Vector to project|
|vector B|Dynamic vector|none|Vector on which vector A will be projected|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|vector|vector3|None|Output vector|
**ShaderInc location**
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
<br>`vec2 project_2d(vec2 a, vec2 b)`
<br>`vec3 project_3d(vec3 a, vec3 b)`
**Parameters for 2D**
|Name|Type|Description|
|---|---|---|
|a|vec2|Vector A|
|b|vec2|Vector B|
**Parameters for 3D**
|Name|Type|Description|
|---|---|---|
|a|vec3|Vector A|
|b|vec3|Vector B|
___

View File

@ -0,0 +1,27 @@
# Project On Plane node
Projects a vector onto a plane defined by a normal orthogonal to the plane.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|vector|vector3|none|Vector to project|
|plane normal|vector3|none|Normal orthogonal of the plane|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|vector|vector3|None|Output vector|
**ShaderInc location**
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
<br>`vec3 project_on_plane(vec3 vector, vec3 plane_normal)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|vector|vec3|Input vector|
|plane_normal|vec3|Normal vector to the plane|
___

View File

@ -0,0 +1,21 @@
# Vector Transform node
Returns the transformed vector of the input value <i><b>in</b></i> from one coordinate space to another.<br><br><i>This node is only available in shader mode SPATIAL.</i>
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|vector3|none|Input vector|
**Controls**
|Name|Options|Description|
|---|---|---|
|Vector type|Positional, Directional|Positional will take into account translation data, Directional won't|
|From|Local, World, View, Screen, Tangent|Coordinate space from which you want to transform the input vector|
|To|Local, World, View, Screen, Tangent|Coordinate space to which you want to transform the input vector|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|vector3|None|Output vector|
___

View File

@ -0,0 +1,32 @@
# Noise Sine Wave node
Returns the sine of the value of input <b><i>in</i></b>. For variance, psuedo-random noise is added to the amplitude of the sine wave, within a range determined by input <b><i>min max</i></b>.
<hr>
**Controls**
|Options|Description|
|---|---|
|Vector1, Vector2, Vector3, Vector4|Vector type to use for calculation|
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|Dynamic vector|none|Input value|
|min max|vec2|none|Minimum and Maximum values for noise intensity|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|Dynamic vector|None|Output value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
<br>`vec4 noise_sine_wave(vec4 input, vec2 min_max)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|input|vec4|Input vector|
|min_max|vec2|Minimum and Maximum values for noise intensity|
___

View File

@ -0,0 +1,30 @@
# Sawtooth Wave node
Returns a sawtooth wave from the value of input <b><i>in</i></b>. Resulting output values will be between -1 and 1.
<hr>
**Controls**
|Options|Description|
|---|---|
|Vector1, Vector2, Vector3, Vector4|Vector type to use for calculation|
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|Dynamic vector|none|Input value|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|Dynamic vector|None|Output value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
<br>`vec4 sawtooth_wave(vec4 input)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|input|vec4|Input vector|
___

View File

@ -0,0 +1,30 @@
# Square Wave node
Returns a square wave from the value of input <b><i>in</i></b>. Resulting output values will be between -1 and 1.
<hr>
**Controls**
|Options|Description|
|---|---|
|Vector1, Vector2, Vector3, Vector4|Vector type to use for calculation|
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|Dynamic vector|none|Input value|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|Dynamic vector|None|Output value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
<br>`vec4 square _wave(vec4 input)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|input|vec4|Input vector|
___

View File

@ -0,0 +1,30 @@
# Triangle Wave node
Returns a triangle wave from the value of input <b><i>in</i></b>. Resulting output values will be between -1 and 1.
<hr>
**Controls**
|Options|Description|
|---|---|
|Vector1, Vector2, Vector3, Vector4|Vector type to use for calculation|
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|in|Dynamic vector|none|Input value|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|Dynamic vector|None|Output value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
**Method signature**
<br>`vec4 triangle_wave(vec4 input)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|input|vec4|Input vector|
___

View File

@ -0,0 +1,31 @@
# Checker Board node
Generates a checkerboard of alternating colors between inputs <b><i>color A</i></b> and <b><i>color B</i></b> based on input UV.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|color a|vec3|none|First checker color|
|color b|vec3|none|Second checker color|
|frequency|vec2|none|Scale of checkerboard per axis|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|vec3|None|Output checkerboard value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
<br>`vec3 checker_board(vec2 uv, vec3 color_a, vec3 color_b, vec2 frequency)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|uv|vec2|Input UV value|
|color a|vec3|First checker color|
|color b|vec3|Second checker color|
|frequency|vec2|Scale of checkerboard per axis|
___

View File

@ -0,0 +1,35 @@
# Koch Fractal node
Generates an koch curve similar to ice fractal shape based on input UV at the size specified by inputs <b><i>width</i></b> and <b><i>height</i></b>. The generated shape can be offset or tiled by connecting a <b><i>[TilingAndOffset](/documentation/Nodes/UV/TilingAndOffset.md)</i></b> node. Note that in order to preserve the ability to offset the shape within the UV space the shape will not automatically repeat if tiled. To achieve a repeating effect first connect your <b><i>TilingAndOffset</i></b> output through a <b><i>Fract</i></b> node.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|thickness|float|none|Shape outline thickness|
|iterations|int|none|Number of steps to repeat the fractal shape|
|width|float|none|Fractal width|
|height|float|none|Fractal height|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|out|float|None|Output fractal value|
|uv|vec2|None|Output UV value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
<br>`float koch_fractal(vec2 uv, float outline, int iteration, float shape_width, float shape_height, out vec2 koch_uv)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|uv|vec2|Input UV value|
|outline|float|Shape outline thickness|
|iterations|int|Number of steps to repeat the fractal shape|
|shape_width|float|Fractal width|
|shape_height|float|Fractal height|
|koch_uv|out vec2|Returns Koch fractal UV|
___

View File

@ -0,0 +1,29 @@
# Height To Normal node
Generates a normal map from a height map.
<hr>
**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**
<br>`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
<br>`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|
___

View File

@ -0,0 +1,27 @@
# Gradient Noise node
Generates a gradient, or Perlin noise based on input UV. The resulting <b><i>output</i></b> values will be between -1 and 1.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|scale|float|none|Noise scale|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|float|None|Output noise value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
<br>`float gradient_noise(vec2 uv, float scale)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|uv|vec2|Input UV value|
|scale|float|Noise scale|
___

View File

@ -0,0 +1,33 @@
# Gyroid Noise node
Generates a gyroid noise based on input UV. The resulting <b><i>output</i></b> values will be between 0 and 1.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|uv|vec2|UV|Input UV value|
|scale|float|none|Noise scale|
|ratio|vec2|none|Noise ratio for X and Y Axes|
|height|float|none|Noise height|
|thickness|float|none|Noise thickness, clamped between 0 and 1|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|float|None|Output noise value|
**ShaderInc location**
<br>`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
**Method signature**
<br>`float gyroid_noise(vec2 uv, float scale, vec2 ratio, float height, float thickness)`
**Parameters**
|Name|Type|Description|
|---|---|---|
|uv|vec2|Input UV value|
|scale|float|Noise scale|
|ratio|vec2|Noise ratio for X and Y axes|
|height|float|Noise height|
|thickness|float|Noise thickness, clamped between 0 and 1|
___

Some files were not shown because too many files have changed in this diff Show More