haze
This commit is contained in:
@@ -29,6 +29,9 @@ const R1: f32 = 256.0;
|
||||
const R2: f32 = 64.0;
|
||||
const R3: f32 = 128.0;
|
||||
|
||||
//const SKY_COLOR: [f32; 4] = [0.15, 0.15, 0.75, 1.0];
|
||||
const SKY_COLOR: [f32; 4] = [0.005, 0.005, 0.01, 1.0];
|
||||
|
||||
gfx_defines! {
|
||||
vertex Vertex {
|
||||
pos: [f32; 3] = "a_pos",
|
||||
@@ -41,6 +44,8 @@ gfx_defines! {
|
||||
r1: f32 = "R1",
|
||||
r2: f32 = "R2",
|
||||
r3: f32 = "R3",
|
||||
haze: f32 = "haze",
|
||||
hazecolor: [f32; 4] = "hazecolor",
|
||||
}
|
||||
|
||||
constant Locals {
|
||||
@@ -157,7 +162,9 @@ impl<D: gfx::Device, F: gfx::Factory<D::Resources>> WorldScene<D, F> {
|
||||
pipe::new())
|
||||
.expect("create pipeline"),
|
||||
camera: na::Matrix4::one(),
|
||||
constants: Constants { anim: ANIMDATA, r1: R1, r2: R2, r3: R3},
|
||||
constants: Constants { anim: ANIMDATA,
|
||||
r1: R1, r2: R2, r3: R3,
|
||||
haze: 1.0/2.0f32.sqrt(), hazecolor: SKY_COLOR },
|
||||
constants_buffer: factory.create_constant_buffer(1),
|
||||
constants_dirty: true,
|
||||
locals: factory.create_constant_buffer(1),
|
||||
@@ -258,6 +265,17 @@ impl<D: gfx::Device,
|
||||
self.constants = Constants { r1: R1 * 16.0, r2: R2 * 16.0, r3: R3 * 16.0, ..self.constants };
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
|
||||
Piston(Input::Press(Button::Keyboard(Key::H))) => {
|
||||
self.constants = Constants { haze: self.constants.haze * 2.0f32.sqrt().sqrt(), ..self.constants };
|
||||
println!("haze: {}", self.constants.haze);
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
Piston(Input::Press(Button::Keyboard(Key::N))) => {
|
||||
self.constants = Constants { haze: self.constants.haze / 2.0f32.sqrt().sqrt(), ..self.constants };
|
||||
println!("haze: {}", self.constants.haze);
|
||||
self.constants_dirty = true;
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
@@ -327,6 +345,8 @@ impl<D: gfx::Device,
|
||||
target: &gfx::handle::RenderTargetView<D::Resources, view::ColorFormat>,
|
||||
depth: &gfx::handle::DepthStencilView<D::Resources, view::DepthFormat>) {
|
||||
|
||||
encoder.clear(&target, SKY_COLOR);
|
||||
encoder.clear_depth(&depth, 1.0);
|
||||
let pipe = pipe::Data {
|
||||
vbuf: self.vbuf.clone(),
|
||||
trans: trans.clone(),
|
||||
|
||||
Reference in New Issue
Block a user