mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Make shadow vert shaders always contain their content but ensure they are never used when shadow maps are disabled, remove uneeded shadow frag shader
This commit is contained in:
parent
e8874b18c9
commit
2c074ac52b
@ -1,48 +0,0 @@
|
|||||||
// NOTE: We currently do nothing, and just rely on the default shader behavior.
|
|
||||||
//
|
|
||||||
// However, in the future we might apply some depth transforms here.
|
|
||||||
|
|
||||||
#version 420 core
|
|
||||||
// #extension ARB_texture_storage : enable
|
|
||||||
|
|
||||||
#include <constants.glsl>
|
|
||||||
|
|
||||||
#define LIGHTING_TYPE LIGHTING_TYPE_REFLECTION
|
|
||||||
|
|
||||||
#define LIGHTING_REFLECTION_KIND LIGHTING_REFLECTION_KIND_GLOSSY
|
|
||||||
|
|
||||||
#if (FLUID_MODE == FLUID_MODE_CHEAP)
|
|
||||||
#define LIGHTING_TRANSPORT_MODE LIGHTING_TRANSPORT_MODE_IMPORTANCE
|
|
||||||
#elif (FLUID_MODE == FLUID_MODE_SHINY)
|
|
||||||
#define LIGHTING_TRANSPORT_MODE LIGHTING_TRANSPORT_MODE_RADIANCE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LIGHTING_DISTRIBUTION_SCHEME LIGHTING_DISTRIBUTION_SCHEME_MICROFACET
|
|
||||||
|
|
||||||
#define LIGHTING_DISTRIBUTION LIGHTING_DISTRIBUTION_BECKMANN
|
|
||||||
|
|
||||||
// // Currently, we only need globals for the far plane.
|
|
||||||
// #include <globals.glsl>
|
|
||||||
// // Currently, we only need lights for the light position
|
|
||||||
// #include <light.glsl>
|
|
||||||
|
|
||||||
// in vec3 FragPos; // FragPos from GS (output per emitvertex)
|
|
||||||
// flat in int FragLayer;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
// Only need to do anything with point lights, since sun and moon should already have nonlinear
|
|
||||||
// distance.
|
|
||||||
/*if (FragLayer > 0) */{
|
|
||||||
// get distance between fragment and light source
|
|
||||||
// float lightDistance = length(FragPos - lights[FragLayer & 31].light_pos.xyz);
|
|
||||||
|
|
||||||
// // // map to [0;1] range by dividing by far_plane
|
|
||||||
// lightDistance = lightDistance / screen_res.w;//FragPos.w;//screen_res.w;
|
|
||||||
|
|
||||||
// // // write this as modified depth
|
|
||||||
// // // lightDistance = -1000.0 / (lightDistance + 10000.0);
|
|
||||||
// // // lightDistance /= screen_res.w;
|
|
||||||
// gl_FragDepth = lightDistance;// / /*FragPos.w;*/screen_res.w;//-1000.0 / (lightDistance + 1000.0);//lightDistance
|
|
||||||
}
|
|
||||||
}
|
|
@ -54,7 +54,6 @@ uniform u_locals {
|
|||||||
const int EXTRA_NEG_Z = 32768;
|
const int EXTRA_NEG_Z = 32768;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
#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;
|
||||||
@ -66,5 +65,4 @@ void main() {
|
|||||||
// gl_Position.z = clamp(gl_Position.z, -abs(gl_Position.w), abs(gl_Position.w));
|
// gl_Position.z = clamp(gl_Position.z, -abs(gl_Position.w), abs(gl_Position.w));
|
||||||
// shadowMapCoord = lights[gl_InstanceID].light_pos * gl_Vertex;
|
// shadowMapCoord = lights[gl_InstanceID].light_pos * gl_Vertex;
|
||||||
// vec4(v_pos, 0.0, 1.0);
|
// vec4(v_pos, 0.0, 1.0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,6 @@ uniform u_bones {
|
|||||||
// out vec4 shadowMapCoord;
|
// out vec4 shadowMapCoord;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
#if (SHADOW_MODE == SHADOW_MODE_MAP)
|
|
||||||
uint bone_idx = (v_pos_norm >> 27) & 0xFu;
|
uint bone_idx = (v_pos_norm >> 27) & 0xFu;
|
||||||
vec3 pos = (vec3((uvec3(v_pos_norm) >> uvec3(0, 9, 18)) & uvec3(0x1FFu)) - 256.0) / 2.0;
|
vec3 pos = (vec3((uvec3(v_pos_norm) >> uvec3(0, 9, 18)) & uvec3(0x1FFu)) - 256.0) / 2.0;
|
||||||
|
|
||||||
@ -80,5 +79,4 @@ void main() {
|
|||||||
).xyz + (model_pos - focus_off.xyz/* + vec3(0.0, 0.0, 0.0001)*/);
|
).xyz + (model_pos - focus_off.xyz/* + vec3(0.0, 0.0, 0.0001)*/);
|
||||||
|
|
||||||
gl_Position = shadowMatrices * vec4(f_pos, 1.0);
|
gl_Position = shadowMatrices * vec4(f_pos, 1.0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -124,9 +124,13 @@ impl<'frame> Drawer<'frame> {
|
|||||||
/// Get the render mode.
|
/// Get the render mode.
|
||||||
pub fn render_mode(&self) -> &super::super::RenderMode { self.borrow.mode }
|
pub fn render_mode(&self) -> &super::super::RenderMode { self.borrow.mode }
|
||||||
|
|
||||||
/// Returns None if the shadow renderer is not enabled or the pipelines are
|
/// Returns None if the shadow renderer is not enabled at some level or the
|
||||||
/// not available yet
|
/// pipelines are not available yet
|
||||||
pub fn shadow_pass(&mut self) -> Option<ShadowPassDrawer> {
|
pub fn shadow_pass(&mut self) -> Option<ShadowPassDrawer> {
|
||||||
|
if !self.borrow.mode.shadow.is_map() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
if let ShadowMap::Enabled(ref shadow_renderer) = self.borrow.shadow?.map {
|
if let ShadowMap::Enabled(ref shadow_renderer) = self.borrow.shadow?.map {
|
||||||
let encoder = self.encoder.as_mut().unwrap();
|
let encoder = self.encoder.as_mut().unwrap();
|
||||||
let device = self.borrow.device;
|
let device = self.borrow.device;
|
||||||
@ -256,13 +260,18 @@ impl<'frame> Drawer<'frame> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Does nothing if the shadow pipelines are not available
|
/// Does nothing if the shadow pipelines are not available or shadow map
|
||||||
|
/// rendering is disabled
|
||||||
pub fn draw_point_shadows<'data: 'frame>(
|
pub fn draw_point_shadows<'data: 'frame>(
|
||||||
&mut self,
|
&mut self,
|
||||||
matrices: &[shadow::PointLightMatrix; 126],
|
matrices: &[shadow::PointLightMatrix; 126],
|
||||||
chunks: impl Clone
|
chunks: impl Clone
|
||||||
+ Iterator<Item = (&'data Model<terrain::Vertex>, &'data terrain::BoundLocals)>,
|
+ Iterator<Item = (&'data Model<terrain::Vertex>, &'data terrain::BoundLocals)>,
|
||||||
) {
|
) {
|
||||||
|
if !self.borrow.mode.shadow.is_map() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(ShadowMap::Enabled(ref shadow_renderer)) = self.borrow.shadow.map(|s| &s.map) {
|
if let Some(ShadowMap::Enabled(ref shadow_renderer)) = self.borrow.shadow.map(|s| &s.map) {
|
||||||
let device = self.borrow.device;
|
let device = self.borrow.device;
|
||||||
let mut encoder = self
|
let mut encoder = self
|
||||||
|
@ -630,6 +630,7 @@ fn create_ingame_and_shadow_pipelines(
|
|||||||
terrain,
|
terrain,
|
||||||
// player_shadow_pipeline,
|
// player_shadow_pipeline,
|
||||||
},
|
},
|
||||||
|
// TODO: skip creating these if the shadow map setting is not enabled
|
||||||
shadow: ShadowPipelines {
|
shadow: ShadowPipelines {
|
||||||
point: Some(point_shadow),
|
point: Some(point_shadow),
|
||||||
directed: Some(terrain_directed_shadow),
|
directed: Some(terrain_directed_shadow),
|
||||||
|
Loading…
Reference in New Issue
Block a user