Просмотр исходного кода

Remove default shadow bias of 0.1 for spot and omni light, fixes #8654

Juan Linietsky 8 лет назад
Родитель
Сommit
95c248e24f

+ 4 - 4
drivers/gles3/rasterizer_scene_gles3.cpp

@@ -3840,8 +3840,8 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
 
 	state.ubo_data.subsurface_scatter_width = subsurface_scatter_size;
 
-	state.ubo_data.shadow_z_offset = 0;
-	state.ubo_data.shadow_slope_scale = 0;
+	state.ubo_data.z_offset = 0;
+	state.ubo_data.z_slope_scale = 0;
 	state.ubo_data.shadow_dual_paraboloid_render_side = 0;
 	state.ubo_data.shadow_dual_paraboloid_render_zfar = 0;
 
@@ -4514,8 +4514,8 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_
 	glClear(GL_DEPTH_BUFFER_BIT);
 	glDisable(GL_SCISSOR_TEST);
 
-	state.ubo_data.shadow_z_offset = bias;
-	state.ubo_data.shadow_slope_scale = normal_bias;
+	state.ubo_data.z_offset = bias;
+	state.ubo_data.z_slope_scale = normal_bias;
 	state.ubo_data.shadow_dual_paraboloid_render_side = dp_direction;
 	state.ubo_data.shadow_dual_paraboloid_render_zfar = zfar;
 

+ 2 - 2
drivers/gles3/rasterizer_scene_gles3.h

@@ -119,8 +119,8 @@ public:
 
 			float ambient_energy;
 			float bg_energy;
-			float shadow_z_offset;
-			float shadow_slope_scale;
+			float z_offset;
+			float z_slope_scale;
 			float shadow_dual_paraboloid_render_zfar;
 			float shadow_dual_paraboloid_render_side;
 			float screen_pixel_size[2];

+ 7 - 7
drivers/gles3/shaders/scene.glsl

@@ -74,8 +74,8 @@ layout(std140) uniform SceneData { //ubo:0
 	float ambient_energy;
 	float bg_energy;
 
-	float shadow_z_offset;
-	float shadow_z_slope_scale;
+	float z_offset;
+	float z_slope_scale;
 	float shadow_dual_paraboloid_render_zfar;
 	float shadow_dual_paraboloid_render_side;
 
@@ -319,7 +319,7 @@ VERTEX_SHADER_CODE
 
 	//for dual paraboloid shadow mapping, this is the fastest but least correct way, as it curves straight edges
 
-	highp vec3 vtx = vertex_interp+normalize(vertex_interp)*shadow_z_offset;
+	highp vec3 vtx = vertex_interp+normalize(vertex_interp)*z_offset;
 	highp float distance = length(vtx);
 	vtx = normalize(vtx);
 	vtx.xy/=1.0-vtx.z;
@@ -332,8 +332,8 @@ VERTEX_SHADER_CODE
 
 #else
 
-	float z_ofs = shadow_z_offset;
-	z_ofs += (1.0-abs(normal_interp.z))*shadow_z_slope_scale;
+	float z_ofs = z_offset;
+	z_ofs += (1.0-abs(normal_interp.z))*z_slope_scale;
 	vertex_interp.z-=z_ofs;
 
 #endif //RENDER_DEPTH_DUAL_PARABOLOID
@@ -446,8 +446,8 @@ layout(std140) uniform SceneData {
 	float ambient_energy;
 	float bg_energy;
 
-	float shadow_z_offset;
-	float shadow_z_slope_scale;
+	float z_offset;
+	float z_slope_scale;
 	float shadow_dual_paraboloid_render_zfar;
 	float shadow_dual_paraboloid_render_side;
 

+ 3 - 2
scene/3d/light.cpp

@@ -261,8 +261,8 @@ Light::Light(VisualServer::LightType p_type) {
 	set_param(PARAM_SHADOW_SPLIT_1_OFFSET, 0.1);
 	set_param(PARAM_SHADOW_SPLIT_2_OFFSET, 0.2);
 	set_param(PARAM_SHADOW_SPLIT_3_OFFSET, 0.5);
-	set_param(PARAM_SHADOW_NORMAL_BIAS, 0.1);
-	set_param(PARAM_SHADOW_BIAS, 0.1);
+	set_param(PARAM_SHADOW_NORMAL_BIAS, 0.0);
+	set_param(PARAM_SHADOW_BIAS, 0.);
 	set_param(PARAM_SHADOW_BIAS_SPLIT_SCALE, 0.1);
 }
 
@@ -328,6 +328,7 @@ void DirectionalLight::_bind_methods() {
 DirectionalLight::DirectionalLight()
 	: Light(VisualServer::LIGHT_DIRECTIONAL) {
 
+	set_param(PARAM_SHADOW_NORMAL_BIAS, 0.1);
 	set_shadow_mode(SHADOW_PARALLEL_4_SPLITS);
 	blend_splits = false;
 }