Tweak fog params

This commit is contained in:
Lauri Räsänen 2023-11-10 20:42:02 +02:00
parent c4ca8b9a04
commit 31c86644a7
3 changed files with 15 additions and 8 deletions

View file

@ -7,7 +7,6 @@ const SHADOW_SAMPLES = 2;
const INV_SHADOW_SAMPLES = 1.0 / 25.0;
const FOG_MAX_STEPS = 30;
const FOG_STEP_SIZE = 5.0;
const FOG_SCALE = 0.01;
const FOG_DENSITY = 2.0;
const FOG_ALPHA = 1.0;
const FOG_BLEND_STEPS = 4;

View file

@ -46,11 +46,19 @@ var t_geometry_depth: texture_depth_2d;
var s_geometry_depth: sampler;
fn fog_noise(pos: vec3<f32>) -> f32 {
var p = pos * FOG_SCALE;
p.x += global_uniforms.time * 0.1;
p.y += global_uniforms.time * 0.2;
p.z += sin(global_uniforms.time * 0.1) * 0.2;
return fbm(p);
var p1 = pos * 0.01;
p1.x += global_uniforms.time * 0.2;
p1.y += global_uniforms.time * 0.2;
p1.z += sin(global_uniforms.time * 0.1) * 0.5;
let noise1 = fbm(p1);
var p2 = pos * 0.05;
p2.x += global_uniforms.time * 0.2;
p2.y += global_uniforms.time * 0.2;
p2.z += sin(global_uniforms.time * 0.1) * 0.5;
let noise2 = fbm(p2);
return 0.8 * noise1 + 0.2 * noise2;
}
fn ray_march(origin: vec3<f32>, direction: vec3<f32>, scene_depth: f32) -> f32 {

View file

@ -400,9 +400,9 @@ impl State {
});
let fog_instances = vec![Instance {
position: [0.0, 20.0, 0.0].into(),
position: [0.0, 30.0, 0.0].into(),
rotation: cgmath::Quaternion::one(),
scale: [1360.0, 20.0, 600.0].into(),
scale: [1360.0, 30.0, 600.0].into(),
}];
let fog_instance_data = fog_instances.iter().map(Instance::to_raw).collect::<Vec<_>>();
let fog_instance_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {