Update lighting and shaders
This commit is contained in:
parent
fbabe444c7
commit
37c146570d
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
[ext_resource type="PackedScene" uid="uid://b2gh50nogfllj" path="res://game/player/camera/camera_holder.tscn" id="1_obar5"]
|
||||
[ext_resource type="Script" uid="uid://br1dfd4fltlef" path="res://game/player/player_character.gd" id="1_pj0hh"]
|
||||
[ext_resource type="Material" uid="uid://oh4kyswey7gr" path="res://game/player/shader/BOTW_Toon_material.tres" id="2_1g6dm"]
|
||||
[ext_resource type="Script" uid="uid://c8vfvcjtsb220" path="res://game/player/input/input_management_component.gd" id="2_r5dqo"]
|
||||
[ext_resource type="Script" uid="uid://dy4wrpvpep1jq" path="res://game/player/states/state_machine.gd" id="3_o4naa"]
|
||||
[ext_resource type="Script" uid="uid://bf6hjwfa74ttj" path="res://game/player/states/idle_state.gd" id="4_38lxl"]
|
||||
|
|
@ -55,10 +56,12 @@ unique_name_in_owner = true
|
|||
|
||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="VisualRoot" unique_id=670759105]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.4555889, 0.5468005)
|
||||
material_override = ExtResource("2_1g6dm")
|
||||
mesh = SubResource("BoxMesh_3agn1")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="VisualRoot" unique_id=1202850119]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
material_override = ExtResource("2_1g6dm")
|
||||
mesh = SubResource("CapsuleMesh_3agn1")
|
||||
|
||||
[node name="CameraHolder" parent="." unique_id=232451612 instance=ExtResource("1_obar5")]
|
||||
|
|
|
|||
25
game/player/shader/BOTW_Toon_material.tres
Normal file
25
game/player/shader/BOTW_Toon_material.tres
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
[gd_resource type="ShaderMaterial" format=3 uid="uid://oh4kyswey7gr"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://ivbvy4l1fihd" path="res://game/player/shader/botw_toon.gdshader" id="1_o0gt5"]
|
||||
|
||||
[resource]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_o0gt5")
|
||||
shader_parameter/tint = Color(0.74138474, 0.7413847, 0.74138457, 1)
|
||||
shader_parameter/metallic = 0.0
|
||||
shader_parameter/shadow_size = 0.3
|
||||
shader_parameter/shadow_blend = 0.02
|
||||
shader_parameter/shadow_extra_intensity = 0.15
|
||||
shader_parameter/shadow_color = Color(0.3491902, 0.3491902, 0.48452926, 1)
|
||||
shader_parameter/light_tint = Color(0.9063318, 0.9063318, 0.9063318, 1)
|
||||
shader_parameter/rimlight_size = 0.8
|
||||
shader_parameter/rimlight_blend = 0.02
|
||||
shader_parameter/rimlight_color = Color(0.6651851, 0.6651851, 0.6651851, 1)
|
||||
shader_parameter/use_normalmap = false
|
||||
shader_parameter/animated = false
|
||||
shader_parameter/time_scale = 0.02
|
||||
shader_parameter/normal_bias = Vector3(0, 0, 0)
|
||||
shader_parameter/light_bias = Vector3(0, 0, 0)
|
||||
shader_parameter/use_view = true
|
||||
shader_parameter/view_bias = Color(1, 0, 1, 1)
|
||||
shader_parameter/view_multiplier = -1.0
|
||||
77
game/player/shader/botw_toon.gdshader
Normal file
77
game/player/shader/botw_toon.gdshader
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
// BoTW Toon Shader by NekotoArts
|
||||
// Migré vers Godot 4.7
|
||||
shader_type spatial;
|
||||
render_mode diffuse_toon, specular_toon;
|
||||
|
||||
uniform vec4 tint : source_color = vec4(1.0);
|
||||
uniform sampler2D albedo_texture : source_color;
|
||||
uniform float metallic : hint_range(0.0, 1.0) = 0.0;
|
||||
uniform sampler2D normal_map : source_color;
|
||||
uniform float shadow_size = 0.045;
|
||||
uniform float shadow_blend = 0.001;
|
||||
uniform float shadow_extra_intensity = 0.0;
|
||||
uniform vec4 shadow_color : source_color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
uniform vec4 light_tint : source_color = vec4(1.0);
|
||||
uniform float rimlight_size = 0.921;
|
||||
uniform float rimlight_blend = 0.01;
|
||||
uniform vec4 rimlight_color : source_color = vec4(1.0);
|
||||
uniform bool use_normalmap = true;
|
||||
uniform bool animated = true;
|
||||
uniform float time_scale = 0.02;
|
||||
uniform vec3 normal_bias = vec3(0.0);
|
||||
uniform vec3 light_bias = vec3(0.0);
|
||||
uniform bool use_view = true;
|
||||
uniform vec4 view_bias : source_color = vec4(1.0, 0.0, 1.0, 1.0);
|
||||
uniform float view_multiplier : hint_range(-1.0, 1.0) = -1.0;
|
||||
|
||||
float fresnel(float amount, vec3 normal, vec3 view)
|
||||
{
|
||||
return pow((1.0 - clamp(dot(normalize(normal), normalize(view)), 0.0, 1.0)), amount);
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
// VERTEX 和 NORMAL 是 Godot 4 的顶点内置变量
|
||||
// TANGENT 在 Godot 4 中仍需从 TANGENT 读取,但已不再推荐存储
|
||||
// 如需传递法线,直接用 NORMAL 即可,Godot 会自动处理
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
ALBEDO = texture(albedo_texture, UV).rgb * tint.rgb;
|
||||
METALLIC = metallic;
|
||||
}
|
||||
|
||||
void light() {
|
||||
vec3 normal;
|
||||
if (use_normalmap) {
|
||||
vec3 normal_from_texture;
|
||||
if (animated) {
|
||||
normal_from_texture = texture(normal_map, UV + TIME * time_scale).rgb;
|
||||
} else {
|
||||
normal_from_texture = texture(normal_map, UV).rgb;
|
||||
}
|
||||
// Godot 4 中法线贴图的解码通常用 texture().rgb * 2.0 - 1.0
|
||||
// 但原代码直接做减法,这里保持原逻辑但修正分量使用
|
||||
normal = NORMAL - (normal_from_texture * 2.0 - 1.0);
|
||||
} else {
|
||||
normal = NORMAL;
|
||||
}
|
||||
|
||||
if (use_view) {
|
||||
normal -= VIEW * view_bias.rgb * view_multiplier;
|
||||
}
|
||||
|
||||
float NdotL = dot(normal + normal_bias, LIGHT + light_bias);
|
||||
|
||||
float rounded = smoothstep(shadow_size, shadow_blend + shadow_size, NdotL);
|
||||
float one_minus = 1.0 - rounded;
|
||||
vec3 mult1 = LIGHT_COLOR * rounded * light_tint.rgb * ATTENUATION;
|
||||
vec3 mult2 = (one_minus * 1.4 * shadow_color.rgb) - shadow_extra_intensity;
|
||||
vec3 add1 = mult1 + mult2;
|
||||
|
||||
float add3 = rimlight_blend + rimlight_size;
|
||||
float basic_fresnel = fresnel(1.0, NORMAL, VIEW);
|
||||
float smoothed = smoothstep(rimlight_size, add3, basic_fresnel);
|
||||
|
||||
vec3 add2 = add1 + smoothed * rimlight_color.rgb;
|
||||
DIFFUSE_LIGHT += ALBEDO * add2;
|
||||
}
|
||||
1
game/player/shader/botw_toon.gdshader.uid
Normal file
1
game/player/shader/botw_toon.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ivbvy4l1fihd
|
||||
|
|
@ -15,16 +15,15 @@
|
|||
[ext_resource type="Script" uid="uid://bx0htbw7ygkww" path="res://game/battle/battle_launcher.gd" id="10_rr16o"]
|
||||
[ext_resource type="Resource" uid="uid://caim7okcsrjq4" path="res://data/pokeapi/pokemon/0025_pikachu.tres" id="10_ysylv"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_tipki"]
|
||||
sky_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
|
||||
ground_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
|
||||
|
||||
[sub_resource type="Sky" id="Sky_85g3d"]
|
||||
sky_material = SubResource("ProceduralSkyMaterial_tipki")
|
||||
|
||||
[sub_resource type="Environment" id="Environment_choun"]
|
||||
background_mode = 2
|
||||
sky = SubResource("Sky_85g3d")
|
||||
background_mode = 1
|
||||
background_color = Color(0.6262097, 0.7014107, 0.7977378, 1)
|
||||
ambient_light_source = 2
|
||||
ambient_light_color = Color(0.3491902, 0.38109186, 0.42358288, 1)
|
||||
ambient_light_energy = 0.3
|
||||
tonemap_mode = 2
|
||||
tonemap_exposure = 0.8
|
||||
tonemap_white = 6.0
|
||||
sdfgi_enabled = true
|
||||
glow_enabled = true
|
||||
fog_enabled = true
|
||||
|
|
@ -65,7 +64,9 @@ metadata/_custom_type_script = "uid://u2t6dm1ee3se"
|
|||
[node name="world" type="Node3D" unique_id=832308324]
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=455638012]
|
||||
transform = Transform3D(-0.8660254, -0.43301278, 0.25, 0, 0.49999997, 0.86602545, -0.50000006, 0.75, -0.43301266, 0, 0, 0)
|
||||
transform = Transform3D(0.70710677, 0.35355338, -0.6123724, 0, 0.8660254, 0.5, 0.70710677, -0.35355338, 0.6123724, 0, 0, 0)
|
||||
light_energy = 0.8
|
||||
light_indirect_energy = 0.0
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1810349008]
|
||||
|
|
|
|||
Loading…
Reference in a new issue