1
0
mirror of https://github.com/DigvijaysinhGohil/Godot-Shader-Lib.git synced 2025-01-07 01:43:35 +08:00

Merge branch 'godot-4.2'

This commit is contained in:
Digvijaysinh Gohil 2024-01-13 19:03:34 +05:30
commit 571098f3d9
25 changed files with 481 additions and 82 deletions

21
LICENSE Normal file
View File

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

View File

@ -12,13 +12,14 @@ Delete the contents of **_addons/ShaderLib_** folder from your project. Make sur
<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.
<summary><h3>Mesh node</h3></summary>
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|
___
</details>
@ -27,6 +28,31 @@ ___
<details open>
<summary><h1>Maths nodes</h1></summary>
<details open>
<summary><h2>Vector</h2></summary>
<details>
<summary><h3>Vector Transform node</h3></summary>
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|
___
</details>
</details>
<details open>
<summary><h2>Wave</h2></summary>
<details>
<summary><h3>Noise Sine Wave node</h3></summary>
@ -360,7 +386,11 @@ Rotates value of input UV around a reference point defined by input <b><i>center
|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|
**Controls**
|Name|Options|Description|
|---|---|---|
|Units|Degrees, Radians|Specifies the unit for <i><b>rotation</b></i> input|
**Outputs**
|Name|Type|Binding|Description|

View File

@ -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,11 @@ 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
var code: String = preload("MeshNode.gdshaderinc").code
return code
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 = geometry_node_scale_world(MODEL_MATRIX);" % output_vars[0]
code += "\n%s = NODE_POSITION_WORLD;" % output_vars[1]
return code

View File

@ -0,0 +1,129 @@
@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:
var code: String = preload("VectorTransform.gdshaderinc").code
return code
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

View File

@ -0,0 +1,99 @@
vec3 vector_transform_world_to_local(mat4 model_matrix, vec3 vector){
return (transpose(model_matrix) * vec4(vector, 0.0)).xyz;
}
vec3 vector_transform_world_to_view(mat4 view_matrix, vec3 vector){
return (view_matrix * vec4(vector, 0.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, 0.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, 0.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, 0.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, 0.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, 0.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, 0.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, 0.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 = transpose(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 = transpose(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 = transpose(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 = transpose(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);
}

View File

@ -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"
@ -34,6 +31,13 @@ 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(0.0, 1.0)
_:
return null
func _get_output_port_count() -> int:
return 1

View File

@ -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
@ -66,4 +73,4 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad
var color_b: String = input_vars[2]
var frequency: String = input_vars[3]
return output_vars[0] + " = checker_board(%s, %s, %s, %s);" % [uv, color_a, color_b, frequency]
return output_vars[0] + " = checker_board(%s, %s.xyz, %s.xyz, %s);" % [uv, color_a, color_b, frequency]

View File

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

View File

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

View File

@ -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:
@ -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

View File

@ -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:
@ -40,6 +37,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 5.0
2:
return 2.0
_:
return null
func _get_output_port_count() -> int:
return 2

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,12 +2,6 @@
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:
@ -51,6 +45,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, 2:
return 1
3, 4:
return 0
5:
return 0.1
_:
return null
func _get_output_port_count() -> int:
return 1

View File

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

View File

@ -2,10 +2,6 @@
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:
@ -43,6 +39,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

View File

@ -2,10 +2,6 @@
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:
@ -21,7 +17,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 +27,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 +35,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,6 +55,18 @@ 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
@ -72,6 +85,6 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad
var center: String = input_vars[1]
var rotation: String = input_vars[2]
var use_degrees: String = input_vars[3]
var use_degrees: String = "true" if get_option_index(0) == 0 else "false"
return output_vars[0] + " = rotate_uv(%s, %s, %s, %s);" % [uv, center, rotation, use_degrees]

View File

@ -2,10 +2,6 @@
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:
@ -43,6 +39,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

View File

@ -2,10 +2,6 @@
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:
@ -43,6 +39,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

View File

@ -2,9 +2,6 @@
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:
@ -38,6 +35,15 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_2D
return PORT_TYPE_SCALAR
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return Vector2(1.0, 1.0)
2:
return Vector2(0.0, 0.0)
_:
return null
func _get_output_port_count() -> int:
return 1

View File

@ -2,10 +2,6 @@
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:
@ -43,6 +39,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