2024-02-27 22:15:06 +05:30
|
|
|
@tool
|
2024-09-28 00:45:16 +05:30
|
|
|
class_name VisualShaderNodeVectorProjectOnPlane extends ShaderLib
|
2024-02-27 22:15:06 +05:30
|
|
|
|
|
|
|
func _get_name() -> String:
|
|
|
|
return "ProjectOnPlane"
|
|
|
|
|
|
|
|
func _get_category() -> String:
|
|
|
|
return "Maths/Vector"
|
|
|
|
|
|
|
|
func _get_description() -> String:
|
|
|
|
return "Projects a vector onto a plane defined by a normal orthogonal to the plane."
|
|
|
|
|
|
|
|
func _get_return_icon_type() -> PortType:
|
2024-07-03 00:01:09 +05:30
|
|
|
return PORT_TYPE_VECTOR_3D
|
2024-02-27 22:15:06 +05:30
|
|
|
|
|
|
|
func _get_input_port_count() -> int:
|
|
|
|
return 2
|
|
|
|
|
|
|
|
func _get_input_port_name(port: int) -> String:
|
|
|
|
match port:
|
|
|
|
0:
|
|
|
|
return "vector"
|
|
|
|
_:
|
|
|
|
return "plane normal"
|
|
|
|
|
|
|
|
func _get_input_port_type(port: int) -> PortType:
|
2024-07-03 00:01:09 +05:30
|
|
|
return PORT_TYPE_VECTOR_3D
|
2024-02-27 22:15:06 +05:30
|
|
|
|
|
|
|
func _get_output_port_count() -> int:
|
|
|
|
return 1
|
|
|
|
|
|
|
|
func _get_output_port_name(port: int) -> String:
|
|
|
|
return "vector"
|
|
|
|
|
|
|
|
func _get_output_port_type(port: int) -> PortType:
|
2024-07-03 00:01:09 +05:30
|
|
|
return PORT_TYPE_VECTOR_3D
|
2024-02-27 22:15:06 +05:30
|
|
|
|
2024-07-03 00:01:09 +05:30
|
|
|
func _get_global_code(mode: Shader.Mode) -> String:
|
2024-09-28 00:45:16 +05:30
|
|
|
return "#include \"res://addons/ShaderLib_%s/Maths/Maths.gdshaderinc\"" % [version]
|
2024-02-27 22:15:06 +05:30
|
|
|
|
|
|
|
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
|
|
|
var vector_a: String = input_vars[0]
|
|
|
|
var plane_normal: String = input_vars[1]
|
2024-07-03 00:01:09 +05:30
|
|
|
return output_vars[0] + " = project_on_plane(%s, %s);" % [vector_a, plane_normal]
|