1
0
mirror of https://github.com/DigvijaysinhGohil/Godot-Shader-Lib.git synced 2025-01-10 03:08:46 +08:00

66 lines
1.5 KiB
GDScript3
Raw Normal View History

2023-10-13 00:49:16 +05:30
@tool
class_name VisualShaderNodeProceduralGradientNoise extends VisualShaderNodeCustom
func _init() -> void:
output_port_for_preview = 0
func _get_name() -> String:
return "GradientNoise"
func _get_category() -> String:
return "Procedural/Noise"
func _get_description() -> String:
2023-10-15 00:03:42 +05:30
return "Generates a gradient, or Perlin noise based on input UV."
2023-10-13 00:49:16 +05:30
func _get_return_icon_type() -> VisualShaderNode.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 "uv"
1:
return "scale"
return ""
func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
match port:
0:
return PORT_TYPE_VECTOR_2D
1:
return PORT_TYPE_SCALAR
return PORT_TYPE_SCALAR
2024-01-12 16:53:06 +05:30
func _get_input_port_default_value(port: int) -> Variant:
match port:
1:
return 10.0
_:
return null
2023-10-13 00:49:16 +05:30
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) -> VisualShaderNode.PortType:
return PORT_TYPE_SCALAR
func _get_global_code(mode: Shader.Mode) -> String:
var code: String = preload("GradientNoise.gdshaderinc").code
return code
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
if input_vars[0]:
uv = input_vars[0]
var scale: String = input_vars[1]
return output_vars[0] + " = gradient_noise(%s, %s);" % [uv, scale]