Skip to content

Commit

Permalink
Point-lights flickering and virtual size fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
RainbowZerg committed Jul 28, 2018
1 parent f8fe8c4 commit 1099772
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Layers/xrRender/Light_Render_Direct_ComputeXFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ void CLight_Compute_XFORM_and_VIS::compute_xf_spot(light* L)

// _min(L->cone + deg2rad(4.5f), PI*0.98f) - Here, it is needed to enlarge the shadow map frustum to include also
// displaced pixels and the pixels neighbor to the examining one.
L->X.S.project.build_projection(std::min(L->cone + deg2rad(5.f), PI * 0.98f), 1.f, SMAP_near_plane, L->range + EPS_S);
float tan_shift;
if (L->flags.type == IRender_Light::POINT)
tan_shift = deg2rad(11.5f);
else
tan_shift = deg2rad(3.5f);

L->X.S.project.build_projection(L->cone + tan_shift, 1.f, L->virtual_size, L->range + EPS_S);
L->X.S.combine.mul(L->X.S.project, L->X.S.view);
}
2 changes: 2 additions & 0 deletions src/Layers/xrRender/light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ light::light(void) : SpatialBase(g_SpatialSpace)
direction.set(0, -1, 0);
right.set(0, 0, 0);
range = 8.f;
virtual_size = 0.1f;
cone = deg2rad(60.f);
color.set(1, 1, 1, 1);

Expand Down Expand Up @@ -342,6 +343,7 @@ void light::Export(light_Package& package)
L->set_rotation(cmDir[f], R);
L->set_cone(PI_DIV_2);
L->set_range(range);
L->set_virtual_size(virtual_size);
L->set_color(color);
L->spatial.sector = spatial.sector; //. dangerous?
L->s_spot = s_spot;
Expand Down
3 changes: 2 additions & 1 deletion src/Layers/xrRender/light.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class light : public IRender_Light, public SpatialBase
Fvector direction;
Fvector right;
float range;
float virtual_size;
float cone;
Fcolor color;

Expand Down Expand Up @@ -113,7 +114,7 @@ class light : public IRender_Light, public SpatialBase
virtual void set_rotation(const Fvector& D, const Fvector& R);
virtual void set_cone(float angle);
virtual void set_range(float R);
virtual void set_virtual_size(float /*R*/){};
virtual void set_virtual_size(float R) { virtual_size = R; }
virtual void set_color(const Fcolor& C) { color.set(C); }
virtual void set_color(float r, float g, float b) { color.set(r, g, b, 1); }
virtual void set_texture(LPCSTR name);
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/HangingLamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ BOOL CHangingLamp::net_Spawn(CSE_Abstract* DC)
light_render->set_type(
lamp->flags.is(CSE_ALifeObjectHangingLamp::flTypeSpot) ? IRender_Light::SPOT : IRender_Light::POINT);
light_render->set_range(lamp->range);
light_render->set_virtual_size(lamp->m_virtual_size);
light_render->set_color(clr);
light_render->set_cone(lamp->spot_cone_angle);
light_render->set_texture(*lamp->light_texture);
Expand Down

0 comments on commit 1099772

Please sign in to comment.