diff --git a/assets/voxygen/shaders/antialias/bilinear.glsl b/assets/voxygen/shaders/antialias/bilinear.glsl new file mode 100644 index 0000000000..ff2ae63e2e --- /dev/null +++ b/assets/voxygen/shaders/antialias/bilinear.glsl @@ -0,0 +1,8 @@ +vec4 aa_apply( + texture2D tex, sampler smplr, + texture2D depth_tex, sampler depth_smplr, + vec2 fragCoord, + vec2 resolution +) { + return texture(sampler2D(tex, smplr), fragCoord / resolution); +} diff --git a/assets/voxygen/shaders/antialias/none.glsl b/assets/voxygen/shaders/antialias/none.glsl index ff2ae63e2e..50c9f74fe2 100644 --- a/assets/voxygen/shaders/antialias/none.glsl +++ b/assets/voxygen/shaders/antialias/none.glsl @@ -4,5 +4,5 @@ vec4 aa_apply( vec2 fragCoord, vec2 resolution ) { - return texture(sampler2D(tex, smplr), fragCoord / resolution); + return texelFetch(sampler2D(tex, smplr), ivec2(fragCoord * textureSize(sampler2D(tex, smplr), 0).xy / resolution), 0); } diff --git a/voxygen/src/hud/settings_window/video.rs b/voxygen/src/hud/settings_window/video.rs index a53b73b597..208a646a07 100644 --- a/voxygen/src/hud/settings_window/video.rs +++ b/voxygen/src/hud/settings_window/video.rs @@ -879,6 +879,7 @@ impl<'a> Widget for Video<'a> { // interaction with greedy meshing, and may eventually be removed. let mode_list = [ AaMode::None, + AaMode::Bilinear, AaMode::Fxaa, /* AaMode::MsaaX4, AaMode::MsaaX8, @@ -887,7 +888,8 @@ impl<'a> Widget for Video<'a> { AaMode::Hqx, ]; let mode_label_list = [ - "No anti-aliasing", + "None", + "Bilinear", "FXAA", /* "MSAA x4", "MSAA x8", diff --git a/voxygen/src/render/mod.rs b/voxygen/src/render/mod.rs index ba8b699c21..4f336349a8 100644 --- a/voxygen/src/render/mod.rs +++ b/voxygen/src/render/mod.rs @@ -108,6 +108,15 @@ pub enum AaMode { /// Screen-space technique that uses a combination of FXAA and /// nearest-neighbour sample retargeting to produce crisp, clean upscaling. FxUpscale, + /// Bilinear filtering. + /// + /// Linear interpolation of the color buffer in each axis to determine the + /// pixel. + Bilinear, + /// Nearest-neighbour filtering. + /// + /// The colour of each pixel is determined by the colour of the spatially + /// closest texel in the color buffer. #[serde(other)] None, } @@ -115,7 +124,7 @@ pub enum AaMode { impl AaMode { pub fn samples(&self) -> u32 { match self { - AaMode::None | AaMode::Fxaa | AaMode::Hqx | AaMode::FxUpscale => 1, + AaMode::None | AaMode::Bilinear | AaMode::Fxaa | AaMode::Hqx | AaMode::FxUpscale => 1, AaMode::MsaaX4 => 4, AaMode::MsaaX8 => 8, AaMode::MsaaX16 => 16, diff --git a/voxygen/src/render/renderer/pipeline_creation.rs b/voxygen/src/render/renderer/pipeline_creation.rs index 82eb152d3a..dc0f176870 100644 --- a/voxygen/src/render/renderer/pipeline_creation.rs +++ b/voxygen/src/render/renderer/pipeline_creation.rs @@ -258,6 +258,7 @@ impl ShaderModules { let anti_alias = shaders .get(match pipeline_modes.aa { AaMode::None => "antialias.none", + AaMode::Bilinear => "antialias.bilinear", AaMode::Fxaa => "antialias.fxaa", AaMode::MsaaX4 => "antialias.msaa-x4", AaMode::MsaaX8 => "antialias.msaa-x8", diff --git a/voxygen/src/render/renderer/shaders.rs b/voxygen/src/render/renderer/shaders.rs index f2468fc0b0..83a27a22e4 100644 --- a/voxygen/src/render/renderer/shaders.rs +++ b/voxygen/src/render/renderer/shaders.rs @@ -38,6 +38,7 @@ impl assets::Compound for Shaders { "include.point_glow", "include.fxaa", "antialias.none", + "antialias.bilinear", "antialias.fxaa", "antialias.msaa-x4", "antialias.msaa-x8",