mirror of
https://github.com/DigvijaysinhGohil/Godot-Shader-Lib.git
synced 2025-01-07 01:43:35 +08:00
NodeScaleWorld node added
This commit is contained in:
parent
6213ca89c3
commit
7b16ab0b8f
36
addons/ShaderLib/Input/NodeScaleWorld.gd
Normal file
36
addons/ShaderLib/Input/NodeScaleWorld.gd
Normal file
@ -0,0 +1,36 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeInputNodeScaleWorld extends VisualShaderNodeCustom
|
||||
|
||||
func _get_name() -> String:
|
||||
return "NodeScaleWorld"
|
||||
|
||||
func _get_category() -> String:
|
||||
return "Input"
|
||||
|
||||
func _get_description() -> String:
|
||||
return "Provides accees to node scale in world space."
|
||||
|
||||
func _get_input_port_count() -> int:
|
||||
return 0
|
||||
|
||||
func _get_input_port_name(port: int) -> String:
|
||||
return ""
|
||||
|
||||
func _get_return_icon_type() -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_3D
|
||||
|
||||
func _get_output_port_count() -> int:
|
||||
return 1
|
||||
|
||||
func _get_output_port_name(port: int) -> String:
|
||||
return "scale"
|
||||
|
||||
func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_3D
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("NodeScaleWorld.gdshaderinc").code
|
||||
return code
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
return output_vars[0] + " = node_scale_world(MODEL_MATRIX);"
|
11
addons/ShaderLib/Input/NodeScaleWorld.gdshaderinc
Normal file
11
addons/ShaderLib/Input/NodeScaleWorld.gdshaderinc
Normal file
@ -0,0 +1,11 @@
|
||||
vec3 node_scale_world(mat4 model_matrix){
|
||||
vec3 _axis_x = model_matrix[0].xyz;
|
||||
vec3 _axis_y = model_matrix[1].xyz;
|
||||
vec3 _axis_z = model_matrix[2].xyz;
|
||||
|
||||
float _scale_x = length(_axis_x);
|
||||
float _scale_y = length(_axis_y);
|
||||
float _scale_z = length(_axis_z);
|
||||
|
||||
return vec3(_scale_x, _scale_y, _scale_z);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user