diff --git a/assets/voxygen/shaders/terrain-frag.glsl b/assets/voxygen/shaders/terrain-frag.glsl index 474f9ddca4..ccb60df2cd 100644 --- a/assets/voxygen/shaders/terrain-frag.glsl +++ b/assets/voxygen/shaders/terrain-frag.glsl @@ -167,6 +167,17 @@ void main() { // uint norm_index = (f_pos_norm >> 29) & 0x7u; // vec3 f_norm = normals[norm_index]; vec3 f_norm = normals[(f_pos_norm >> 29) & 0x7u]; + + #ifdef EXPERIMENTAL_BRICKLOREN + vec3 pos = f_pos - focus_off.xyz; + vec3 fp = pos * vec3(1.0, 1.0, 3.0); + fp.xy += floor(fp.z) * 0.5; + vec3 clamped = min(floor(fp.xyz) + vec3(0.92, 0.92, 0.8), max(floor(fp.xyz) + vec3(0.06, 0.06, 0.2), fp.xyz)); + f_norm.xyz += (fp.xyz - clamped) * 8.0 * sign(1.0 - f_norm) * max(1.0 - length(f_pos - cam_pos.xyz) / 64.0, 0); + f_norm = normalize(f_norm); + f_col /= 1.0 + length((fp - clamped) * sign(1.0 - f_norm)) * 2; + #endif + // vec3 du = dFdx(f_pos); // vec3 dv = dFdy(f_pos); // vec3 f_norm = normalize(cross(du, dv)); @@ -305,7 +316,11 @@ void main() { // vec3 surf_color = illuminate(srgb_to_linear(f_col), light, diffuse_light, ambient_light); vec3 f_chunk_pos = f_pos - (model_offs - focus_off.xyz); - float noise = hash(vec4(floor(f_chunk_pos * 3.0 - f_norm * 0.5), 0));//0.005/* - 0.01*/; + #ifdef EXPERIMENTAL_NONOISE + float noise = 0.0; + #else + float noise = hash(vec4(floor(f_chunk_pos * 3.0 - f_norm * 0.5), 0));//0.005/* - 0.01*/; + #endif //vec3 srgb_to_linear(vec3 srgb) { // bvec3 cutoff = lessThan(srgb, vec3(0.04045)); diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index d3d7275ce9..1deb42e272 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -69,6 +69,7 @@ fn main() { // `logging::init`. The issue is we need to read a setting to decide // whether we create a log file or not. let mut settings = Settings::load(&config_dir); + settings.display_warnings(); // Save settings to add new fields or create the file if it is not already there if let Err(err) = settings.save_to_file(&config_dir) { panic!("Failed to save settings: {:?}", err); diff --git a/voxygen/src/render/mod.rs b/voxygen/src/render/mod.rs index 594a114384..55f493edf8 100644 --- a/voxygen/src/render/mod.rs +++ b/voxygen/src/render/mod.rs @@ -54,6 +54,7 @@ pub use self::{ }, texture::Texture, }; +use hashbrown::HashSet; pub use wgpu::{AddressMode, FilterMode}; pub trait Vertex: Clone + bytemuck::Pod { @@ -341,6 +342,8 @@ pub struct RenderMode { pub shadow: ShadowMode, pub bloom: BloomMode, + pub experimental_shaders: HashSet, + pub upscale_mode: UpscaleMode, pub present_mode: PresentMode, pub profiler_enabled: bool, @@ -356,6 +359,7 @@ impl RenderMode { lighting: self.lighting, shadow: self.shadow, bloom: self.bloom, + experimental_shaders: self.experimental_shaders, }, OtherModes { upscale_mode: self.upscale_mode, @@ -376,6 +380,7 @@ pub struct PipelineModes { lighting: LightingMode, pub shadow: ShadowMode, bloom: BloomMode, + experimental_shaders: HashSet, } /// Other render modes that don't effect pipelines @@ -385,3 +390,11 @@ struct OtherModes { present_mode: PresentMode, profiler_enabled: bool, } + +#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum ExperimentalShader { + /// Add brick-like normal mapping to the world. + Brickloren, + /// Remove the default procedural noise from terrain. + NoNoise, +} diff --git a/voxygen/src/render/renderer/pipeline_creation.rs b/voxygen/src/render/renderer/pipeline_creation.rs index 6a1552108b..1760c516ed 100644 --- a/voxygen/src/render/renderer/pipeline_creation.rs +++ b/voxygen/src/render/renderer/pipeline_creation.rs @@ -143,7 +143,7 @@ impl ShaderModules { let shadows = shaders.get("include.shadows").unwrap(); // We dynamically add extra configuration settings to the constants file. - let constants = format!( + let mut constants = format!( r#" {} @@ -181,6 +181,13 @@ impl ShaderModules { }, ); + for shader in pipeline_modes.experimental_shaders.iter() { + constants += &format!( + "#define EXPERIMENTAL_{}\n", + format!("{:?}", shader).to_uppercase() + ); + } + let constants = match pipeline_modes.bloom { BloomMode::Off => constants, BloomMode::On(config) => { diff --git a/voxygen/src/settings/mod.rs b/voxygen/src/settings/mod.rs index 39010e4fdd..d8380c4fba 100644 --- a/voxygen/src/settings/mod.rs +++ b/voxygen/src/settings/mod.rs @@ -128,4 +128,14 @@ impl Settings { } fn get_path(config_dir: &Path) -> PathBuf { config_dir.join("settings.ron") } + + pub fn display_warnings(&self) { + if !self.graphics.render_mode.experimental_shaders.is_empty() { + warn!( + "One or more experimental shaders are enabled, all rendering guarantees are off. \ + Experimental shaders may be unmaintained, mutually-incompatible, entirely \ + broken, or may cause your GPU to explode. You have been warned!" + ); + } + } }