pub struct Glass { /* private fields */ }Implementations§
Source§impl Glass
impl Glass
pub const fn new() -> Self
pub const fn frosted(blur: f32) -> Self
pub const fn blur(self, radius: f32) -> Self
pub const fn tint(self, tint: Color) -> Self
pub const fn refraction(self, amount: f32) -> Self
pub const fn dispersion(self, amount: f32) -> Self
pub const fn highlight(self, amount: f32) -> Self
pub const fn edge_width(self, width: f32) -> Self
pub const fn shadow(self, amount: f32) -> Self
pub const fn saturation(self, amount: f32) -> Self
pub const fn light(self, at: Point, strength: f32, reach: f32) -> Self
Trait Implementations§
impl Copy for Glass
Source§impl ShaderEffect for Glass
impl ShaderEffect for Glass
const WGSL: &'static str = "const RIM_WIDTH: f32 = 1.5;\nconst SHADOW_REACH: f32 = 22.0;\nconst SHADOW_DROP: f32 = 6.0;\nconst CONTACT_REACH: f32 = 5.0;\nconst CONTACT_DROP: f32 = 1.5;\nconst LUMA: vec3<f32> = vec3<f32>(0.2126, 0.7152, 0.0722);\n\nfn effect(in: EffectInput) -> vec4<f32> {\n let tint = param(0);\n let optics = param(1);\n let finish = param(2);\n let pointer = param(3);\n let shadow_amount = finish.x;\n let texel = 1.0 / scale_factor();\n\n var shadow = 0.0;\n if (shadow_amount > 0.0) {\n let dropped = shape_sdf(in.local - vec2<f32>(0.0, SHADOW_DROP));\n let soft = clamp(1.0 - dropped / SHADOW_REACH, 0.0, 1.0);\n let grounded = shape_sdf(in.local - vec2<f32>(0.0, CONTACT_DROP));\n let contact = clamp(1.0 - grounded / CONTACT_REACH, 0.0, 1.0);\n shadow = shadow_amount * (0.75 * soft * soft * soft + 0.25 * contact * contact) * (1.0 - in.coverage);\n }\n if (in.coverage <= 0.0 && shadow <= 0.0) {\n discard;\n }\n\n let e = vec2<f32>(texel, 0.0);\n let gradient = vec2<f32>(\n shape_sdf(in.local + e.xy) - shape_sdf(in.local - e.xy),\n shape_sdf(in.local + e.yx) - shape_sdf(in.local - e.yx),\n );\n let normal = gradient / max(length(gradient), 1e-4 * texel);\n\n let edge = max(optics.w, texel);\n let depth = max(-in.distance, 0.0);\n let rim = clamp(1.0 - depth / edge, 0.0, 1.0);\n let bend = 1.0 - sqrt(1.0 - rim * rim);\n\n let offset = -normal * bend * optics.x * edge * 2.0;\n let spread = offset * optics.y;\n let r = sample_backdrop(in.local + offset + spread).r;\n let g = sample_backdrop(in.local + offset).g;\n let b = sample_backdrop(in.local + offset - spread).b;\n var color = vec3<f32>(r, g, b);\n\n color = mix(vec3<f32>(dot(color, LUMA)), color, finish.y);\n color = mix(color, tint.rgb, tint.a);\n\n let light = vec2<f32>(sin(pointer.z), -cos(pointer.z));\n let facing = dot(normal, light);\n let key = max(facing, 0.0);\n let fill = max(-facing, 0.0);\n let glint = 0.15 + 0.85 * key * key + pointer.w * fill * fill;\n let line = clamp(1.0 - depth / RIM_WIDTH, 0.0, 1.0);\n let bloom = rim * rim * rim;\n let sheen = line * glint + bloom * glint * 0.22 + bend * 0.12;\n\n let away = (in.local - finish.zw) / max(pointer.y, 1.0);\n let spot = exp(-dot(away, away)) * pointer.x;\n let caught = spot * (line * 0.8 + bloom * 0.3 + 0.05);\n\n color += vec3<f32>(sheen * optics.z + caught);\n\n let glass = clamp(color, vec3<f32>(0.0), vec3<f32>(1.0)) * in.coverage;\n return vec4<f32>(glass, in.coverage + shadow);\n}\n"
const INPUTS: Inputs = Inputs::BACKDROP
fn uniforms(&self, uniforms: &mut [f32; 16])
fn margin(&self) -> f32
fn backdrop_blur(&self) -> f32
fn backdrop_reach(&self) -> Option<f32>
const CLOCK: Option<usize> = None
fn content_blur(&self) -> f32
impl StructuralPartialEq for Glass
Auto Trait Implementations§
impl Forget for Glass
impl Freeze for Glass
impl Move for Glass
impl RefUnwindSafe for Glass
impl Send for Glass
impl Sync for Glass
impl Unpin for Glass
impl UnsafeUnpin for Glass
impl UnwindSafe for Glass
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more