From 424edaf5818758b24b253771fcf0b302819d8b64 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Mon, 5 May 2025 23:12:09 -0500 Subject: [PATCH] Dummy NPC texture --- scenes/Entities/Rosa.tscn | 6 +++-- scenes/Entities/TestNPC.tscn | 4 +++- scripts/Entities/OverworldEntity.gd | 4 ++-- shaders/NPC Shader.gdshader | 12 +++++++--- textures/human.png | Bin 0 -> 412 bytes textures/human.png.import | 35 ++++++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 textures/human.png create mode 100644 textures/human.png.import diff --git a/scenes/Entities/Rosa.tscn b/scenes/Entities/Rosa.tscn index e625d0c..8dd2daa 100644 --- a/scenes/Entities/Rosa.tscn +++ b/scenes/Entities/Rosa.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=7 format=3 uid="uid://yhtpoum3eek7"] +[gd_scene load_steps=8 format=3 uid="uid://yhtpoum3eek7"] [ext_resource type="Script" uid="uid://ixwikdguyhf0" path="res://scripts/Entities/RosaController.gd" id="1_3g383"] [ext_resource type="Script" uid="uid://jd50n00bo05y" path="res://scripts/Entities/RosaCamera.gd" id="2_tr66j"] [ext_resource type="Shader" uid="uid://7h2axb2tsh17" path="res://shaders/NPC Shader.gdshader" id="3_j5vis"] +[ext_resource type="Texture2D" uid="uid://cofrgefp8e617" path="res://textures/human.png" id="4_rvn3n"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_ls7r8"] radius = 0.331611 @@ -13,7 +14,8 @@ height = 0.804274 [sub_resource type="ShaderMaterial" id="ShaderMaterial_fegux"] render_priority = 0 shader = ExtResource("3_j5vis") -shader_parameter/color = Color(0.931725, 0.000206962, 0.803019, 1) +shader_parameter/npcTexture = ExtResource("4_rvn3n") +shader_parameter/color = Color(1, 1, 1, 1) shader_parameter/frame = 0 shader_parameter/direction = 1 diff --git a/scenes/Entities/TestNPC.tscn b/scenes/Entities/TestNPC.tscn index 8904785..be3adb8 100644 --- a/scenes/Entities/TestNPC.tscn +++ b/scenes/Entities/TestNPC.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=7 format=3 uid="uid://dr4b2pmsknuhc"] +[gd_scene load_steps=8 format=3 uid="uid://dr4b2pmsknuhc"] [ext_resource type="Script" uid="uid://d23qg1ovkbxst" path="res://scripts/Entities/BasicNPCEntity.gd" id="1_1muh7"] [ext_resource type="Shader" uid="uid://7h2axb2tsh17" path="res://shaders/NPC Shader.gdshader" id="1_xgcv1"] [ext_resource type="Script" uid="uid://btxgv85qst1jy" path="res://scripts/Cutscene/TestCutscene.gd" id="2_jwvuu"] +[ext_resource type="Texture2D" uid="uid://cofrgefp8e617" path="res://textures/human.png" id="4_vo0ku"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_dw1sy"] radius = 0.331611 @@ -13,6 +14,7 @@ height = 0.804274 [sub_resource type="ShaderMaterial" id="ShaderMaterial_l4utx"] render_priority = 0 shader = ExtResource("1_xgcv1") +shader_parameter/npcTexture = ExtResource("4_vo0ku") shader_parameter/color = Color(0, 0.563816, 0, 1) shader_parameter/frame = 0 shader_parameter/direction = 1 diff --git a/scripts/Entities/OverworldEntity.gd b/scripts/Entities/OverworldEntity.gd index b2a30cc..ba8463b 100644 --- a/scripts/Entities/OverworldEntity.gd +++ b/scripts/Entities/OverworldEntity.gd @@ -1,10 +1,10 @@ class_name OverworldEntity extends CharacterBody3D enum Direction { - NORTH, - EAST, SOUTH, WEST, + NORTH, + EAST, } var speed:float = 150; diff --git a/shaders/NPC Shader.gdshader b/shaders/NPC Shader.gdshader index 1998bb3..208cbff 100644 --- a/shaders/NPC Shader.gdshader +++ b/shaders/NPC Shader.gdshader @@ -6,12 +6,15 @@ uniform vec4 color : source_color; uniform int frame; uniform int direction; -const int FRAMES = 3; +const int FRAMES = 1; const int DIRECTIONS = 4; void vertex() { - vec2 tileSize = vec2(1.0 / float(FRAMES), 1.0 / float(DIRECTIONS)); - vec2 topLeft = tileSize * vec2(float(frame % FRAMES), float(direction % DIRECTIONS)); + vec2 tileSize = vec2(1.0 / float(DIRECTIONS), 1.0 / float(FRAMES)); + vec2 topLeft = tileSize * vec2( + float(direction % DIRECTIONS), + float(frame % FRAMES) + ); vec2 bottomRight = topLeft + tileSize; if(VERTEX_ID == 3) { @@ -27,6 +30,9 @@ void vertex() { void fragment() { vec4 npcColor = texture(npcTexture, UV); + + if(npcColor.a == 0.0) + discard; // Remove PINK background if(npcColor.r == 1.0 && npcColor.g == 0.0 && npcColor.b == 1.0) diff --git a/textures/human.png b/textures/human.png new file mode 100644 index 0000000000000000000000000000000000000000..fd253547b223e498c069b9d5432fea4701862dbd GIT binary patch literal 412 zcmV;N0b~A&P)Px$R!KxbRCt{2o7)n@AP7Vu)Bpcv`;s^{;}u2Hu>07w9<&?c1YsIiXk2H(nBW`n zd%ql^A=LTI$&jlS1AHZZPk^BXZ3HvB2oDD~N6ITo6=Ai&}Br`PTDSo@ep$M};cT?mxhbO6z(V1A74HVlqg75q`Q5 zd^4Vq6KOMb7~ZWP!9Ia zKhn?hZfUt_`887Ph?zMT zKhYs0>d48(0e+d^)fy%V8&yz|i<>YOhL@Kx>6-uYju;xa^v