new outline shader
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
|
||||
@export var meshInstance: MeshInstance3D
|
||||
@export var preview_shader: ShaderMaterial
|
||||
|
||||
var default_shaders: Array
|
||||
var staic_body: StaticBody3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Global.preview_created.connect(_on_preview_create)
|
||||
Global.object_placed.connect(_on_object_placed)
|
||||
set_default_shaders()
|
||||
|
||||
staic_body = $StaticBody3D
|
||||
staic_body.mouse_entered.connect(_on_mouse_enter)
|
||||
staic_body.mouse_exited.connect(_on_mouse_exit)
|
||||
print(staic_body)
|
||||
|
||||
|
||||
func set_default_shaders():
|
||||
@@ -46,3 +54,22 @@ func _on_preview_create():
|
||||
|
||||
func _on_object_placed():
|
||||
restore_default_shaders()
|
||||
|
||||
|
||||
func enable_outline():
|
||||
for i in meshInstance.get_surface_override_material_count():
|
||||
var material = meshInstance.get_surface_override_material(i)
|
||||
if material.next_pass != null:
|
||||
meshInstance.get_surface_override_material(i).next_pass.set_shader_parameter("is_active", true)
|
||||
func disable_outline():
|
||||
for i in meshInstance.get_surface_override_material_count():
|
||||
var material = meshInstance.get_surface_override_material(i)
|
||||
if material.next_pass != null:
|
||||
meshInstance.get_surface_override_material(i).next_pass.set_shader_parameter("is_active", false)
|
||||
|
||||
|
||||
|
||||
func _on_mouse_enter():
|
||||
enable_outline()
|
||||
func _on_mouse_exit():
|
||||
disable_outline()
|
||||
|
||||
Reference in New Issue
Block a user