Skip to content

Commit 1099772

Browse files
committed
Point-lights flickering and virtual size fix.
1 parent f8fe8c4 commit 1099772

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

src/Layers/xrRender/Light_Render_Direct_ComputeXFS.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ void CLight_Compute_XFORM_and_VIS::compute_xf_spot(light* L)
8888

8989
// _min(L->cone + deg2rad(4.5f), PI*0.98f) - Here, it is needed to enlarge the shadow map frustum to include also
9090
// displaced pixels and the pixels neighbor to the examining one.
91-
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);
91+
float tan_shift;
92+
if (L->flags.type == IRender_Light::POINT)
93+
tan_shift = deg2rad(11.5f);
94+
else
95+
tan_shift = deg2rad(3.5f);
96+
97+
L->X.S.project.build_projection(L->cone + tan_shift, 1.f, L->virtual_size, L->range + EPS_S);
9298
L->X.S.combine.mul(L->X.S.project, L->X.S.view);
9399
}

src/Layers/xrRender/light.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ light::light(void) : SpatialBase(g_SpatialSpace)
1717
direction.set(0, -1, 0);
1818
right.set(0, 0, 0);
1919
range = 8.f;
20+
virtual_size = 0.1f;
2021
cone = deg2rad(60.f);
2122
color.set(1, 1, 1, 1);
2223

@@ -342,6 +343,7 @@ void light::Export(light_Package& package)
342343
L->set_rotation(cmDir[f], R);
343344
L->set_cone(PI_DIV_2);
344345
L->set_range(range);
346+
L->set_virtual_size(virtual_size);
345347
L->set_color(color);
346348
L->spatial.sector = spatial.sector; //. dangerous?
347349
L->s_spot = s_spot;

src/Layers/xrRender/light.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class light : public IRender_Light, public SpatialBase
2626
Fvector direction;
2727
Fvector right;
2828
float range;
29+
float virtual_size;
2930
float cone;
3031
Fcolor color;
3132

@@ -113,7 +114,7 @@ class light : public IRender_Light, public SpatialBase
113114
virtual void set_rotation(const Fvector& D, const Fvector& R);
114115
virtual void set_cone(float angle);
115116
virtual void set_range(float R);
116-
virtual void set_virtual_size(float /*R*/){};
117+
virtual void set_virtual_size(float R) { virtual_size = R; }
117118
virtual void set_color(const Fcolor& C) { color.set(C); }
118119
virtual void set_color(float r, float g, float b) { color.set(r, g, b, 1); }
119120
virtual void set_texture(LPCSTR name);

src/xrGame/HangingLamp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ BOOL CHangingLamp::net_Spawn(CSE_Abstract* DC)
101101
light_render->set_type(
102102
lamp->flags.is(CSE_ALifeObjectHangingLamp::flTypeSpot) ? IRender_Light::SPOT : IRender_Light::POINT);
103103
light_render->set_range(lamp->range);
104+
light_render->set_virtual_size(lamp->m_virtual_size);
104105
light_render->set_color(clr);
105106
light_render->set_cone(lamp->spot_cone_angle);
106107
light_render->set_texture(*lamp->light_texture);

0 commit comments

Comments
 (0)