tetted pawn
This commit is contained in:
1 parent
f38e811e14
commit
0bf78729a1
7 files changed
+101
-4
No files matched your search
Binary file not shown.
|
Before Width: | Height: | Size: 257 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 79 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
@@ -0,0 +1,56 @@
|
||||
import bevy_ui_render::ui_vertex_output::UiVertexOutput;
|
||||
|
||||
@group(1) @binding(1) var combined_texture: texture_2d<f32>;
|
||||
@group(1) @binding(2) var combined_sampler: sampler;
|
||||
|
||||
fn scene(uv: vec2<f32>) -> vec4<f32> {
|
||||
let tex_color = textureSample(combined_texture, combined_sampler, uv);
|
||||
let mask = tex_color.a;
|
||||
|
||||
// Alpha cutout по маске
|
||||
if mask < 0.1 {
|
||||
discard;
|
||||
}
|
||||
|
||||
// Распаковка нормали: [0, 1] -> [-1, 1]
|
||||
// Если тени выглядят вывернутыми — поменяйте знак у G-компонента.
|
||||
let normal = normalize(vec3<f32>(
|
||||
tex_color.r * 2.0 - 1.0,
|
||||
tex_color.g * 2.0 - 1.0,
|
||||
tex_color.b * 2.0 - 1.0,
|
||||
));
|
||||
|
||||
// Направленный свет: постоянный вектор к источнику
|
||||
let light_dir = normalize(vec3<f32>(-0.5, -1.0, 0.5));
|
||||
let ndotl = max(dot(normal, light_dir), 0.0);
|
||||
|
||||
// Ambient, чтобы затенённые участки не были чёрными
|
||||
let ambient = 0.25;
|
||||
let lighting = ambient + ndotl * 0.75;
|
||||
|
||||
// Базовый цвет поверхности — например, тот же зелёный, что был у вас.
|
||||
// (или можно взять из uniform-поля материала, если добавите)
|
||||
let base_color = vec3<f32>(0.08, 0.28, 0.4);
|
||||
|
||||
let final_color = base_color * lighting;
|
||||
|
||||
return vec4<f32>(final_color, 1.0);
|
||||
}
|
||||
|
||||
fn antialias(uv: vec2<f32>, delta: vec2<f32>) -> vec4<f32> {
|
||||
var color = vec4<f32>(0.0);
|
||||
|
||||
color += scene(uv + delta * vec2<f32>(-0.5, -0.5));
|
||||
color += scene(uv + delta * vec2<f32>( 0.5, -0.5));
|
||||
color += scene(uv + delta * vec2<f32>(-0.5, 0.5));
|
||||
color += scene(uv + delta * vec2<f32>( 0.5, 0.5));
|
||||
|
||||
return color * 0.25;
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fragment(in: UiVertexOutput) -> @location(0) vec4<f32> {
|
||||
let delta = fwidth(in.uv) * 0.5;
|
||||
|
||||
return antialias(in.uv, delta);
|
||||
}
|
||||
Reference in new issue
Block a user