Revert some irrelevant stuff.

This commit is contained in:
Joshua Yanovski 2020-07-16 01:57:39 +02:00
parent 2e2ab3dc1e
commit add2cfae04
9 changed files with 39 additions and 37 deletions

View File

@ -126,7 +126,7 @@ float lights_at(vec3 wpos, vec3 wnorm, vec3 /*cam_to_frag*/view_dir, vec3 mu, ve
vec3 directed_light = vec3(0.0);
vec3 max_light = vec3(0.0);
const float LIGHT_AMBIANCE = 0.015625;
const float LIGHT_AMBIANCE = 0.0;//0.015625;
for (uint i = 0u; i < /*light_shadow_count.x*//*0u*/light_shadow_count.x/*32u*/; i ++) {
@ -184,8 +184,8 @@ float lights_at(vec3 wpos, vec3 wnorm, vec3 /*cam_to_frag*/view_dir, vec3 mu, ve
vec3 direct_light = PI * color * strength * square_factor * light_reflection_factor(/*direct_norm_dir*/wnorm, /*cam_to_frag*/view_dir, direct_light_dir, k_d, k_s, alpha, voxel_norm, voxel_lighting);
float computed_shadow = ShadowCalculationPoint(i, -difference, wnorm, wpos/*, light_distance*/);
// directed_light += is_direct ? max(computed_shadow, /*LIGHT_AMBIANCE*/0.0) * direct_light * square_factor : vec3(0.0);
// directed_light += is_direct ? mix(LIGHT_AMBIANCE, 1.0, computed_shadow) * direct_light * square_factor : vec3(0.0);
directed_light += (is_direct ? 1.0 : LIGHT_AMBIANCE) * max(computed_shadow, /*LIGHT_AMBIANCE*/0.0) * direct_light * square_factor;// : vec3(0.0);
directed_light += is_direct ? mix(LIGHT_AMBIANCE, 1.0, computed_shadow) * direct_light * square_factor : vec3(0.0);
// directed_light += (is_direct ? 1.0 : LIGHT_AMBIANCE) * max(computed_shadow, /*LIGHT_AMBIANCE*/0.0) * direct_light * square_factor;// : vec3(0.0);
// directed_light += mix(LIGHT_AMBIANCE, 1.0, computed_shadow) * direct_light * square_factor;
// ambient_light += is_direct ? vec3(0.0) : vec3(0.0); // direct_light * square_factor * LIGHT_AMBIANCE;
// ambient_light += is_direct ? direct_light * (1.0 - square_factor * LIGHT_AMBIANCE) : vec3(0.0);

View File

@ -138,7 +138,7 @@ float ShadowCalculationPoint(uint lightIndex, vec3 fragToLight, vec3 fragNorm, /
float ShadowCalculationDirected(in vec3 fragPos)//in vec4 /*light_pos[2]*/sun_pos, vec3 fragPos)
{
float bias = 0.001;//0.0005;//-0.0001;// 0.05 / (2.0 * view_distance.x);
float bias = 0.000;//0.0005;//-0.0001;// 0.05 / (2.0 * view_distance.x);
float diskRadius = 0.01;
const vec3 sampleOffsetDirections[20] = vec3[]
(

View File

@ -1,6 +1,6 @@
use super::{
super::{
ColLightFmt, ColLightInfo, Light, Pipeline, RenderError, Renderer, ShadowDepthStencilFmt,
ColLightFmt, ColLightInfo, Pipeline, RenderError, Renderer, ShadowDepthStencilFmt,
TerrainLocals, Texture,
},
figure, terrain, Globals,
@ -30,7 +30,7 @@ gfx_defines! {
locals: gfx::ConstantBuffer<TerrainLocals> = "u_locals",
globals: gfx::ConstantBuffer<Globals> = "u_globals",
lights: gfx::ConstantBuffer<Light> = "u_lights",
// lights: gfx::ConstantBuffer<Light> = "u_lights",
// shadows: gfx::ConstantBuffer<Shadow> = "u_shadows",
// map: gfx::TextureSampler<[f32; 4]> = "t_map",
@ -42,7 +42,7 @@ gfx_defines! {
light_shadows: gfx::ConstantBuffer<Locals> = "u_light_shadows",
tgt_depth_stencil: gfx::DepthTarget<ShadowDepthStencilFmt> = gfx::state::Depth {
fun: gfx::state::Comparison::LessEqual,
fun: gfx::state::Comparison::Less,
write: true,
},
// tgt_depth_stencil: gfx::DepthTarget<ShadowDepthStencilFmt> = gfx::preset::depth::LESS_EQUAL_WRITE,//,Stencil::new(Comparison::Always,0xff,(StencilOp::Keep,StencilOp::Keep,StencilOp::Keep))),
@ -67,7 +67,7 @@ gfx_defines! {
light_shadows: gfx::ConstantBuffer<Locals> = "u_light_shadows",
tgt_depth_stencil: gfx::DepthTarget<ShadowDepthStencilFmt> = gfx::state::Depth {
fun: gfx::state::Comparison::LessEqual,
fun: gfx::state::Comparison::Less,
write: true,
},
// tgt_depth_stencil: gfx::DepthTarget<ShadowDepthStencilFmt> = gfx::preset::depth::LESS_WRITE,//,Stencil::new(Comparison::Always,0xff,(StencilOp::Keep,StencilOp::Keep,StencilOp::Keep))),

View File

@ -1388,8 +1388,8 @@ impl Renderer {
globals: &Consts<Globals>,
terrain_locals: &Consts<terrain::Locals>,
locals: &Consts<shadow::Locals>,
lights: &Consts<Light>,
/* shadows: &Consts<Shadow>,
/* lights: &Consts<Light>,
* shadows: &Consts<Shadow>,
* map: &Texture<LodColorFmt>,
* horizon: &Texture<LodTextureFmt>, */
) {
@ -1419,7 +1419,7 @@ impl Renderer {
vbuf: model.vbuf.clone(),
locals: terrain_locals.buf.clone(),
globals: globals.buf.clone(),
lights: lights.buf.clone(),
// lights: lights.buf.clone(),
// shadows: shadows.buf.clone(),
// noise: (self.noise_tex.srv.clone(), self.noise_tex.sampler.clone()),
// map: (map.srv.clone(), map.sampler.clone()),
@ -1443,8 +1443,8 @@ impl Renderer {
globals: &Consts<Globals>,
terrain_locals: &Consts<terrain::Locals>,
locals: &Consts<shadow::Locals>,
lights: &Consts<Light>,
/* shadows: &Consts<Shadow>,
/* lights: &Consts<Light>,
* shadows: &Consts<Shadow>,
* map: &Texture<LodColorFmt>,
* horizon: &Texture<LodTextureFmt>, */
) {
@ -1474,7 +1474,7 @@ impl Renderer {
vbuf: model.vbuf.clone(),
locals: terrain_locals.buf.clone(),
globals: globals.buf.clone(),
lights: lights.buf.clone(),
// lights: lights.buf.clone(),
// shadows: shadows.buf.clone(),
// noise: (self.noise_tex.srv.clone(), self.noise_tex.sampler.clone()),
// map: (map.srv.clone(), map.sampler.clone()),
@ -2089,8 +2089,9 @@ fn create_pipelines(
)
.unwrap(),
&include_ctx,
gfx::state::CullFace::Front,
Some(gfx::state::Offset(2, /* 10 */ 0)),
gfx::state::CullFace::Back,
None,
// Some(gfx::state::Offset(2, /* 10 */ 0)),
) {
Ok(pipe) => Some(pipe),
Err(err) => {

View File

@ -438,8 +438,8 @@ impl FigureMgr {
// Are shadows enabled at all?
let can_shadow_sun = renderer.render_mode().shadow.is_map() && is_daylight;
let Dependents {
proj_mat,
view_mat,
proj_mat: _,
view_mat: _,
cam_pos,
} = camera.dependents();
let cam_pos = math::Vec3::from(cam_pos);

View File

@ -1,9 +1,9 @@
use core::{iter, mem};
use hashbrown::HashMap;
use num::traits::Float;
// pub use vek::{geom::repr_simd::*, mat::repr_simd::column_major::Mat4, ops::*,
// vec::repr_simd::*};
pub use vek::{geom::repr_c::*, mat::repr_c::column_major::Mat4, ops::*, vec::repr_c::*};
pub use vek::{geom::repr_simd::*, mat::repr_simd::column_major::Mat4, ops::*, vec::repr_simd::*};
// pub use vek::{geom::repr_c::*, mat::repr_c::column_major::Mat4, ops::*,
// vec::repr_c::*};
pub fn aabb_to_points<T: Float>(bounds: Aabb<T>) -> [Vec3<T>; 8] {
[

View File

@ -569,7 +569,7 @@ impl Scene {
// Maintain the terrain.
let (
/* _scene_bounds, visible_bounds, _psc_bounds */ visible_bounds,
/* _scene_bounds, visible_bounds, _psc_bounds */ _visible_bounds,
visible_light_volume,
visible_psr_bounds,
) = self.terrain.maintain(
@ -775,8 +775,8 @@ impl Scene {
.scaled_3d(Vec3::new(proj_mat[(0, 0)], proj_mat[(1, 1)], 1.0));
let focus_off = focus_pos.map(|e| e.trunc()); */
let z_n = 1.0; //f64::from(camera::NEAR_PLANE);
let z_f = f64::from(camera::FAR_PLANE);
let scalar_fov = /*f64::from(fov / 2.0)*/compute_scalar_fov(z_n, f64::from(fov), f64::from(aspect_ratio));
let _z_f = f64::from(camera::FAR_PLANE);
let _scalar_fov = /*f64::from(fov / 2.0)*/compute_scalar_fov(z_n, f64::from(fov), f64::from(aspect_ratio));
shadow_mats.extend(directed_shadow_mats.iter().enumerate().map(move |(idx, &light_view_mat)| {
if idx >= NUM_DIRECTED_LIGHTS {
return ShadowLocals::new(Mat4::identity(), Mat4::identity());
@ -911,7 +911,8 @@ impl Scene {
let cos_gamma = new_dir.map(f64::from).dot(directed_light_dir.map(f64::from));
let sin_gamma = (1.0 - cos_gamma * cos_gamma).sqrt();
let gamma = sin_gamma.asin()/*cos_gamma.acos()*/;
let bounds1 = math::fit_psr(view_mat, visible_light_volume.iter().copied(), math::Vec4::homogenized);
let view_mat = math::Mat4::from_col_array(view_mat.into_col_array());
let bounds1 = math::fit_psr(view_mat.map_cols(math::Vec4::from), visible_light_volume.iter().copied(), math::Vec4::homogenized);
let n_e = f64::from(-bounds1.max.z);
// let f_e = f64::from(-bounds1.min.z);
// let fov = 2.0 * aspect_ratio * (fov / 2.0).tan();
@ -988,7 +989,7 @@ impl Scene {
0.0, 0.0, 0.0, 1.0,
);
let w_p_arr = solve_p0.cols.iter().map(|e| (e.x, e.y, e.z, e.w)).collect::<Vec<_>>();
// let _w_p_arr = solve_p0.cols.iter().map(|e| (e.x, e.y, e.z, e.w)).collect::<Vec<_>>();
// println!("mat4 solve_p0 = mat4(vec4{:?}, vec4{:?}, vec4{:?}, vec4{:?});", w_p_arr[0], w_p_arr[1], w_p_arr[2], w_p_arr[3]);
let p0_world = solve_p0.inverted() * math::Vec4::unit_w();
@ -1286,7 +1287,7 @@ impl Scene {
0.0, 0.0, 1.0, 0.0,
0.0, 1.0, 0.0, 0.0,
); */
let _w_p_arr = w_p.cols.iter().map(|e| (e.x, e.y, e.z, e.w)).collect::<Vec<_>>();
// let _w_p_arr = w_p.cols.iter().map(|e| (e.x, e.y, e.z, e.w)).collect::<Vec<_>>();
// println!("mat4 w_p = mat4(vec4{:?}, vec4{:?}, vec4{:?}, vec4{:?});", w_p_arr[0], w_p_arr[1], w_p_arr[2], w_p_arr[3]);
// let w_p: Mat4<f32> = Mat4::identity();
// let zmin = p1.z.min(p4.z);
@ -1312,7 +1313,7 @@ impl Scene {
far: zmax,//directed_far,
}); */
let shadow_all_mat: math::Mat4<f32> = /*(w_v * l_r).inverted() * */w_p * shadow_view_mat/*w_v * light_all_mat*/;
let _w_p_arr = shadow_all_mat.cols.iter().map(|e| (e.x, e.y, e.z, e.w)).collect::<Vec<_>>();
// let _w_p_arr = shadow_all_mat.cols.iter().map(|e| (e.x, e.y, e.z, e.w)).collect::<Vec<_>>();
// println!("mat4 shadow_all_mat = mat4(vec4{:?}, vec4{:?}, vec4{:?}, vec4{:?});", w_p_arr[0], w_p_arr[1], w_p_arr[2], w_p_arr[3]);
let math::Aabb::<f32> { min: math::Vec3 { x: xmin, y: ymin, z: zmin }, max: math::Vec3 { x: xmax, y: ymax, z: zmax } } =
math::fit_psr(/*light_all_mat*/shadow_all_mat/*shadow_view_mat*//* * inverse_visible*/, visible_light_volume.iter().copied(), /*|p| math::Vec3::from(p) / p.w*/math::Vec4::homogenized);
@ -1349,11 +1350,11 @@ impl Scene {
}/*.scaled_3d(Vec3::new(1.0, 1.0, -1.0))*//* * w_p * w_v*//* * l_r*/;//Mat4::identity();
// println!("proj_mat: {:?}", directed_proj_mat);
// println!("all_mat: {:?}", directed_proj_mat * view_mat);
let _w_p_arr = directed_proj_mat.cols.iter().map(|e| (e.x, e.y, e.z, e.w)).collect::<Vec<_>>();
// let _w_p_arr = directed_proj_mat.cols.iter().map(|e| (e.x, e.y, e.z, e.w)).collect::<Vec<_>>();
// println!("mat4 directed_proj_mat = mat4(vec4{:?}, vec4{:?}, vec4{:?}, vec4{:?});", w_p_arr[0], w_p_arr[1], w_p_arr[2], w_p_arr[3]);
let shadow_all_mat: Mat4<f32> = Mat4::from_col_arrays(shadow_all_mat.into_col_arrays());
let _w_p_arr = (directed_proj_mat * shadow_all_mat).cols.iter().map(|e| (e.x, e.y, e.z, e.w)).collect::<Vec<_>>();
// let _w_p_arr = (directed_proj_mat * shadow_all_mat).cols.iter().map(|e| (e.x, e.y, e.z, e.w)).collect::<Vec<_>>();
// println!("mat4 final_mat = mat4(vec4{:?}, vec4{:?}, vec4{:?}, vec4{:?});", w_p_arr[0], w_p_arr[1], w_p_arr[2], w_p_arr[3]);
let directed_texture_proj_mat = texture_mat * directed_proj_mat;
@ -1441,7 +1442,7 @@ impl Scene {
self.terrain.render_shadows(
renderer,
&self.globals,
&self.lights,
// &self.lights,
&self.shadow_mats,
&self.light_data,
is_daylight,

View File

@ -2788,7 +2788,7 @@ impl<V: RectRasterableVol> Terrain<V> {
// Update chunk visibility
let chunk_sz = V::RECT_SIZE.x as f32;
let scene_bounding_box: Aabb<f32> = Aabb {
let _scene_bounding_box: Aabb<f32> = Aabb {
min: focus_pos - 2.0, /*
* - /0.5f32 */
max: focus_pos + 2.0, /* + 0.5f32 */
@ -2862,7 +2862,7 @@ impl<V: RectRasterableVol> Terrain<V> {
});
// PSCs: Potential shadow casters
let psc_bounding_box: Aabb<f32> = visible_bounding_box;
let _psc_bounding_box: Aabb<f32> = visible_bounding_box;
/*Aabb {
min: focus_pos - 0.5f32,
max: focus_pos + 0.5f32,
@ -3083,7 +3083,7 @@ impl<V: RectRasterableVol> Terrain<V> {
&self,
renderer: &mut Renderer,
globals: &Consts<Globals>,
lights: &Consts<Light>,
// lights: &Consts<Light>,
shadow_mats: &Consts<ShadowLocals>,
light_data: &[Light],
is_daylight: bool,
@ -3124,7 +3124,7 @@ impl<V: RectRasterableVol> Terrain<V> {
globals,
&chunk.locals,
shadow_mats,
lights,
/* lights, */
/* shadows,
* &lod.map,
* &lod.horizon, */
@ -3146,7 +3146,7 @@ impl<V: RectRasterableVol> Terrain<V> {
globals,
&chunk.locals,
shadow_mats,
lights,
/* lights, */
/* shadows,
* &lod.map,
* &lod.horizon, */

View File

@ -39,7 +39,7 @@ fn main() {
// world_file: sim::FileOpts::Save,
..WorldOpts::default()
});
log::info!("Sampling data...");
tracing::info!("Sampling data...");
let sampler = world.sim();
let samples_data = {