1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
use crate::*; pub struct FXAAEffect { gl: Gl, pub color: Vec3, pub density: f32, pub animation: f32, image_effect: ImageEffect } impl FXAAEffect { pub fn new(gl: &Gl) -> Result<Self, Error> { Ok(Self {gl: gl.clone(), color: vec3(0.8, 0.8, 0.8), density: 0.2, animation: 0.1, image_effect: ImageEffect::new(gl, include_str!("shaders/fxaa.frag"))?}) } pub fn apply(&self, color_texture: &Texture2D) -> Result<(), Error> { state::depth_write(&self.gl,false); state::depth_test(&self.gl, state::DepthTestType::None); state::blend(&self.gl, state::BlendType::None); self.image_effect.program().use_texture(color_texture, "colorMap")?; self.image_effect.program().add_uniform_vec2("resolution", &vec2(color_texture.width as f32, color_texture.height as f32))?; self.image_effect.apply(); Ok(()) } }