mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
More frustration with shadows.
This commit is contained in:
parent
ffa8f29732
commit
e974ebfebd
@ -24,6 +24,7 @@ layout(std140, set = 0, binding = 0) uniform u_globals {
|
|||||||
// 1 - ThirdPerson
|
// 1 - ThirdPerson
|
||||||
uint cam_mode;
|
uint cam_mode;
|
||||||
float sprite_render_distance;
|
float sprite_render_distance;
|
||||||
|
float gloabls_dummy; // Fix alignment.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Specifies the pattern used in the player dithering
|
// Specifies the pattern used in the player dithering
|
||||||
|
@ -44,7 +44,7 @@ float VectorToDepth (vec3 Vec)
|
|||||||
// float NormZComp = 1.0 - shadow_proj_factors.y / shadow_proj_factors.x / LocalZcomp;
|
// float NormZComp = 1.0 - shadow_proj_factors.y / shadow_proj_factors.x / LocalZcomp;
|
||||||
// -(1 + 2n/(f-n)) - 2(1 + n/(f-n)) * n/z
|
// -(1 + 2n/(f-n)) - 2(1 + n/(f-n)) * n/z
|
||||||
// -(1 + n/(f-n)) - (1 + n/(f-n)) * n/z
|
// -(1 + n/(f-n)) - (1 + n/(f-n)) * n/z
|
||||||
// f/(f-n) - f
|
// f/(f-n) - fn/(f-n)/z
|
||||||
float NormZComp = shadow_proj_factors.x - shadow_proj_factors.y / LocalZcomp;
|
float NormZComp = shadow_proj_factors.x - shadow_proj_factors.y / LocalZcomp;
|
||||||
// NormZComp = -1000.0 / (NormZComp + 10000.0);
|
// NormZComp = -1000.0 / (NormZComp + 10000.0);
|
||||||
// return (NormZComp + 1.0) * 0.5;
|
// return (NormZComp + 1.0) * 0.5;
|
||||||
@ -75,6 +75,8 @@ float ShadowCalculationPoint(uint lightIndex, vec3 fragToLight, vec3 fragNorm, /
|
|||||||
{
|
{
|
||||||
float currentDepth = VectorToDepth(fragToLight);// + bias;
|
float currentDepth = VectorToDepth(fragToLight);// + bias;
|
||||||
|
|
||||||
|
// currentDepth = -currentDepth * 0.5 + 0.5;
|
||||||
|
|
||||||
float visibility = texture(samplerCubeShadow(t_point_shadow_maps, s_point_shadow_maps), vec4(fragToLight, currentDepth));// / (screen_res.w/* - screen_res.z*/)/*1.0 -bias*//*-(currentDepth - bias) / screen_res.w*//*-screen_res.w*/);
|
float visibility = texture(samplerCubeShadow(t_point_shadow_maps, s_point_shadow_maps), vec4(fragToLight, currentDepth));// / (screen_res.w/* - screen_res.z*/)/*1.0 -bias*//*-(currentDepth - bias) / screen_res.w*//*-screen_res.w*/);
|
||||||
/* if (visibility == 1.0 || visibility == 0.0) {
|
/* if (visibility == 1.0 || visibility == 0.0) {
|
||||||
return visibility;
|
return visibility;
|
||||||
@ -166,6 +168,8 @@ float ShadowCalculationDirected(in vec3 fragPos)//in vec4 /*light_pos[2]*/sun_po
|
|||||||
// vec3 fragPos = sun_pos.xyz;// / sun_pos.w;//light_pos[lightIndex].xyz;
|
// vec3 fragPos = sun_pos.xyz;// / sun_pos.w;//light_pos[lightIndex].xyz;
|
||||||
// sun_pos.z += sun_pos.w * bias;
|
// sun_pos.z += sun_pos.w * bias;
|
||||||
vec4 sun_pos = texture_mat/*shadowMatrices*/ * vec4(fragPos, 1.0);
|
vec4 sun_pos = texture_mat/*shadowMatrices*/ * vec4(fragPos, 1.0);
|
||||||
|
// sun_pos.xy = 0.5 * sun_pos.w + sun_pos.xy * 0.5;
|
||||||
|
// sun_pos.xy = sun_pos.ww - sun_pos.xy;
|
||||||
// sun_pos.xyz /= abs(sun_pos.w);
|
// sun_pos.xyz /= abs(sun_pos.w);
|
||||||
// sun_pos.w = sign(sun_pos.w);
|
// sun_pos.w = sign(sun_pos.w);
|
||||||
// sun_pos.xy = (sun_pos.xy + 1.0) * 0.5;
|
// sun_pos.xy = (sun_pos.xy + 1.0) * 0.5;
|
||||||
|
@ -56,7 +56,7 @@ const int EXTRA_NEG_Z = 32768;
|
|||||||
void main() {
|
void main() {
|
||||||
#if (SHADOW_MODE == SHADOW_MODE_MAP)
|
#if (SHADOW_MODE == SHADOW_MODE_MAP)
|
||||||
vec3 f_chunk_pos = vec3(ivec3((uvec3(v_pos_norm) >> uvec3(0, 6, 12)) & uvec3(0x3Fu, 0x3Fu, 0xFFFFu)) - ivec3(0, 0, EXTRA_NEG_Z));
|
vec3 f_chunk_pos = vec3(ivec3((uvec3(v_pos_norm) >> uvec3(0, 6, 12)) & uvec3(0x3Fu, 0x3Fu, 0xFFFFu)) - ivec3(0, 0, EXTRA_NEG_Z));
|
||||||
vec3 f_pos = f_chunk_pos + model_offs - focus_off.xyz;
|
vec3 f_pos = f_chunk_pos + (model_offs - focus_off.xyz);
|
||||||
// f_pos = v_pos;
|
// f_pos = v_pos;
|
||||||
// vec3 f_pos = f_chunk_pos + model_offs;
|
// vec3 f_pos = f_chunk_pos + model_offs;
|
||||||
|
|
||||||
|
@ -58,6 +58,8 @@ pub struct Globals {
|
|||||||
ambiance: f32,
|
ambiance: f32,
|
||||||
cam_mode: u32,
|
cam_mode: u32,
|
||||||
sprite_render_distance: f32,
|
sprite_render_distance: f32,
|
||||||
|
/// To keep 16-byte-aligned.
|
||||||
|
globals_dummy: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@ -140,6 +142,7 @@ impl Globals {
|
|||||||
ambiance,
|
ambiance,
|
||||||
cam_mode: cam_mode as u32,
|
cam_mode: cam_mode as u32,
|
||||||
sprite_render_distance,
|
sprite_render_distance,
|
||||||
|
globals_dummy: 0.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +420,7 @@ impl GlobalsLayouts {
|
|||||||
binding: 0,
|
binding: 0,
|
||||||
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
||||||
ty: wgpu::BindingType::Texture {
|
ty: wgpu::BindingType::Texture {
|
||||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
sample_type: wgpu::TextureSampleType::Depth,
|
||||||
view_dimension: wgpu::TextureViewDimension::Cube,
|
view_dimension: wgpu::TextureViewDimension::Cube,
|
||||||
multisampled: false,
|
multisampled: false,
|
||||||
},
|
},
|
||||||
@ -437,7 +440,7 @@ impl GlobalsLayouts {
|
|||||||
binding: 2,
|
binding: 2,
|
||||||
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
visibility: wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT,
|
||||||
ty: wgpu::BindingType::Texture {
|
ty: wgpu::BindingType::Texture {
|
||||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
sample_type: wgpu::TextureSampleType::Depth,
|
||||||
view_dimension: wgpu::TextureViewDimension::D2,
|
view_dimension: wgpu::TextureViewDimension::D2,
|
||||||
multisampled: false,
|
multisampled: false,
|
||||||
},
|
},
|
||||||
|
@ -161,10 +161,10 @@ impl ShadowFigurePipeline {
|
|||||||
module: vs_module,
|
module: vs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
},
|
},
|
||||||
fragment_stage: Some(wgpu::ProgrammableStageDescriptor {
|
fragment_stage: /*Some(wgpu::ProgrammableStageDescriptor {
|
||||||
module: fs_module,
|
module: fs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
}),
|
})*/None,
|
||||||
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
|
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
|
||||||
front_face: wgpu::FrontFace::Ccw,
|
front_face: wgpu::FrontFace::Ccw,
|
||||||
cull_mode: wgpu::CullMode::Front,
|
cull_mode: wgpu::CullMode::Front,
|
||||||
@ -237,10 +237,10 @@ impl ShadowPipeline {
|
|||||||
module: vs_module,
|
module: vs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
},
|
},
|
||||||
fragment_stage: Some(wgpu::ProgrammableStageDescriptor {
|
fragment_stage: /*Some(wgpu::ProgrammableStageDescriptor {
|
||||||
module: fs_module,
|
module: fs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
}),
|
})*/None,
|
||||||
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
|
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
|
||||||
front_face: wgpu::FrontFace::Ccw,
|
front_face: wgpu::FrontFace::Ccw,
|
||||||
cull_mode: wgpu::CullMode::Front,
|
cull_mode: wgpu::CullMode::Front,
|
||||||
@ -315,10 +315,10 @@ impl PointShadowPipeline {
|
|||||||
module: vs_module,
|
module: vs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
},
|
},
|
||||||
fragment_stage: Some(wgpu::ProgrammableStageDescriptor {
|
fragment_stage: /*Some(wgpu::ProgrammableStageDescriptor {
|
||||||
module: fs_module,
|
module: fs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
}),
|
})*/None,
|
||||||
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
|
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
|
||||||
front_face: wgpu::FrontFace::Ccw,
|
front_face: wgpu::FrontFace::Ccw,
|
||||||
cull_mode: wgpu::CullMode::Front,
|
cull_mode: wgpu::CullMode::Front,
|
||||||
|
@ -2106,7 +2106,7 @@ fn create_pipelines(
|
|||||||
|
|
||||||
let figure_vert_mod = create_shader("figure-vert", ShaderKind::Vertex)?;
|
let figure_vert_mod = create_shader("figure-vert", ShaderKind::Vertex)?;
|
||||||
|
|
||||||
let terrain_point_shadow_vert_mod = create_shader("point-light-shadows-vert", ShaderKind::Vertex)?;
|
// let terrain_point_shadow_vert_mod = create_shader("Point-light-shadows-vert", ShaderKind::Vertex)?;
|
||||||
|
|
||||||
let terrain_directed_shadow_vert_mod =
|
let terrain_directed_shadow_vert_mod =
|
||||||
create_shader("light-shadows-directed-vert", ShaderKind::Vertex)?;
|
create_shader("light-shadows-directed-vert", ShaderKind::Vertex)?;
|
||||||
|
@ -172,7 +172,7 @@ impl<'a> Drawer<'a> {
|
|||||||
label: Some("Point shadow cubemap face"),
|
label: Some("Point shadow cubemap face"),
|
||||||
format: None,
|
format: None,
|
||||||
dimension: Some(wgpu::TextureViewDimension::D2),
|
dimension: Some(wgpu::TextureViewDimension::D2),
|
||||||
aspect: wgpu::TextureAspect::All,
|
aspect: wgpu::TextureAspect::DepthOnly,
|
||||||
base_mip_level: 0,
|
base_mip_level: 0,
|
||||||
level_count: None,
|
level_count: None,
|
||||||
base_array_layer: face,
|
base_array_layer: face,
|
||||||
|
Loading…
Reference in New Issue
Block a user