mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added support for experimental shaders
This commit is contained in:
parent
9b85a01df6
commit
cd428d9267
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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<ExperimentalShader>,
|
||||
|
||||
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<ExperimentalShader>,
|
||||
}
|
||||
|
||||
/// 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,
|
||||
}
|
||||
|
@ -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) => {
|
||||
|
@ -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!"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user