mirror of
https://github.com/DigvijaysinhGohil/Godot-Shader-Lib.git
synced 2025-09-19 11:56:01 +08:00
Compare commits
79 Commits
v1.2.0
...
d72153b7c4
Author | SHA1 | Date | |
---|---|---|---|
d72153b7c4 | |||
21213d657e | |||
56eaa9e7b1 | |||
e33f70baa9 | |||
0a8948118f | |||
6c7221cbb7 | |||
dc049b857b | |||
3cf0e2d38a | |||
45ddc1f6a2 | |||
ce44d78559 | |||
9f8087e91d | |||
0b22ea2ce1 | |||
6bd06becac | |||
2dadda73fc | |||
8a036a2abf | |||
b7c13a973a | |||
b1411a809c | |||
7b3fe34b9b | |||
f7e9fddd00 | |||
9c9907580c | |||
57d3027b6c | |||
6f447b39af | |||
b9bd4c3a3d | |||
033b54ea93 | |||
6b57a43325 | |||
f8c0bc1e4e | |||
e921ecebad | |||
0b9c1235fa | |||
c4e47d37eb | |||
1d15214565 | |||
6cfeaaec5e | |||
beeee0e556 | |||
a7467b8bfd | |||
4686b20c51 | |||
0d5c68fb1f | |||
41f016feca | |||
55039f4c6b | |||
de8d5e472e | |||
600079e3e5 | |||
f06a680212 | |||
ae40a2f349 | |||
c51785f3b5 | |||
9d7cf5e9e9 | |||
8b3f23fbea | |||
506b4c9563 | |||
f0dad0ce8e | |||
088c80aa2b | |||
578a78df0b | |||
6b62f15a7d | |||
151e40d0fb | |||
eaa074f68f | |||
64df7fb100 | |||
9ebc2ddf76 | |||
ba9ee716b4 | |||
b2ba78fa43 | |||
b41d1dff80 | |||
7adea627e0 | |||
bd86743d0f | |||
4cc91847ed | |||
23b35b99da | |||
f83b238e5a | |||
0037db566e | |||
154214e248 | |||
2d187facab | |||
4c6b6910fb | |||
47c437f10c | |||
e73385e903 | |||
931fc113db | |||
93f6927a1f | |||
f8ea3cd71e | |||
3a05a667c9 | |||
d19bca6369 | |||
4125d1d412 | |||
2828af7503 | |||
13971eeab6 | |||
d3397cf87c | |||
4205904cb5 | |||
a0aaf91ef3 | |||
64dead8a82 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
tests/
|
||||
*.import
|
||||
|
21
LICENSE
Normal file
21
LICENSE
Normal 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.
|
444
README.md
444
README.md
@ -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)
|
59
addons/ShaderLib/Artistic/Adjustment/Contrast.gd
Normal file
59
addons/ShaderLib/Artistic/Adjustment/Contrast.gd
Normal file
@ -0,0 +1,59 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeAdjustmentContrast extends VisualShaderNodeCustom
|
||||
|
||||
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/Artistic/Artistic.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec3(1.0)"
|
||||
|
||||
if input_vars[0]:
|
||||
input = input_vars[0]
|
||||
|
||||
var contrast: String = input_vars[1]
|
||||
return output_vars[0] + " = contrast(%s, %s);" % [input, contrast]
|
72
addons/ShaderLib/Artistic/Adjustment/Hue.gd
Normal file
72
addons/ShaderLib/Artistic/Adjustment/Hue.gd
Normal file
@ -0,0 +1,72 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeAdjustmentHue extends VisualShaderNodeCustom
|
||||
|
||||
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/Artistic/Artistic.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var range_index: int = get_option_index(0)
|
||||
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]
|
77
addons/ShaderLib/Artistic/Adjustment/ReplaceColor.gd
Normal file
77
addons/ShaderLib/Artistic/Adjustment/ReplaceColor.gd
Normal file
@ -0,0 +1,77 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeAdjustmentReplaceColor extends VisualShaderNodeCustom
|
||||
|
||||
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/Artistic/Artistic.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec3(1.0)"
|
||||
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]
|
60
addons/ShaderLib/Artistic/Adjustment/Saturation.gd
Normal file
60
addons/ShaderLib/Artistic/Adjustment/Saturation.gd
Normal file
@ -0,0 +1,60 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeAdjustmentSaturation extends VisualShaderNodeCustom
|
||||
|
||||
|
||||
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/Artistic/Artistic.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec3(1.0)"
|
||||
|
||||
if input_vars[0]:
|
||||
input = input_vars[0]
|
||||
|
||||
var saturation = input_vars[1]
|
||||
return output_vars[0] + " = saturation(%s, %s);" % [input, saturation]
|
63
addons/ShaderLib/Artistic/Adjustment/WhiteBalance.gd
Normal file
63
addons/ShaderLib/Artistic/Adjustment/WhiteBalance.gd
Normal file
@ -0,0 +1,63 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeWhiteBalance extends VisualShaderNodeCustom
|
||||
|
||||
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/Artistic/Artistic.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec3(1.0)"
|
||||
|
||||
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]
|
84
addons/ShaderLib/Artistic/Artistic.gdshaderinc
Normal file
84
addons/ShaderLib/Artistic/Artistic.gdshaderinc
Normal 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.));
|
||||
}
|
68
addons/ShaderLib/Artistic/Mask/ColorMask.gd
Normal file
68
addons/ShaderLib/Artistic/Mask/ColorMask.gd
Normal file
@ -0,0 +1,68 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeMaskColorMask extends VisualShaderNodeCustom
|
||||
|
||||
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/Artistic/Artistic.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec3(0.0)"
|
||||
|
||||
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]
|
11
addons/ShaderLib/Geometry/Geometry.gdshaderinc
Normal file
11
addons/ShaderLib/Geometry/Geometry.gdshaderinc
Normal 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);
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeGeometryNodeScaleWorld extends VisualShaderNodeCustom
|
||||
class_name VisualShaderNodeGeometryMeshNode extends VisualShaderNodeCustom
|
||||
|
||||
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/Geometry/Geometry.gdshaderinc\""
|
||||
|
||||
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
|
@ -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);
|
||||
}
|
161
addons/ShaderLib/Maths/Maths.gdshaderinc
Normal file
161
addons/ShaderLib/Maths/Maths.gdshaderinc
Normal file
@ -0,0 +1,161 @@
|
||||
float chebyshev_distance_2d(vec2 point1, vec2 point2, float power) {
|
||||
vec2 p = abs(point1 - point2);
|
||||
return pow(pow(p.x, power) + pow(p.y, power), 1. / power);
|
||||
}
|
||||
|
||||
float chebyshev_distance_3d(vec3 point1, vec3 point2, float power) {
|
||||
vec3 p = abs(point1 - point2);
|
||||
return pow(pow(p.x, power) + pow(p.y, power) + pow(p.z, power), 1. / power);
|
||||
}
|
||||
|
||||
float manhattan_distance_2d(vec2 point1, vec2 point2) {
|
||||
vec2 d = point1 - point2;
|
||||
return abs(d.x) + abs(d.y);
|
||||
}
|
||||
|
||||
float manhattan_distance_3d(vec3 point1, vec3 point2) {
|
||||
vec3 d = point1 - point2;
|
||||
return abs(d.x) + abs(d.y) + abs(d.z);
|
||||
}
|
||||
|
||||
vec2 project_2d(vec2 a, vec2 b) {
|
||||
return b * (dot(a, b) / dot(b, b));
|
||||
}
|
||||
|
||||
vec3 project_3d(vec3 a, vec3 b) {
|
||||
return b * (dot(a, b) / dot(b, b));
|
||||
}
|
||||
|
||||
vec3 project_on_plane(vec3 vector, vec3 plane_normal) {
|
||||
return vector - (plane_normal * (dot(vector, plane_normal) / dot(plane_normal, plane_normal)));
|
||||
}
|
||||
|
||||
float smoothmin(float a, float b, float t) {
|
||||
float h = clamp(.5 + .5 * (b - a) / t, 0, 1);
|
||||
return mix(b, a, h) - t * h * (1. - h);
|
||||
}
|
||||
|
||||
float smoothmax(float a, float b, float t) {
|
||||
float h = clamp(.5 + .5 * (b - a) / -t, 0, 1);
|
||||
return mix(b, a, h) + t * h * (1. - h);
|
||||
}
|
||||
|
||||
vec3 vector_transform_world_to_local(mat4 model_matrix, vec3 vector) {
|
||||
return (inverse(model_matrix) * vec4(vector, 1.0)).xyz;
|
||||
}
|
||||
|
||||
vec3 vector_transform_world_to_view(mat4 view_matrix, vec3 vector) {
|
||||
return (view_matrix * vec4(vector, 1.0)).xyz;
|
||||
}
|
||||
|
||||
vec3 vector_transform_world_to_screen(mat4 view_matrix, mat4 projection_matrix, vec3 vector) {
|
||||
vec3 vector_view = vector_transform_world_to_view(view_matrix, vector);
|
||||
return (projection_matrix * vec4(vector_view, 1.0)).xyz;
|
||||
}
|
||||
|
||||
vec3 vector_transform_world_to_tangent(mat4 model_matrix, vec3 normal, vec3 binormal, vec3 tangent, vec3 vector) {
|
||||
mat3 local_to_tangent_matrix = mat3(tangent, binormal, normal);
|
||||
vec3 vector_local = vector_transform_world_to_local(model_matrix, vector);
|
||||
return local_to_tangent_matrix * vector_local;
|
||||
}
|
||||
|
||||
vec3 vector_transform_local_to_world(mat4 model_matrix, vec3 vector) {
|
||||
return (model_matrix * vec4(vector, 1.0)).xyz;
|
||||
}
|
||||
|
||||
vec3 vector_transform_local_to_view(mat4 model_matrix, mat4 view_matrix, vec3 vector) {
|
||||
vec3 vector_world = vector_transform_local_to_world(model_matrix, vector);
|
||||
return (view_matrix * vec4(vector_world, 1.0)).xyz;
|
||||
}
|
||||
|
||||
vec3 vector_transform_local_to_screen(mat4 model_matrix, mat4 view_matrix, mat4 projection_matrix, vec3 vector) {
|
||||
vec3 vector_view = vector_transform_local_to_view(model_matrix, view_matrix, vector);
|
||||
return (projection_matrix * vec4(vector_view, 1.0)).xyz;
|
||||
}
|
||||
|
||||
vec3 vector_transform_local_to_tangent(vec3 normal, vec3 binormal, vec3 tangent, vec3 vector) {
|
||||
mat3 local_to_tangent_matrix = mat3(tangent, binormal, normal);
|
||||
return local_to_tangent_matrix * vector;
|
||||
}
|
||||
|
||||
vec3 vector_transform_view_to_world(mat4 inv_view_matrix, vec3 vector) {
|
||||
return (inv_view_matrix * vec4(vector, 1.0)).xyz;;
|
||||
}
|
||||
|
||||
vec3 vector_transform_view_to_local(mat4 inv_view_matrix, mat4 model_matrix, vec3 vector) {
|
||||
vec3 vector_world = vector_transform_view_to_world(inv_view_matrix, vector);
|
||||
return vector_transform_world_to_local(model_matrix, vector_world);
|
||||
}
|
||||
|
||||
vec3 vector_transform_view_to_screen(mat4 projection_matrix, vec3 vector) {
|
||||
return (projection_matrix * vec4(vector, 1.0)).xyz;
|
||||
}
|
||||
|
||||
vec3 vector_transform_view_to_tangent(mat4 inv_view_matrix, mat4 model_matrix, vec3 normal, vec3 binormal, vec3 tangent, vec3 vector) {
|
||||
mat3 local_to_tangent_matrix = mat3(tangent, binormal, normal);
|
||||
vec3 vector_local = vector_transform_view_to_local(inv_view_matrix, model_matrix, vector);
|
||||
return vector_transform_local_to_tangent(normal, binormal, tangent, vector_local);
|
||||
}
|
||||
|
||||
vec3 vector_transform_screen_to_view(mat4 inv_projection_matrix, vec3 vector) {
|
||||
return (inv_projection_matrix * vec4(vector, 1.0)).xyz;;
|
||||
}
|
||||
|
||||
vec3 vector_transform_screen_to_local(mat4 inv_projection_matrix, mat4 inv_view_matrix, mat4 model_matrix, vec3 vector) {
|
||||
vec3 vector_view = vector_transform_screen_to_view(inv_projection_matrix, vector);
|
||||
return vector_transform_view_to_local(inv_view_matrix, model_matrix, vector_view);
|
||||
}
|
||||
|
||||
vec3 vector_transform_screen_to_world(mat4 inv_projection_matrix, mat4 inv_view_matrix, vec3 vector) {
|
||||
vec3 vector_view = vector_transform_screen_to_view(inv_projection_matrix, vector);
|
||||
return vector_transform_view_to_world(inv_view_matrix, vector_view);
|
||||
}
|
||||
|
||||
vec3 vector_transform_screen_to_tangent(mat4 inv_projection_matrix, mat4 inv_view_matrix, mat4 model_matrix, vec3 normal, vec3 binormal, vec3 tangent, vec3 vector) {
|
||||
mat3 local_to_tangent_matrix = mat3(tangent, binormal, normal);
|
||||
vec3 vector_local = vector_transform_screen_to_local(inv_projection_matrix, inv_view_matrix, model_matrix, vector);
|
||||
return local_to_tangent_matrix * vector_local;
|
||||
}
|
||||
|
||||
vec3 vector_transform_tangent_to_local(vec3 normal, vec3 binormal, vec3 tangent, vec3 vector) {
|
||||
mat3 tangent_to_local_matrix = inverse(mat3(tangent, binormal, normal));
|
||||
return tangent_to_local_matrix * vector;
|
||||
}
|
||||
|
||||
vec3 vector_transform_tangent_to_world(mat4 model_matrix, vec3 normal, vec3 binormal, vec3 tangent, vec3 vector) {
|
||||
mat3 tangent_to_local_matrix = inverse(mat3(tangent, binormal, normal));
|
||||
vec3 vector_local = tangent_to_local_matrix * vector;
|
||||
return vector_transform_local_to_world(model_matrix, vector_local);
|
||||
}
|
||||
|
||||
vec3 vector_transform_tangent_to_view(mat4 model_matrix, mat4 view_matrix, vec3 normal, vec3 binormal, vec3 tangent, vec3 vector) {
|
||||
mat3 tangent_to_local_matrix = inverse(mat3(tangent, binormal, normal));
|
||||
vec3 vector_local = tangent_to_local_matrix * vector;
|
||||
return vector_transform_local_to_view(model_matrix, view_matrix, vector_local);
|
||||
}
|
||||
|
||||
vec3 vector_transform_tangent_to_screen(mat4 model_matrix, mat4 view_matrix, mat4 projection_matrix, vec3 normal, vec3 binormal, vec3 tangent, vec3 vector) {
|
||||
mat3 tangent_to_local_matrix = inverse(mat3(tangent, binormal, normal));
|
||||
vec3 vector_local = tangent_to_local_matrix * vector;
|
||||
return vector_transform_local_to_screen(model_matrix, view_matrix, projection_matrix, vector_local);
|
||||
}
|
||||
|
||||
vec4 noise_sine_wave(vec4 input, vec2 min_max) {
|
||||
vec4 sin_in = sin(input);
|
||||
vec4 sin_in_offset = sin(input + 1.0);
|
||||
vec4 random_number = fract(sin((sin_in - sin_in_offset) * (12.9898 + 78.233)) * 43758.5453);
|
||||
float noise = mix(min_max.x, min_max.y, random_number.x);
|
||||
return sin_in + vec4(noise);
|
||||
}
|
||||
|
||||
vec4 sawtooth_wave(vec4 input) {
|
||||
return 2. * (input - floor(.5 + input));
|
||||
}
|
||||
|
||||
vec4 square_wave(vec4 input) {
|
||||
return 1. - 2. * round(fract(input));
|
||||
}
|
||||
|
||||
vec4 triangle_wave(vec4 input) {
|
||||
return 2. * abs(2. * (input - floor(.5 + input))) - 1.;
|
||||
}
|
55
addons/ShaderLib/Maths/Scalar/SmoothMax.gd
Normal file
55
addons/ShaderLib/Maths/Scalar/SmoothMax.gd
Normal file
@ -0,0 +1,55 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeScalarSmoothMax extends VisualShaderNodeCustom
|
||||
|
||||
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/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var a: String = input_vars[0]
|
||||
var b: String = input_vars[1]
|
||||
var t: String = input_vars[2]
|
||||
|
||||
return output_vars[0] + " = smoothmax(%s, %s, %s);" % [a, b, t]
|
55
addons/ShaderLib/Maths/Scalar/SmoothMin.gd
Normal file
55
addons/ShaderLib/Maths/Scalar/SmoothMin.gd
Normal file
@ -0,0 +1,55 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeScalarSmoothMin extends VisualShaderNodeCustom
|
||||
|
||||
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/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var a: String = input_vars[0]
|
||||
var b: String = input_vars[1]
|
||||
var t: String = input_vars[2]
|
||||
|
||||
return output_vars[0] + " = smoothmin(%s, %s, %s);" % [a, b, t]
|
95
addons/ShaderLib/Maths/Vector/Distance/ChebyshevDistance.gd
Normal file
95
addons/ShaderLib/Maths/Vector/Distance/ChebyshevDistance.gd
Normal file
@ -0,0 +1,95 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeMathsChebyshevDistance extends VisualShaderNodeCustom
|
||||
|
||||
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/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var point_a: String
|
||||
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]
|
||||
|
81
addons/ShaderLib/Maths/Vector/Distance/ManhattanDistance.gd
Normal file
81
addons/ShaderLib/Maths/Vector/Distance/ManhattanDistance.gd
Normal file
@ -0,0 +1,81 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeMathsManhattanDistance extends VisualShaderNodeCustom
|
||||
|
||||
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/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var point_a: String
|
||||
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]
|
||||
|
77
addons/ShaderLib/Maths/Vector/Project.gd
Normal file
77
addons/ShaderLib/Maths/Vector/Project.gd
Normal file
@ -0,0 +1,77 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeVectorProject extends VisualShaderNodeCustom
|
||||
|
||||
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/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var vector_a: String = input_vars[0]
|
||||
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]
|
44
addons/ShaderLib/Maths/Vector/ProjectOnPlane.gd
Normal file
44
addons/ShaderLib/Maths/Vector/ProjectOnPlane.gd
Normal file
@ -0,0 +1,44 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeVectorProjectOnPlane extends VisualShaderNodeCustom
|
||||
|
||||
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/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var vector_a: String = input_vars[0]
|
||||
var plane_normal: String = input_vars[1]
|
||||
return output_vars[0] + " = project_on_plane(%s, %s);" % [vector_a, plane_normal]
|
128
addons/ShaderLib/Maths/Vector/VectorTransform.gd
Normal file
128
addons/ShaderLib/Maths/Vector/VectorTransform.gd
Normal file
@ -0,0 +1,128 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeVectorTransform extends VisualShaderNodeCustom
|
||||
|
||||
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 2
|
||||
|
||||
func _get_property_default_index(index: int) -> int:
|
||||
match index:
|
||||
0:
|
||||
return 0
|
||||
_:
|
||||
return 1
|
||||
|
||||
func _get_property_name(index: int) -> String:
|
||||
match index:
|
||||
0:
|
||||
return "From"
|
||||
_:
|
||||
return "To"
|
||||
|
||||
func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Local", "World", "View", "Screen", "Tangent"]
|
||||
|
||||
func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool:
|
||||
return mode == Shader.MODE_SPATIAL
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var code: String
|
||||
var from_coord_space_index: int = get_option_index(0)
|
||||
var to_coord_space_index: int = get_option_index(1)
|
||||
var input_vector: String = input_vars[0] if input_vars[0] else "vec3(0.0, 0.0, 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 = vector_transform_local_to_world(MODEL_MATRIX, %s);" % [output_vars[0], input_vector]
|
||||
2:
|
||||
code = "%s = vector_transform_local_to_view(MODEL_MATRIX, VIEW_MATRIX, %s);" % [output_vars[0], input_vector]
|
||||
3:
|
||||
code = "%s = vector_transform_local_to_screen(MODEL_MATRIX, VIEW_MATRIX, PROJECTION_MATRIX, %s);" % [output_vars[0], input_vector]
|
||||
4:
|
||||
code = "%s = vector_transform_local_to_tangent(NORMAL, BINORMAL, TANGENT, %s);" % [output_vars[0], input_vector]
|
||||
1:
|
||||
match to_coord_space_index:
|
||||
0:
|
||||
code = "%s = vector_transform_world_to_local(MODEL_MATRIX, %s);" % [output_vars[0], input_vector]
|
||||
1:
|
||||
code = "%s = %s;" % [output_vars[0], input_vector]
|
||||
2:
|
||||
code = "%s = vector_transform_world_to_view(VIEW_MATRIX, %s);" % [output_vars[0], input_vector]
|
||||
3:
|
||||
code = "%s = vector_transform_world_to_screen(VIEW_MATRIX, PROJECTION_MATRIX, %s);" % [output_vars[0], input_vector]
|
||||
4:
|
||||
code = "%s = vector_transform_world_to_tangent(MODEL_MATRIX, NORMAL, BINORMAL, TANGENT, %s);" % [output_vars[0], input_vector]
|
||||
2:
|
||||
match to_coord_space_index:
|
||||
0:
|
||||
code = "%s = vector_transform_view_to_local(INV_VIEW_MATRIX, MODEL_MATRIX, %s);" % [output_vars[0], input_vector]
|
||||
1:
|
||||
code = "%s = vector_transform_view_to_world(INV_VIEW_MATRIX, %s);" % [output_vars[0], input_vector]
|
||||
2:
|
||||
code = "%s = %s;" % [output_vars[0], input_vector]
|
||||
3:
|
||||
code = "%s = vector_transform_view_to_screen(PROJECTION_MATRIX, %s);" % [output_vars[0], input_vector]
|
||||
4:
|
||||
code = "%s = vector_transform_view_to_tangent(INV_VIEW_MATRIX, MODEL_MATRIX, NORMAL, BINORMAL, TANGENT, %s);" % [output_vars[0], input_vector]
|
||||
3:
|
||||
match to_coord_space_index:
|
||||
0:
|
||||
code = "%s = vector_transform_screen_to_local(INV_PROJECTION_MATRIX, INV_VIEW_MATRIX, MODEL_MATRIX, %s);" % [output_vars[0], input_vector]
|
||||
1:
|
||||
code = "%s = vector_transform_screen_to_world(INV_PROJECTION_MATRIX, INV_VIEW_MATRIX, %s);" % [output_vars[0], input_vector]
|
||||
2:
|
||||
code = "%s = vector_transform_screen_to_view(INV_PROJECTION_MATRIX, %s);" % [output_vars[0], input_vector]
|
||||
3:
|
||||
code = "%s = %s;" % [output_vars[0], input_vector]
|
||||
4:
|
||||
code = "%s = vector_transform_screen_to_tangent(INV_PROJECTION_MATRIX, INV_VIEW_MATRIX, MODEL_MATRIX, NORMAL, BINORMAL, TANGENT, %s);" % [output_vars[0], input_vector]
|
||||
4:
|
||||
match to_coord_space_index:
|
||||
0:
|
||||
code = "%s = vector_transform_tangent_to_local(NORMAL, BINORMAL, TANGENT, %s);" % [output_vars[0], input_vector]
|
||||
1:
|
||||
code = "%s = vector_transform_tangent_to_world(MODEL_MATRIX, NORMAL, BINORMAL, TANGENT, %s);" % [output_vars[0], input_vector]
|
||||
2:
|
||||
code = "%s = vector_transform_tangent_to_view(MODEL_MATRIX, VIEW_MATRIX, NORMAL, BINORMAL, TANGENT, %s);" % [output_vars[0], input_vector]
|
||||
3:
|
||||
code = "%s = vector_transform_tangent_to_screen(MODEL_MATRIX, VIEW_MATRIX, PROJECTION_MATRIX, NORMAL, BINORMAL, TANGENT, %s);" % [output_vars[0], input_vector]
|
||||
4:
|
||||
code = "%s = %s;" % [output_vars[0], input_vector]
|
||||
|
||||
return code
|
@ -1,9 +1,6 @@
|
||||
@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"
|
||||
|
||||
@ -14,7 +11,16 @@ 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
|
||||
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
|
||||
@ -29,11 +35,27 @@ func _get_input_port_name(port: int) -> String:
|
||||
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
match port:
|
||||
0:
|
||||
return PORT_TYPE_VECTOR_4D
|
||||
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
|
||||
|
||||
@ -41,16 +63,56 @@ func _get_output_port_name(port: int) -> String:
|
||||
return "out"
|
||||
|
||||
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_4D
|
||||
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:
|
||||
var code: String = preload("NoiseSineWave.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec4(0.0)"
|
||||
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]
|
||||
return output_vars[0] + " = noise_sine_wave(%s, %s);" % [input, min_max]
|
||||
|
||||
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]
|
||||
|
@ -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);
|
||||
}
|
@ -11,7 +11,16 @@ 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
|
||||
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
|
||||
@ -20,7 +29,16 @@ func _get_input_port_name(port: int) -> String:
|
||||
return "in"
|
||||
|
||||
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_4D
|
||||
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
|
||||
@ -29,10 +47,54 @@ func _get_output_port_name(port: int) -> String:
|
||||
return "out"
|
||||
|
||||
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_4D
|
||||
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/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec4(0.0)"
|
||||
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]
|
||||
return output_vars[0] + " = 2.0 * (%s - floor(0.5 + %s));" % [input, input]
|
||||
|
||||
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]
|
||||
|
@ -12,7 +12,16 @@ 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
|
||||
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
|
||||
@ -21,7 +30,16 @@ func _get_input_port_name(port: int) -> String:
|
||||
return "input"
|
||||
|
||||
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_4D
|
||||
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
|
||||
@ -30,10 +48,54 @@ func _get_output_port_name(port: int) -> String:
|
||||
return "out"
|
||||
|
||||
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_4D
|
||||
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/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec4(0.0)"
|
||||
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]
|
||||
return output_vars[0] + " = 1.0 - 2.0 * round(fract(%s));" % [input]
|
||||
|
||||
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]
|
||||
|
@ -11,7 +11,16 @@ 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
|
||||
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
|
||||
@ -19,7 +28,16 @@ func _get_input_port_count() -> int:
|
||||
func _get_input_port_name(port: int) -> String:
|
||||
return "in"
|
||||
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_4D
|
||||
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
|
||||
@ -28,10 +46,54 @@ func _get_output_port_name(port: int) -> String:
|
||||
return "out"
|
||||
|
||||
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_4D
|
||||
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/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec4(0.0)"
|
||||
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]
|
||||
return output_vars[0] + " = 2.0 * abs(2.0 * (%s - floor(0.5 + %s))) - 1.0;" % [input, input]
|
||||
|
||||
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]
|
||||
|
@ -2,10 +2,6 @@
|
||||
class_name VisualShaderNodeProceduralCheckerBoard extends VisualShaderNodeCustom
|
||||
|
||||
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/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
@ -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]
|
||||
|
@ -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);
|
||||
}
|
85
addons/ShaderLib/Procedural/Fractals/KochFractal.gd
Normal file
85
addons/ShaderLib/Procedural/Fractals/KochFractal.gd
Normal file
@ -0,0 +1,85 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeProceduralKochFractal extends VisualShaderNodeCustom
|
||||
|
||||
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/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
||||
if input_vars[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]]
|
||||
|
@ -2,8 +2,6 @@
|
||||
class_name VisualShaderNodeProceduralGradientNoise extends VisualShaderNodeCustom
|
||||
|
||||
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/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -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;
|
||||
}
|
78
addons/ShaderLib/Procedural/Noise/GyroidNoise.gd
Normal file
78
addons/ShaderLib/Procedural/Noise/GyroidNoise.gd
Normal file
@ -0,0 +1,78 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeProceduralGyroidNoise extends VisualShaderNodeCustom
|
||||
|
||||
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/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
||||
if input_vars[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]
|
@ -2,7 +2,6 @@
|
||||
class_name VisualShaderNodePseudoRandomNoise extends VisualShaderNodeCustom
|
||||
|
||||
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
|
||||
|
||||
@ -36,4 +42,4 @@ func _get_output_port_type(port: int) -> PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
return output_vars[0] + " = fract(sin(dot(UV.xy + vec2(%s), vec2(12.9898,78.233))) * 43758.5453123);" % input_vars[0]
|
||||
return output_vars[0] + " = pseudo_random_noise(UV, %s);" % input_vars[0]
|
||||
|
@ -2,8 +2,6 @@
|
||||
class_name VisualShaderNodeProceduralSimpleNoise extends VisualShaderNodeCustom
|
||||
|
||||
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/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
@ -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]
|
||||
|
@ -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;
|
||||
}
|
@ -2,9 +2,6 @@
|
||||
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:
|
||||
@ -20,25 +17,63 @@ func _get_return_icon_type() -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_input_port_count() -> int:
|
||||
return 3
|
||||
var distance_index: int = get_option_index(0)
|
||||
match distance_index:
|
||||
2:
|
||||
return 4
|
||||
_:
|
||||
return 3
|
||||
|
||||
func _get_input_port_name(port: int) -> String:
|
||||
match port:
|
||||
0:
|
||||
return "uv"
|
||||
1:
|
||||
return "cell density"
|
||||
var distance_index: int = get_option_index(0)
|
||||
match distance_index:
|
||||
2:
|
||||
return "angle offset"
|
||||
return ""
|
||||
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
|
||||
1, 2:
|
||||
_:
|
||||
return PORT_TYPE_SCALAR
|
||||
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 2.0
|
||||
_:
|
||||
return null
|
||||
_:
|
||||
match port:
|
||||
1:
|
||||
return 5.0
|
||||
2:
|
||||
return 2.0
|
||||
_:
|
||||
return null
|
||||
|
||||
func _get_output_port_count() -> int:
|
||||
return 2
|
||||
@ -47,16 +82,26 @@ 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_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:
|
||||
var code: String = preload("Voronoi.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
@ -64,9 +109,17 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad
|
||||
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 chebyshev_power: String = "0."
|
||||
|
||||
if distance_index == 2:
|
||||
if input_vars[3]:
|
||||
chebyshev_power = input_vars[3]
|
||||
|
||||
var output: String = output_vars[0]
|
||||
var cells: String = output_vars[1]
|
||||
|
||||
return "voronoi_noise(%s,%s, %s, %s, %s);" % [uv, cell_density, angle_offset, output, cells]
|
||||
return "voronoi_noise(%s, %s, %s, %s, %s, %s, %s);" % [uv, cell_density, angle_offset, distance_index, chebyshev_power, output, cells]
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
232
addons/ShaderLib/Procedural/Procedural.gdshaderinc
Normal file
232
addons/ShaderLib/Procedural/Procedural.gdshaderinc
Normal file
@ -0,0 +1,232 @@
|
||||
#include "res://addons/ShaderLib/Maths/Maths.gdshaderinc"
|
||||
|
||||
vec3 checker_board(vec2 uv, vec3 color_a, vec3 color_b, vec2 frequency) {
|
||||
uv = (uv.xy + 0.5) * frequency;
|
||||
vec4 derivatives = vec4(dFdx(uv), dFdy(uv));
|
||||
vec2 duv_length = sqrt(vec2(dot(derivatives.xz, derivatives.xz), dot(derivatives.yw, derivatives.yw)));
|
||||
float width = 1.0;
|
||||
vec2 distance3 = 4.0 * abs(fract(uv + 0.25) - 0.5) - width;
|
||||
vec2 scale = 0.35 / duv_length.xy;
|
||||
float frequency_limiter = sqrt(clamp(1.1f - max(duv_length.x, duv_length.y), 0.0, 1.0));
|
||||
vec2 vector_alpha = clamp(distance3 * scale.xy, -1.0, 1.0);
|
||||
float alpha = clamp(0.5f + 0.5f * vector_alpha.x * vector_alpha.y * frequency_limiter, 0.0, 1.0);
|
||||
return mix(color_b, color_a, alpha);
|
||||
}
|
||||
|
||||
vec2 koch_fractal_direction(float angle) {
|
||||
return vec2(sin(angle), cos(angle));
|
||||
}
|
||||
|
||||
float koch_fractal(vec2 uv, float outline, int iteration, float shape_width, float shape_height, out vec2 koch_uv) {
|
||||
float tiling = 3.0;
|
||||
vec2 center = uv - vec2(.5);
|
||||
shape_width = .85 * (shape_width / 1.);
|
||||
shape_height = .85 * (shape_height / 1.);
|
||||
center.x /= shape_width;
|
||||
center.y /= shape_height;
|
||||
|
||||
center.x = abs(center.x);
|
||||
center.y += tan(.833 * PI) * .5;
|
||||
vec2 dir = koch_fractal_direction(.833 * PI);
|
||||
float dist = dot(center - vec2(tiling / (2. * tiling), 0), dir);
|
||||
center -= dir * max(0, dist) * 2.0;
|
||||
|
||||
dir = koch_fractal_direction(.6667 * PI);
|
||||
float scale = 1.0;
|
||||
center.x += .5;
|
||||
for(int i = 0; i < iteration; i++){
|
||||
center *= tiling;
|
||||
scale *= tiling;
|
||||
center.x -= .5 * tiling;
|
||||
|
||||
center.x = abs(center.x);
|
||||
center.x -= .5;
|
||||
center -= dir * min(0.0, dot(center, dir)) * 2.0;
|
||||
}
|
||||
|
||||
dist = length(center - vec2(clamp(center.x, -1.0, 1.0), 0));
|
||||
dist += step(outline / 100.0, dist / scale);
|
||||
koch_uv = abs(center);
|
||||
return 1.0 - dist;
|
||||
}
|
||||
|
||||
vec2 gradient_modulo(vec2 divident, vec2 divisor) {
|
||||
vec2 positive_divident = mod(divident, divisor) + divisor;
|
||||
return mod(positive_divident, divisor);
|
||||
}
|
||||
|
||||
vec2 gradient_random(vec2 uv) {
|
||||
uv = vec2(dot(uv, vec2(127.1,311.7)), dot(uv, vec2(269.5,183.3)));
|
||||
return -1.0 + 2.0 * fract(sin(uv) * 43758.5453123);
|
||||
}
|
||||
|
||||
float gradient_noise(vec2 uv, float scale) {
|
||||
uv = uv * float(scale);
|
||||
vec2 period = vec2(30.0, 60.0);
|
||||
vec2 cells_minimum = floor(uv);
|
||||
vec2 cells_maximum = ceil(uv);
|
||||
vec2 uv_fract = fract(uv);
|
||||
cells_minimum = gradient_modulo(cells_minimum, period);
|
||||
cells_maximum = gradient_modulo(cells_maximum, period);
|
||||
vec2 blur = smoothstep(0.0, 1.0, uv_fract);
|
||||
vec2 lowerLeftDirection = gradient_random(vec2(cells_minimum.x, cells_minimum.y));
|
||||
vec2 lowerRightDirection = gradient_random(vec2(cells_maximum.x, cells_minimum.y));
|
||||
vec2 upperLeftDirection = gradient_random(vec2(cells_minimum.x, cells_maximum.y));
|
||||
vec2 upperRightDirection = gradient_random(vec2(cells_maximum.x, cells_maximum.y));
|
||||
vec2 fraction = fract(uv);
|
||||
float mix_one = mix(dot(lowerLeftDirection, fraction - vec2(0, 0)), dot(lowerRightDirection, fraction - vec2(1, 0)), blur.x);
|
||||
float mix_two = mix(dot(upperLeftDirection, fraction - vec2(0, 1)), dot(upperRightDirection, fraction - vec2(1, 1)), blur.x);
|
||||
return mix(mix_one, mix_two, blur.y) * 0.8 + 0.5;
|
||||
}
|
||||
|
||||
float gyroid_noise(vec2 uv, float scale, vec2 ratio, float height, float thickness) {
|
||||
scale *= 10.;
|
||||
thickness = clamp(thickness, 0., 1.);
|
||||
vec3 vector = vec3(uv, height);
|
||||
vector *= scale;
|
||||
return abs(dot(sin(vector * ratio.x), cos(vector.zxy * ratio.y))) - thickness;
|
||||
}
|
||||
|
||||
float pseudo_random_noise(vec2 uv, float seed) {
|
||||
return fract(sin(dot(uv.xy + seed, vec2(12.9898,78.233))) * 43758.5453123);
|
||||
}
|
||||
|
||||
float simple_noise_random(vec2 point) {
|
||||
return fract(sin(point.x * 100. + point.y * 654.125) * 55647.8745);
|
||||
}
|
||||
|
||||
float value_noise(vec2 uv) {
|
||||
vec2 grid_uv = fract(uv);
|
||||
vec2 grid_id = floor(uv);
|
||||
grid_uv = grid_uv * grid_uv * (3. - 2. * grid_uv);
|
||||
|
||||
float bottom_left = simple_noise_random(grid_id);
|
||||
float bottom_right = simple_noise_random(grid_id + vec2(1, 0));
|
||||
float bottom = mix(bottom_left, bottom_right, grid_uv.x);
|
||||
|
||||
float top_left = simple_noise_random(grid_id + vec2(0, 1));
|
||||
float top_right = simple_noise_random(grid_id + vec2(1, 1));
|
||||
float top = mix(top_left, top_right, grid_uv.x);
|
||||
|
||||
return mix(bottom, top, grid_uv.y);
|
||||
}
|
||||
|
||||
float simple_noise(vec2 uv, float scale, int octaves) {
|
||||
octaves = clamp(octaves, 1, 6);
|
||||
float noise = value_noise(uv * scale);
|
||||
float amplitude = 1.;
|
||||
|
||||
for(int i = 1; i < octaves; i++) {
|
||||
scale *= 2.;
|
||||
amplitude /= 2.;
|
||||
noise += value_noise(uv * scale) * amplitude;
|
||||
}
|
||||
|
||||
return noise / 2.;
|
||||
}
|
||||
|
||||
vec2 voronoi_random_vector(vec2 p) {
|
||||
mat2 matrix = mat2(vec2(15.27, 47.63), vec2(99.41, 89.98));
|
||||
return fract(sin(p * matrix) * 46839.32);
|
||||
}
|
||||
|
||||
void voronoi_noise(vec2 uv, float cell_density, float angle_offset, int distance_index, float chebyshev_power, out float output, out float cells){
|
||||
vec2 grid_uv = fract(uv * cell_density);
|
||||
vec2 grid_id = floor(uv * cell_density);
|
||||
vec2 cell_id = vec2(0);
|
||||
float min_dist = 100.;
|
||||
|
||||
for(float y = -1.; y <= 1.; y++) {
|
||||
for(float x = -1.; x <= 1.; x++) {
|
||||
vec2 offset = vec2(x, y);
|
||||
vec2 n = voronoi_random_vector(grid_id + offset);
|
||||
vec2 p = offset + vec2(sin(n.x + angle_offset) * .5 + .5, cos(n.y + angle_offset) * .5 + .5);
|
||||
float d = min_dist;
|
||||
|
||||
switch(distance_index){
|
||||
case 1:
|
||||
d = manhattan_distance_2d(grid_uv, p);
|
||||
break;
|
||||
case 2:
|
||||
d = chebyshev_distance_2d(grid_uv, p, chebyshev_power);
|
||||
break;
|
||||
default:
|
||||
d = distance(grid_uv, p);
|
||||
break;
|
||||
}
|
||||
|
||||
if(d < min_dist) {
|
||||
min_dist = d;
|
||||
cell_id = voronoi_random_vector(grid_id + offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output = min_dist;
|
||||
cells = cell_id.y;
|
||||
}
|
||||
|
||||
float ellipse_shape(vec2 uv, float width, float height) {
|
||||
float 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);
|
||||
}
|
@ -2,9 +2,6 @@
|
||||
class_name VisualShaderNodeProceduralEllipse extends VisualShaderNodeCustom
|
||||
|
||||
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/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -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);
|
||||
}
|
@ -2,10 +2,6 @@
|
||||
class_name VisualShaderNodeProceduralPolygon extends VisualShaderNodeCustom
|
||||
|
||||
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/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -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);
|
||||
}
|
@ -2,9 +2,6 @@
|
||||
class_name VisualShaderNodeProceduralRectangle extends VisualShaderNodeCustom
|
||||
|
||||
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/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -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);
|
||||
}
|
@ -2,11 +2,6 @@
|
||||
class_name VisualShaderNodeProceduralRoundedPolygon extends VisualShaderNodeCustom
|
||||
|
||||
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/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -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;
|
||||
}
|
@ -2,10 +2,6 @@
|
||||
class_name VisualShaderNodeProceduralRoundedRectangle extends VisualShaderNodeCustom
|
||||
|
||||
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/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -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);
|
||||
}
|
225
addons/ShaderLib/RayMarching/RayMarch.gd
Normal file
225
addons/ShaderLib/RayMarching/RayMarch.gd
Normal file
@ -0,0 +1,225 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeRayMarch extends VisualShaderNodeCustom
|
||||
|
||||
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/RayMarching/SignedDistanceFunctions.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var sdf_index: int = get_option_index(0)
|
||||
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]
|
||||
|
@ -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;
|
||||
}
|
150
addons/ShaderLib/RayMarching/SignedDistanceFunctions.gdshaderinc
Normal file
150
addons/ShaderLib/RayMarching/SignedDistanceFunctions.gdshaderinc
Normal 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;
|
||||
}
|
@ -1,15 +1,6 @@
|
||||
@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)
|
||||
|
||||
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/UV/UV.gdshaderinc\""
|
||||
|
||||
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]
|
||||
|
@ -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;
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeUVParallaxMapping extends VisualShaderNodeCustom
|
||||
|
||||
func _init() -> void:
|
||||
_set_input_port_default_value(1, 1.0)
|
||||
|
||||
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/UV/UV.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var height_map: String = input_vars[0]
|
||||
|
@ -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;
|
||||
}
|
@ -1,13 +1,6 @@
|
||||
@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)
|
||||
|
||||
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/UV/UV.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String
|
||||
|
@ -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;
|
||||
}
|
@ -1,13 +1,6 @@
|
||||
@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)
|
||||
|
||||
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/UV/UV.gdshaderinc\""
|
||||
|
||||
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]
|
||||
|
@ -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);
|
||||
}
|
@ -1,13 +1,6 @@
|
||||
@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)
|
||||
|
||||
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/UV/UV.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String
|
||||
|
@ -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;
|
||||
}
|
@ -1,13 +1,6 @@
|
||||
@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
|
||||
|
||||
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/UV/UV.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String
|
||||
|
@ -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);
|
||||
}
|
@ -1,12 +1,6 @@
|
||||
@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
|
||||
|
||||
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
|
||||
|
||||
|
@ -1,13 +1,6 @@
|
||||
@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
|
||||
|
||||
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/UV/UV.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String
|
||||
|
@ -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);
|
||||
}
|
77
addons/ShaderLib/UV/UV.gdshaderinc
Normal file
77
addons/ShaderLib/UV/UV.gdshaderinc
Normal 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;
|
||||
}
|
93
documentation/Documentation.md
Normal file
93
documentation/Documentation.md
Normal file
@ -0,0 +1,93 @@
|
||||
# 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> Adjustment</h3>
|
||||
|
||||
<h4><a href="/documentation/Nodes/Artistic/Adjustment/ContrastNode.md">  Contrast node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Artistic/Adjustment/HueNode.md">  Hue node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Artistic/Adjustment/ReplaceColorNode.md">  Replace Color node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Artistic/Adjustment/SaturationNode.md">  Saturation node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Artistic/Adjustment/WhiteBalanceNode.md">  White Balance node</a></h4>
|
||||
|
||||
<h3> Mask</h3>
|
||||
|
||||
<h4><a href="/documentation/Nodes/Artistic/Mask/ColorMaskNode.md">  Color Mask node</a></h4>
|
||||
|
||||
<h2>Geometry nodes</h2>
|
||||
|
||||
<h4><a href="/documentation/Nodes/Geometry/Mesh.md"> Mesh node</a></h4>
|
||||
|
||||
<h2>Maths nodes</h2>
|
||||
|
||||
<h3> Scalar</h3>
|
||||
|
||||
<h4><a href="/documentation/Nodes/Maths/Scalar/SmoothMax.md">  SmoothMax node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Maths/Scalar/SmoothMin.md">  SmoothMin node</a></h4>
|
||||
|
||||
<h3> Vector</h3>
|
||||
|
||||
<h3>  Distance</h3>
|
||||
|
||||
<h4><a href="/documentation/Nodes/Maths/Vector/Distance/ChebyshevDistance.md">   Chebyshev Distance node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Maths/Vector/Distance/ManhattanDistance.md">   Manhattan Distance node</a></h4>
|
||||
|
||||
<h4><a href="/documentation/Nodes/Maths/Vector/Project.md">  Project node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Maths/Vector/ProjectOnPlane.md">  Project On Plane node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Maths/Vector/VectorTransform.md">  Vector Transform node</a></h4>
|
||||
|
||||
<h3> Wave</h3>
|
||||
|
||||
<h4><a href="/documentation/Nodes/Maths/Wave/NoiseSineWave.md">  Noise Sine Wave node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Maths/Wave/SawtoothWave.md">  Sawtooth Wave node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Maths/Wave/SquareWave.md">  Square Wave node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Maths/Wave/TriangleWave.md">  Triangle Wave node</a></h4>
|
||||
|
||||
<h2>Procedural nodes</h2>
|
||||
|
||||
<h4><a href="/documentation/Nodes/Procedural/CheckerBoard.md"> Checker Board node</a></h4>
|
||||
|
||||
<h3> Fractals</h3>
|
||||
|
||||
<h4><a href="/documentation/Nodes/Procedural/Fractals/KochFractal.md">  Koch Fractal node</a></h4>
|
||||
|
||||
<h3> Noise</h3>
|
||||
|
||||
<h4><a href="/documentation/Nodes/Procedural/Noise/GradientNoise.md">  Gradient Noise node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Procedural/Noise/GyroidNoise.md">  Gyroid Noise node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Procedural/Noise/PseudoRandomNoise.md">  Pseudo Random Noise node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Procedural/Noise/SimpleNoise.md">  Simple Noise node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Procedural/Noise/Voronoi.md">  Voronoi node</a></h4>
|
||||
|
||||
<h3> Shapes</h3>
|
||||
|
||||
<h4><a href="/documentation/Nodes/Procedural/Shapes/Ellipse.md">  Ellipse node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Procedural/Shapes/Polygon.md">  Polygon node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Procedural/Shapes/Rectangle.md">  Rectangle node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Procedural/Shapes/RoundedPolygon.md">  Rounded Polygon node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Procedural/Shapes/RoundedRectangle.md">  Rounded Rectangle node</a></h4>
|
||||
|
||||
<h2>Ray marching nodes</h2>
|
||||
|
||||
<h4><a href="/documentation/Nodes/RayMarching/RayMarch.md"> Ray March node</a></h4>
|
||||
|
||||
<h2>UV nodes</h2>
|
||||
|
||||
<h4><a href="/documentation/Nodes/UV/Flipbook.md"> Flipbook node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/UV/ParallaxMapping.md"> Parallax Mapping node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/UV/RadialShear.md"> Radial Shear node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/UV/Rotate.md"> Rotate node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/UV/Spherize.md"> Spherize node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/UV/Swirl.md"> Swirl node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/UV/TilingAndOffset.md"> Tiling and Offset node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/UV/Twirl.md"> Twirl node</a></h4>
|
27
documentation/Nodes/Artistic/Adjustment/ContrastNode.md
Normal file
27
documentation/Nodes/Artistic/Adjustment/ContrastNode.md
Normal 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|
|
||||
___
|
33
documentation/Nodes/Artistic/Adjustment/HueNode.md
Normal file
33
documentation/Nodes/Artistic/Adjustment/HueNode.md
Normal 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|
|
||||
___
|
33
documentation/Nodes/Artistic/Adjustment/ReplaceColorNode.md
Normal file
33
documentation/Nodes/Artistic/Adjustment/ReplaceColorNode.md
Normal 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|
|
||||
___
|
27
documentation/Nodes/Artistic/Adjustment/SaturationNode.md
Normal file
27
documentation/Nodes/Artistic/Adjustment/SaturationNode.md
Normal 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|
|
||||
___
|
29
documentation/Nodes/Artistic/Adjustment/WhiteBalanceNode.md
Normal file
29
documentation/Nodes/Artistic/Adjustment/WhiteBalanceNode.md
Normal 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|
|
||||
___
|
31
documentation/Nodes/Artistic/Mask/ColorMaskNode.md
Normal file
31
documentation/Nodes/Artistic/Mask/ColorMaskNode.md
Normal 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.|
|
||||
___
|
21
documentation/Nodes/Geometry/Mesh.md
Normal file
21
documentation/Nodes/Geometry/Mesh.md
Normal 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|
|
||||
___
|
29
documentation/Nodes/Maths/Scalar/SmoothMax.md
Normal file
29
documentation/Nodes/Maths/Scalar/SmoothMax.md
Normal 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|
|
||||
___
|
29
documentation/Nodes/Maths/Scalar/SmoothMin.md
Normal file
29
documentation/Nodes/Maths/Scalar/SmoothMin.md
Normal 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|
|
||||
___
|
@ -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|
|
||||
___
|
@ -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|
|
||||
___
|
39
documentation/Nodes/Maths/Vector/Project.md
Normal file
39
documentation/Nodes/Maths/Vector/Project.md
Normal 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|
|
||||
___
|
27
documentation/Nodes/Maths/Vector/ProjectOnPlane.md
Normal file
27
documentation/Nodes/Maths/Vector/ProjectOnPlane.md
Normal 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|
|
||||
___
|
20
documentation/Nodes/Maths/Vector/VectorTransform.md
Normal file
20
documentation/Nodes/Maths/Vector/VectorTransform.md
Normal file
@ -0,0 +1,20 @@
|
||||
# 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|
|
||||
|---|---|---|
|
||||
|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|
|
||||
___
|
32
documentation/Nodes/Maths/Wave/NoiseSineWave.md
Normal file
32
documentation/Nodes/Maths/Wave/NoiseSineWave.md
Normal 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|
|
||||
___
|
30
documentation/Nodes/Maths/Wave/SawtoothWave.md
Normal file
30
documentation/Nodes/Maths/Wave/SawtoothWave.md
Normal 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|
|
||||
___
|
30
documentation/Nodes/Maths/Wave/SquareWave.md
Normal file
30
documentation/Nodes/Maths/Wave/SquareWave.md
Normal 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|
|
||||
___
|
30
documentation/Nodes/Maths/Wave/TriangleWave.md
Normal file
30
documentation/Nodes/Maths/Wave/TriangleWave.md
Normal 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|
|
||||
___
|
31
documentation/Nodes/Procedural/CheckerBoard.md
Normal file
31
documentation/Nodes/Procedural/CheckerBoard.md
Normal 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|
|
||||
___
|
35
documentation/Nodes/Procedural/Fractals/KochFractal.md
Normal file
35
documentation/Nodes/Procedural/Fractals/KochFractal.md
Normal 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|
|
||||
___
|
27
documentation/Nodes/Procedural/Noise/GradientNoise.md
Normal file
27
documentation/Nodes/Procedural/Noise/GradientNoise.md
Normal 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|
|
||||
___
|
33
documentation/Nodes/Procedural/Noise/GyroidNoise.md
Normal file
33
documentation/Nodes/Procedural/Noise/GyroidNoise.md
Normal 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|
|
||||
___
|
26
documentation/Nodes/Procedural/Noise/PseudoRandomNoise.md
Normal file
26
documentation/Nodes/Procedural/Noise/PseudoRandomNoise.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Pseudo Random Noise node
|
||||
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|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`float pseudo_random_noise(vec2 uv, float seed)`
|
||||
|
||||
**Parameters**
|
||||
|Name|Type|Description|
|
||||
|---|---|---|
|
||||
|uv|vec2|Input UV value|
|
||||
|seed|float|Noise seed|
|
||||
___
|
29
documentation/Nodes/Procedural/Noise/SimpleNoise.md
Normal file
29
documentation/Nodes/Procedural/Noise/SimpleNoise.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Simple Noise node
|
||||
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|
|
||||
|octaves|int|none|Octaves/Layers of noise, <b><i>octaves</i></b> input is clamped between 1 and 6.|
|
||||
|
||||
**Outputs**
|
||||
|Name|Type|Binding|Description|
|
||||
|---|---|---|---|
|
||||
|output|float|None|Output noise value|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`float simple_noise(vec2 uv, float scale, int octaves)`
|
||||
|
||||
**Parameters**
|
||||
|Name|Type|Description|
|
||||
|---|---|---|
|
||||
|uv|vec2|Input UV value|
|
||||
|scale|float|Noise scale|
|
||||
|octaves|int|Octaves/Layers of noise, clamped between 1 and 6.|
|
||||
___
|
40
documentation/Nodes/Procedural/Noise/Voronoi.md
Normal file
40
documentation/Nodes/Procedural/Noise/Voronoi.md
Normal file
@ -0,0 +1,40 @@
|
||||
# Voronoi node
|
||||
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>
|
||||
|
||||
**Controls**
|
||||
|Name|Options|Description|
|
||||
|---|---|---|
|
||||
|Distance|Euclidean, Manhattan, Chebyshev|Distance matrix used to calculate the noise|
|
||||
|
||||
**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|
|
||||
|chebyshev power|float|none|Power values for Chebyshev distance matrix|
|
||||
|
||||
**Outputs**
|
||||
|Name|Type|Binding|Description|
|
||||
|---|---|---|---|
|
||||
|output|float|None|Output noise value|
|
||||
|cells|float|None|Raw cell data|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`void voronoi_noise(vec2 uv, float cell_density, float angle_offset, int distance_index, float chebyshev_power, out float output, out float cells)`
|
||||
|
||||
**Parameters**
|
||||
|Name|Type|Description|
|
||||
|---|---|---|
|
||||
|uv|vec2|Input UV value|
|
||||
|cell_density|float|Density of generated cells|
|
||||
|angle_offset|float|Offset values for points|
|
||||
|distance_index|int|Distance matrix to use for Voronoi, 0 = Euclidean, 1 = Manhattan, 2 = Chebyshev|
|
||||
|chebyshev_power|float|Power for Chebyshev distance|
|
||||
|output|out float|Output noise value|
|
||||
|cells|out float|Output raw cell data|
|
||||
___
|
29
documentation/Nodes/Procedural/Shapes/Ellipse.md
Normal file
29
documentation/Nodes/Procedural/Shapes/Ellipse.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Ellipse node
|
||||
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](/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 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|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`float ellipse_shape(vec2 uv, float width, float height)`
|
||||
|
||||
**Parameters**
|
||||
|Name|Type|Description|
|
||||
|---|---|---|
|
||||
|uv|vec2|Input UV value|
|
||||
|width|float|Ellipse width|
|
||||
|height|float|Ellipse height|
|
||||
___
|
31
documentation/Nodes/Procedural/Shapes/Polygon.md
Normal file
31
documentation/Nodes/Procedural/Shapes/Polygon.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Polygon node
|
||||
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](/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 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|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`float polygon_shape(vec2 uv, int sides, float width, float height)`
|
||||
|
||||
**Parameters**
|
||||
|Name|Type|Description|
|
||||
|---|---|---|
|
||||
|uv|vec2|Input UV value|
|
||||
|sides|int|Number of sides of the polygon|
|
||||
|width|float|Polygon width|
|
||||
|height|float|Polygon height|
|
||||
___
|
29
documentation/Nodes/Procedural/Shapes/Rectangle.md
Normal file
29
documentation/Nodes/Procedural/Shapes/Rectangle.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Rectangle node
|
||||
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](/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 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|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`float rectangle_shape(vec2 uv, float width, float height)`
|
||||
|
||||
**Parameters**
|
||||
|Name|Type|Description|
|
||||
|---|---|---|
|
||||
|uv|vec2|Input UV value|
|
||||
|width|float|Rectangle width|
|
||||
|height|float|Rectangle height|
|
||||
___
|
33
documentation/Nodes/Procedural/Shapes/RoundedPolygon.md
Normal file
33
documentation/Nodes/Procedural/Shapes/RoundedPolygon.md
Normal file
@ -0,0 +1,33 @@
|
||||
# Rounded Polygon node
|
||||
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](/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 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|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`float rounded_polygon_shape(vec2 uv, float width, float height, float sides, float roundness)`
|
||||
|
||||
**Parameters**
|
||||
|Name|Type|Description|
|
||||
|---|---|---|
|
||||
|uv|vec2|Input UV value|
|
||||
|width|float|Polygon width|
|
||||
|height|float|Polygon height|
|
||||
|sides|float|Number of sides of the polygon|
|
||||
|roundness|float|Corner radius|
|
||||
___
|
31
documentation/Nodes/Procedural/Shapes/RoundedRectangle.md
Normal file
31
documentation/Nodes/Procedural/Shapes/RoundedRectangle.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Rounded Rectangle node
|
||||
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](/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 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|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Procedural/Procedural.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`float rounded_rectangle_shape(vec2 uv, float width, float height, float radius)`
|
||||
|
||||
**Parameters**
|
||||
|Name|Type|Description|
|
||||
|---|---|---|
|
||||
|uv|vec2|Input UV value|
|
||||
|width|float|Rectangle width|
|
||||
|height|float|Rectangle height|
|
||||
|radius|float|Corner radius|
|
||||
___
|
BIN
documentation/Nodes/RayMarching/Expression.jpg
Normal file
BIN
documentation/Nodes/RayMarching/Expression.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 74 KiB |
BIN
documentation/Nodes/RayMarching/GlobalExpression.jpg
Normal file
BIN
documentation/Nodes/RayMarching/GlobalExpression.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 120 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user