generated from krampus/template-godot4
GunkBody takes an optional initial gunk mask
Some checks failed
linting & formatting / build (push) Failing after 5s
Some checks failed
linting & formatting / build (push) Failing after 5s
This commit is contained in:
parent
99ec33ed3c
commit
96e657e21d
@ -3,20 +3,19 @@
|
|||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://8cm835h4gxwe"
|
uid="uid://8cm835h4gxwe"
|
||||||
path.s3tc="res://.godot/imported/debug_mask.png-fd2bc783338ed9439fe81a4eef9d86da.s3tc.ctex"
|
path="res://.godot/imported/debug_mask.png-fd2bc783338ed9439fe81a4eef9d86da.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"imported_formats": ["s3tc_bptc"],
|
"vram_texture": false
|
||||||
"vram_texture": true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://assets/debug_mask.png"
|
source_file="res://assets/debug_mask.png"
|
||||||
dest_files=["res://.godot/imported/debug_mask.png-fd2bc783338ed9439fe81a4eef9d86da.s3tc.ctex"]
|
dest_files=["res://.godot/imported/debug_mask.png-fd2bc783338ed9439fe81a4eef9d86da.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
compress/mode=2
|
compress/mode=0
|
||||||
compress/high_quality=false
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
compress/hdr_compression=1
|
compress/hdr_compression=1
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
[gd_scene load_steps=46 format=4 uid="uid://16ds4fvv72xk"]
|
[gd_scene load_steps=47 format=4 uid="uid://16ds4fvv72xk"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://c2omlx4ptrc01" path="res://src/world/gunk_body/gunk_body.tscn" id="1_a67lu"]
|
[ext_resource type="PackedScene" uid="uid://c2omlx4ptrc01" path="res://src/world/gunk_body/gunk_body.tscn" id="1_a67lu"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bwe2jdmvinhqd" path="res://src/player/player.tscn" id="1_h436a"]
|
[ext_resource type="PackedScene" uid="uid://bwe2jdmvinhqd" path="res://src/player/player.tscn" id="1_h436a"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://8cm835h4gxwe" path="res://assets/debug_mask.png" id="2_2roq2"]
|
||||||
[ext_resource type="Shader" uid="uid://ckxc0ngd37rtk" path="res://src/shaders/gunk.gdshader" id="5_rdjtm"]
|
[ext_resource type="Shader" uid="uid://ckxc0ngd37rtk" path="res://src/shaders/gunk.gdshader" id="5_rdjtm"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bniqwnr66mvwa" path="res://assets/level/hallway/hallway_1_C.png" id="6_hrvvi"]
|
[ext_resource type="Texture2D" uid="uid://bniqwnr66mvwa" path="res://assets/level/hallway/hallway_1_C.png" id="6_hrvvi"]
|
||||||
[ext_resource type="FastNoiseLite" uid="uid://cnlvdtx68giv6" path="res://assets/materials/gunk_noise.tres" id="6_l64ek"]
|
[ext_resource type="FastNoiseLite" uid="uid://cnlvdtx68giv6" path="res://assets/materials/gunk_noise.tres" id="6_l64ek"]
|
||||||
@ -397,6 +398,7 @@ shape = SubResource("WorldBoundaryShape3D_c8g65")
|
|||||||
[node name="Icosahedron" parent="Geometry" node_paths=PackedStringArray("mesh_instance") instance=ExtResource("1_a67lu")]
|
[node name="Icosahedron" parent="Geometry" node_paths=PackedStringArray("mesh_instance") instance=ExtResource("1_a67lu")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.35498, 1.13294, -2.81423)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.35498, 1.13294, -2.81423)
|
||||||
mesh_instance = NodePath("MeshInstance3D")
|
mesh_instance = NodePath("MeshInstance3D")
|
||||||
|
initial_mask = ExtResource("2_2roq2")
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Geometry/Icosahedron"]
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="Geometry/Icosahedron"]
|
||||||
mesh = SubResource("ArrayMesh_2roq2")
|
mesh = SubResource("ArrayMesh_2roq2")
|
||||||
|
@ -6,10 +6,16 @@ signal painted
|
|||||||
var _draw_queue: Array[Callable] = []
|
var _draw_queue: Array[Callable] = []
|
||||||
|
|
||||||
var _dirty := false
|
var _dirty := false
|
||||||
|
var _clear := true
|
||||||
|
var _show_texture := true
|
||||||
|
|
||||||
|
@onready var mask_clear: ColorRect = %MaskClear
|
||||||
|
@onready var mask_texture: TextureRect = %MaskTexture
|
||||||
|
|
||||||
|
|
||||||
func clear(color: Color) -> void:
|
func clear(color: Color) -> void:
|
||||||
queue_draw(func() -> void: draw_rect(Rect2(0, 0, size.x, size.y), color, true))
|
mask_clear.color = color
|
||||||
|
_clear = true
|
||||||
|
|
||||||
|
|
||||||
func queue_draw(op: Callable) -> void:
|
func queue_draw(op: Callable) -> void:
|
||||||
@ -28,3 +34,9 @@ func _process(_delta: float) -> void:
|
|||||||
queue_redraw()
|
queue_redraw()
|
||||||
_dirty = false
|
_dirty = false
|
||||||
painted.emit()
|
painted.emit()
|
||||||
|
|
||||||
|
# show clear rect for one frame
|
||||||
|
mask_clear.visible = _clear
|
||||||
|
_clear = false
|
||||||
|
mask_texture.visible = _show_texture
|
||||||
|
_show_texture = false
|
||||||
|
@ -13,6 +13,7 @@ const CLEAR_TOTAL_EPSILON := 1
|
|||||||
|
|
||||||
@export var mask_dim := 256
|
@export var mask_dim := 256
|
||||||
@export var mesh_instance: MeshInstance3D
|
@export var mesh_instance: MeshInstance3D
|
||||||
|
@export var initial_mask: Texture
|
||||||
|
|
||||||
var meshtool := MeshDataTool.new()
|
var meshtool := MeshDataTool.new()
|
||||||
|
|
||||||
@ -34,8 +35,7 @@ var _exit_thread := false
|
|||||||
|
|
||||||
@onready var mask_viewport: SubViewport = %MaskViewport
|
@onready var mask_viewport: SubViewport = %MaskViewport
|
||||||
@onready var mask_control: DrawController = %MaskControl
|
@onready var mask_control: DrawController = %MaskControl
|
||||||
|
@onready var mask_texture: TextureRect = %MaskTexture
|
||||||
@onready var debug_draw: DebugDraw = $DebugDraw
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
@ -51,6 +51,9 @@ func _ready() -> void:
|
|||||||
gunk_mat.set_shader_parameter("gunk_mask", mask_viewport.get_texture())
|
gunk_mat.set_shader_parameter("gunk_mask", mask_viewport.get_texture())
|
||||||
meshtool.create_from_surface(mesh_instance.mesh as ArrayMesh, 0)
|
meshtool.create_from_surface(mesh_instance.mesh as ArrayMesh, 0)
|
||||||
|
|
||||||
|
if initial_mask:
|
||||||
|
mask_texture.texture = initial_mask
|
||||||
|
|
||||||
_thread = Thread.new()
|
_thread = Thread.new()
|
||||||
_thread.start(_async_compute_clear_total)
|
_thread.start(_async_compute_clear_total)
|
||||||
|
|
||||||
@ -180,8 +183,6 @@ func paint_dot(point: Vector3, normal: Vector3, radius: float) -> void:
|
|||||||
|
|
||||||
## Paint a continuous line on the gunk mask if called on successive frames.
|
## Paint a continuous line on the gunk mask if called on successive frames.
|
||||||
func paint_continuous(point: Vector3, normal: Vector3, width: float) -> void:
|
func paint_continuous(point: Vector3, normal: Vector3, width: float) -> void:
|
||||||
debug_draw.draw_vector(normal, point)
|
|
||||||
|
|
||||||
var px := _get_px(point, normal)
|
var px := _get_px(point, normal)
|
||||||
if _polyline_buffer and px.distance_to(_polyline_buffer[0]) <= CONTINUITY_LIMIT:
|
if _polyline_buffer and px.distance_to(_polyline_buffer[0]) <= CONTINUITY_LIMIT:
|
||||||
_polyline_buffer.push_front(px)
|
_polyline_buffer.push_front(px)
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://c2omlx4ptrc01"]
|
[gd_scene load_steps=3 format=3 uid="uid://c2omlx4ptrc01"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://hbl5u20wlwr5" path="res://src/world/gunk_body/gunk_body.gd" id="1_qqbpr"]
|
[ext_resource type="Script" uid="uid://hbl5u20wlwr5" path="res://src/world/gunk_body/gunk_body.gd" id="1_qqbpr"]
|
||||||
[ext_resource type="Script" uid="uid://bom5qysgfvap1" path="res://src/world/gunk_body/draw_controller.gd" id="2_kkcjw"]
|
[ext_resource type="Script" uid="uid://bom5qysgfvap1" path="res://src/world/gunk_body/draw_controller.gd" id="2_kkcjw"]
|
||||||
[ext_resource type="Script" uid="uid://ba7480ara8eo" path="res://levels/sandbox/debug_draw.gd" id="3_m8wx4"]
|
|
||||||
|
|
||||||
[node name="GunkBody" type="StaticBody3D"]
|
[node name="GunkBody" type="StaticBody3D"]
|
||||||
script = ExtResource("1_qqbpr")
|
script = ExtResource("1_qqbpr")
|
||||||
@ -14,6 +13,23 @@ size = Vector2i(1024, 1024)
|
|||||||
render_target_clear_mode = 1
|
render_target_clear_mode = 1
|
||||||
render_target_update_mode = 4
|
render_target_update_mode = 4
|
||||||
|
|
||||||
|
[node name="MaskClear" type="ColorRect" parent="MaskViewport"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
|
[node name="MaskTexture" type="TextureRect" parent="MaskViewport"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
[node name="MaskControl" type="Control" parent="MaskViewport"]
|
[node name="MaskControl" type="Control" parent="MaskViewport"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
@ -24,11 +40,4 @@ grow_horizontal = 2
|
|||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("2_kkcjw")
|
script = ExtResource("2_kkcjw")
|
||||||
|
|
||||||
[node name="DebugDraw" type="Control" parent="."]
|
|
||||||
layout_mode = 3
|
|
||||||
anchors_preset = 0
|
|
||||||
offset_right = 40.0
|
|
||||||
offset_bottom = 40.0
|
|
||||||
script = ExtResource("3_m8wx4")
|
|
||||||
|
|
||||||
[connection signal="painted" from="MaskViewport/MaskControl" to="." method="_on_mask_painted"]
|
[connection signal="painted" from="MaskViewport/MaskControl" to="." method="_on_mask_painted"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user