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

Wave nodes updated

This commit is contained in:
Digvijaysinh Gohil 2024-02-27 23:11:12 +05:30
parent bd86743d0f
commit 7adea627e0
6 changed files with 239 additions and 17 deletions

View File

@ -11,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
@ -26,7 +35,16 @@ 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
@ -45,16 +63,57 @@ 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
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]

View File

@ -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,43 @@ 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_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]

View File

@ -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,43 @@ 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_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]

View File

@ -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,43 @@ 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_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]

View File

@ -2,6 +2,11 @@
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|
|---|---|---|---|

View File

@ -2,6 +2,11 @@
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|
|---|---|---|---|