Repository navigation
Stylized Shadows
#25564
Replies: 1 comment
|
There's no screen space shadow texture in bevy, shadows get sampled per fragment inside Based on the #import bevy_pbr::{
pbr_fragment::pbr_input_from_standard_material,
forward_io::{VertexOutput, FragmentOutput},
pbr_functions::{apply_pbr_lighting, main_pass_post_lighting_processing},
mesh_view_bindings as view_bindings,
shadows,
}
@fragment
fn fragment(in: VertexOutput, @builtin(front_facing) is_front: bool) -> FragmentOutput {
var pbr_input = pbr_input_from_standard_material(in, is_front);
// same as in apply_pbr_lighting, used to pick the cascade
let view_z = dot(vec4<f32>(
view_bindings::view.view_from_world[0].z,
view_bindings::view.view_from_world[1].z,
view_bindings::view.view_from_world[2].z,
view_bindings::view.view_from_world[3].z
), pbr_input.world_position);
// 0 = in shadow, 1 = lit
let shadow = shadows::fetch_directional_shadow(0u, pbr_input.world_position, pbr_input.world_normal, view_z, pbr_input.frag_coord.xy);
var out: FragmentOutput;
out.color = apply_pbr_lighting(pbr_input);
// 4x4 bayer dither on the shadow
var bayer = array<f32, 16>(0., 8., 2., 10., 12., 4., 14., 6., 3., 11., 1., 9., 15., 7., 13., 5.);
let p = vec2<u32>(pbr_input.frag_coord.xy) % 4u;
let threshold = (bayer[p.y * 4u + p.x] + 0.5) / 16.0;
let lit = select(0.4, 1.0, shadow > threshold);
out.color = vec4<f32>(out.color.rgb * lit, out.color.a);
out.color = main_pass_post_lighting_processing(pbr_input, out.color);
return out;
}Then put This is from the 0.19 source ( |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I have searched and chatted in an attempt to find an answer. How do I create stylized shadows in bevy? Specifically, I want to create a dithering effect on shadows. It seems there isnt something like a "Screen Space Shadow Texture" or something. I know how to create a dithering shader I just dont know how I can manipulate the shadows in bevy with one.
Any ideas?
Thank you!
All reactions