diff --git a/README.md b/README.md index 5add5e2..75e814f 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,14 @@ Delete the contents of **_addons/ShaderLib_** folder from your project. Make sur

Geometry nodes

-

Node Scale World node

-Provides accees to node scale in world space. +

Mesh node

+Provides accees to node's position and scale in world space.
**Outputs** |Name|Type|Binding|Description| |---|---|---|---| +|position|vec3|None|Node/object position in world space| |scale|vec3|None|Node/object scale in world space| ___
diff --git a/addons/ShaderLib/Geometry/NodeScaleWorld.gd b/addons/ShaderLib/Geometry/MeshNode.gd similarity index 70% rename from addons/ShaderLib/Geometry/NodeScaleWorld.gd rename to addons/ShaderLib/Geometry/MeshNode.gd index e804f46..9ba0b45 100644 --- a/addons/ShaderLib/Geometry/NodeScaleWorld.gd +++ b/addons/ShaderLib/Geometry/MeshNode.gd @@ -1,8 +1,8 @@ @tool -class_name VisualShaderNodeGeometryNodeScaleWorld extends VisualShaderNodeCustom +class_name VisualShaderNodeGeometryMeshNode extends VisualShaderNodeCustom func _get_name() -> String: - return "NodeScaleWorld" + return "MeshNode" func _get_category() -> String: return "Geometry" @@ -20,10 +20,14 @@ func _get_return_icon_type() -> VisualShaderNode.PortType: return PORT_TYPE_VECTOR_3D func _get_output_port_count() -> int: - return 1 + return 2 func _get_output_port_name(port: int) -> String: - return "scale" + match port: + 0: + return "position" + _: + return "scale" func _get_output_port_type(port: int) -> VisualShaderNode.PortType: return PORT_TYPE_VECTOR_3D @@ -38,8 +42,11 @@ func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool: return false func _get_global_code(mode: Shader.Mode) -> String: - var code: String = preload("NodeScaleWorld.gdshaderinc").code + var code: String = preload("MeshNode.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] + " = geometry_node_scale_world(MODEL_MATRIX);" + var code: String + code = "%s = geometry_node_scale_world(MODEL_MATRIX);" % output_vars[0] + code += "\n%s = NODE_POSITION_WORLD;" % output_vars[1] + return code diff --git a/addons/ShaderLib/Geometry/NodeScaleWorld.gdshaderinc b/addons/ShaderLib/Geometry/MeshNode.gdshaderinc similarity index 100% rename from addons/ShaderLib/Geometry/NodeScaleWorld.gdshaderinc rename to addons/ShaderLib/Geometry/MeshNode.gdshaderinc