From 28779c43855f854afcee0c2c8e63248766974a4e Mon Sep 17 00:00:00 2001 From: Valentin Stark Date: Thu, 1 Sep 2022 14:43:01 +0200 Subject: [PATCH] nettoyage --- world/game.tscn | 19 ++++--- world/materials/outilne_1.tres | 21 -------- world/materials/outilne_2.tres | 57 -------------------- world/materials/{test.tres => outline.tres} | 0 world/materials/world2.material | Bin 297 -> 0 bytes 5 files changed, 12 insertions(+), 85 deletions(-) delete mode 100644 world/materials/outilne_1.tres delete mode 100644 world/materials/outilne_2.tres rename world/materials/{test.tres => outline.tres} (100%) delete mode 100644 world/materials/world2.material diff --git a/world/game.tscn b/world/game.tscn index 02770ef..f45efd5 100644 --- a/world/game.tscn +++ b/world/game.tscn @@ -1,7 +1,7 @@ -[gd_scene load_steps=13 format=2] +[gd_scene load_steps=14 format=2] [ext_resource path="res://ui/ui.tscn" type="PackedScene" id=1] -[ext_resource path="res://world/materials/world2.material" type="Material" id=2] +[ext_resource path="res://world/materials/outline.tres" type="Shader" id=2] [ext_resource path="res://world/World3d.gd" type="Script" id=4] [ext_resource path="res://utils/camera/CamBase.tscn" type="PackedScene" id=5] @@ -151,6 +151,14 @@ shader_param/noise2 = SubResource( 7 ) [sub_resource type="QuadMesh" id=8] size = Vector2( 2, 2 ) +[sub_resource type="ShaderMaterial" id=9] +shader = ExtResource( 2 ) +shader_param/outline_mode = 3 +shader_param/outline_intensity = 0.1 +shader_param/_round = true +shader_param/outline_bias = 0.0 +shader_param/outline_color = Color( 0, 0, 0, 1 ) + [node name="Game" type="Node"] [node name="UI" parent="." instance=ExtResource( 1 )] @@ -186,14 +194,11 @@ transform = Transform( 0.971628, 0.168947, -0.16552, 0, 0.699825, 0.714314, 0.23 light_energy = 0.1 shadow_enabled = true -[node name="Spatial" type="Spatial" parent="World3d"] - -[node name="MeshInstance" type="MeshInstance" parent="World3d/Spatial"] +[node name="Outline" type="MeshInstance" parent="World3d"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 6.29265, 7.41201, 29.3021 ) extra_cull_margin = 3653.19 mesh = SubResource( 8 ) -skeleton = NodePath("../..") -material/0 = ExtResource( 2 ) +material/0 = SubResource( 9 ) [connection signal="map_clicked" from="UI/Map" to="World3d/CamBase/Camera" method="_on_Map_map_clicked"] [connection signal="camera_moved" from="World3d/CamBase/Camera" to="UI/Map/Cursor" method="_on_Camera_camera_moved"] diff --git a/world/materials/outilne_1.tres b/world/materials/outilne_1.tres deleted file mode 100644 index 4c29fb3..0000000 --- a/world/materials/outilne_1.tres +++ /dev/null @@ -1,21 +0,0 @@ -[gd_resource type="Shader" format=2] - -[resource] -code = "// Edge-Detection Shader Pass 1 -// Here we simply pass the vertex normals to the albedo -// so we can access it through the SCREEN_TEXTURE in our Shader Pass 2 -// LICENSE: MIT - -shader_type spatial; -render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_toon,specular_disabled,shadows_disabled; - -varying vec3 world_normal; - -void vertex() { - world_normal = NORMAL; -} - -void fragment() { - ALBEDO = world_normal.rgb; -} -" diff --git a/world/materials/outilne_2.tres b/world/materials/outilne_2.tres deleted file mode 100644 index a0ae7ef..0000000 --- a/world/materials/outilne_2.tres +++ /dev/null @@ -1,57 +0,0 @@ -[gd_resource type="Shader" format=2] - -[resource] -code = "// Edge-Detection Shader Pass 2 -// Here's our fully lit and shaded model, -// but through the SCREEN_TEXTURE, we also have the world normals -// of all the visible parts of our model that the first pass gives us. -// LICENSE: MIT - -shader_type spatial; -render_mode blend_mix,depth_draw_alpha_prepass,cull_back,diffuse_lambert,specular_disabled; -uniform vec4 albedo : hint_color; -uniform sampler2D texture_albedo : hint_albedo; -uniform float specular; -uniform float metallic; -uniform float roughness : hint_range(0,1); -uniform float edge_strength : hint_range(0,1) = 0.2; -uniform vec4 edge_color : hint_color = vec4(0.5, 0.5, 0.5, 1.0); - -// essentially a cheap \"lightness\" function -// returns the average of red, green and blue color channels -float vec3_avg(vec3 color) { - return (color.r + color.g + color.b) / 3.0; -} - -// transform a pixel coordinate to screen UV -vec2 pixel_to_screen_uv(vec2 viewport_size, vec2 pixel) { - return vec2(pixel.x / viewport_size.x, pixel.y / viewport_size.y); -} - -void fragment() { - vec4 albedo_tex = texture(texture_albedo, UV); - - vec2 iuv = vec2(SCREEN_UV.x * VIEWPORT_SIZE.x, SCREEN_UV.y * VIEWPORT_SIZE.y); - - vec3 neighbour_left = texture(SCREEN_TEXTURE, pixel_to_screen_uv(VIEWPORT_SIZE, iuv + vec2(0, 0))).rgb; - vec3 neighbour_right = texture(SCREEN_TEXTURE, pixel_to_screen_uv(VIEWPORT_SIZE, iuv + vec2(0.5, 0))).rgb; - - vec3 neighbour_top = texture(SCREEN_TEXTURE, pixel_to_screen_uv(VIEWPORT_SIZE, iuv + vec2(0, 0.0))).rgb; - vec3 neighbour_bottom = texture(SCREEN_TEXTURE, pixel_to_screen_uv(VIEWPORT_SIZE, iuv + vec2(0, 0.5))).rgb; - - ALBEDO = albedo.rgb * texture(texture_albedo, UV).rgb; - - // compare normals: if they differ, we draw an edge - // by mixing in the edge_color, by edge_strength amount - // feel free to try other ways to mix, such as multiply for more textured objects. - if (abs(vec3_avg(neighbour_left) - vec3_avg(neighbour_right)) > 0.0) { - ALBEDO = mix(ALBEDO, edge_color.rgb, edge_strength); - }else if (abs(vec3_avg(neighbour_top) - vec3_avg(neighbour_bottom)) > 0.0) { - ALBEDO = mix(ALBEDO, edge_color.rgb, edge_strength); - } - - METALLIC = metallic; - ROUGHNESS = roughness; - SPECULAR = specular; -} -" diff --git a/world/materials/test.tres b/world/materials/outline.tres similarity index 100% rename from world/materials/test.tres rename to world/materials/outline.tres diff --git a/world/materials/world2.material b/world/materials/world2.material deleted file mode 100644 index 65cd81f89c95dbe03cf801efbeca6dc0efa9729f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 297 zcmV+^0oMLfQ$s@n000005C8yE0ssIJ0RR9fwJ-f(Qvp2)03r=4DR52F82snz{|Df} zj+sbu5V=!TSwe1&y=|WzZ^)PI^|FXa>?BDNV+t6Q3T5)~2nQc95djJLEB=B9MwVDm z=;caQZ;>{LVTl|FUFgIQ@H#7(M21Vms+I=R9?ayR?Y1q6kHIEgTWlXhjY{Pti1jyE zRXJ%puKfvn>`Gkeq&%iIe2r=gU%N#UZenUdmTt)h_40rC6=rJXt;)z_)JElJAovA7 zCLk~ZWRyhoNN^Jw2=F~GgdTs3;o@L{KI1MHkMV;WgDi-*u;L28ub@0&F5&iy