mirror of
https://github.com/DigvijaysinhGohil/Godot-Shader-Lib.git
synced 2025-09-20 04:15:58 +08:00
Maths nodes refactored, Smoothmin and Smoothmax nodes added
This commit is contained in:
@ -70,6 +70,10 @@ func _get_property_name(index: int) -> String:
|
||||
func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Vector1", "Vector2", "Vector3", "Vector4"]
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("SawtoothWave.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
|
||||
var vector_index: int = get_option_index(0)
|
||||
@ -86,4 +90,12 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad
|
||||
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]
|
||||
|
3
addons/ShaderLib/Maths/Wave/SawtoothWave.gdshaderinc
Normal file
3
addons/ShaderLib/Maths/Wave/SawtoothWave.gdshaderinc
Normal file
@ -0,0 +1,3 @@
|
||||
vec4 sawtooth_wave(vec4 input) {
|
||||
return 2. * (input - floor(.5 + input));
|
||||
}
|
@ -71,6 +71,10 @@ func _get_property_name(index: int) -> String:
|
||||
func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Vector1", "Vector2", "Vector3", "Vector4"]
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("SquareWave.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
|
||||
var vector_index: int = get_option_index(0)
|
||||
@ -87,4 +91,12 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad
|
||||
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]
|
||||
|
3
addons/ShaderLib/Maths/Wave/SquareWave.gdshaderinc
Normal file
3
addons/ShaderLib/Maths/Wave/SquareWave.gdshaderinc
Normal file
@ -0,0 +1,3 @@
|
||||
vec4 square_wave(vec4 input) {
|
||||
return 1. - 2. * round(fract(input));
|
||||
}
|
@ -69,6 +69,10 @@ func _get_property_name(index: int) -> String:
|
||||
func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Vector1", "Vector2", "Vector3", "Vector4"]
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("TriangleWave.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
|
||||
var vector_index: int = get_option_index(0)
|
||||
@ -85,4 +89,12 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad
|
||||
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]
|
||||
|
3
addons/ShaderLib/Maths/Wave/TriangleWave.gdshaderinc
Normal file
3
addons/ShaderLib/Maths/Wave/TriangleWave.gdshaderinc
Normal file
@ -0,0 +1,3 @@
|
||||
vec4 triangle_wave(vec4 input) {
|
||||
return 2. * abs(2. * (input - floor(.5 + input))) - 1.;
|
||||
}
|
Reference in New Issue
Block a user