Skip to content

Commit

Permalink
Remove default shadow bias of 0.1 for spot and omni light, fixes godo…
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz authored and amugana committed Jun 28, 2017
1 parent 6827b54 commit 2b19524
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions drivers/gles3/rasterizer_scene_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions drivers/gles3/rasterizer_scene_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class RasterizerSceneGLES3 : public RasterizerScene {

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];
Expand Down
14 changes: 7 additions & 7 deletions drivers/gles3/shaders/scene.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions scene/3d/light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 2b19524

Please sign in to comment.