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

VectorTransform node initial implementation

This commit is contained in:
Digvijaysinh Gohil 2024-01-12 16:19:35 +05:30
parent 64dead8a82
commit a0aaf91ef3
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,74 @@
@tool
class_name VisualShaderNodeVectorTransform extends VisualShaderNodeCustom
func _init() -> void:
_set_input_port_default_value(0, Vector3(0.0, 0.0, 0.0))
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 "input"
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 "output"
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 _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)
#match from_coord_space_index:
#0:
#1:
#2:
#3:
#4:
code = "%s = some_function(%s)" % [input_vars[0], output_vars[0]]
return output_vars[0] + " = 0.0;"