Implement weather particle culling and increase particle count

This commit is contained in:
Lwmte 2025-04-25 12:23:54 +02:00
parent ad01accd58
commit 6c0eeff41c
3 changed files with 14 additions and 7 deletions

View file

@ -25,6 +25,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
* Fixed crashes when Lara is on a vehicle unreachable by friendly NPCs.
* Removed legacy TR5 search object code which caused issues with meshswaps.
* Removed excessive HK nerfing in running state.
* Optimized weather particle rendering.
### Lua API changes
* Added `View.PlayVideo`, `View.StopVideo`, and other helper functions for the video playback.

View file

@ -9,7 +9,7 @@ using namespace TEN::Entities::Effects;
namespace TEN::Effects::Environment
{
constexpr auto WEATHER_PARTICLE_SPAWN_DENSITY = 32;
constexpr auto WEATHER_PARTICLE_COUNT_MAX = 2048;
constexpr auto WEATHER_PARTICLE_COUNT_MAX = 4096;
constexpr auto WEATHER_PARTICLE_COLL_CHECK_DELAY_MAX = 5.0f;
constexpr auto DUST_SIZE_MAX = 25.0f;

View file

@ -1028,6 +1028,12 @@ namespace TEN::Renderer
if (!part.Enabled)
continue;
auto pos = Vector3::Lerp(part.PrevPosition, part.Position, GetInterpolationFactor());
auto size = Lerp(part.PrevSize, part.Size, GetInterpolationFactor());
if (!view.Camera.Frustum.SphereInFrustum(pos, size))
continue;
switch (part.Type)
{
case WeatherType::None:
@ -1037,9 +1043,9 @@ namespace TEN::Renderer
AddSpriteBillboard(
&_sprites[Objects[ID_DEFAULT_SPRITES].meshIndex + SPR_UNDERWATERDUST],
Vector3::Lerp(part.PrevPosition, part.Position, GetInterpolationFactor()),
pos,
Color(1.0f, 1.0f, 1.0f, part.Transparency()),
0.0f, 1.0f, Vector2(Lerp(part.PrevSize, part.Size, GetInterpolationFactor())),
0.0f, 1.0f, Vector2(size),
BlendMode::Additive, true, view);
break;
@ -1051,9 +1057,9 @@ namespace TEN::Renderer
AddSpriteBillboard(
&_sprites[Objects[ID_DEFAULT_SPRITES].meshIndex + SPR_UNDERWATERDUST],
Vector3::Lerp(part.PrevPosition, part.Position, GetInterpolationFactor()),
pos,
Color(1.0f, 1.0f, 1.0f, part.Transparency()),
0.0f, 1.0f, Vector2(Lerp(part.PrevSize, part.Size, GetInterpolationFactor())),
0.0f, 1.0f, Vector2(size),
BlendMode::Additive, true, view);
break;
@ -1068,10 +1074,10 @@ namespace TEN::Renderer
AddSpriteBillboardConstrained(
&_sprites[Objects[ID_DRIP_SPRITE].meshIndex],
Vector3::Lerp(part.PrevPosition, part.Position, GetInterpolationFactor()),
pos,
Color(0.8f, 1.0f, 1.0f, part.Transparency()),
0.0f, 1.0f,
Vector2(RAIN_WIDTH, Lerp(part.PrevSize, part.Size, GetInterpolationFactor())),
Vector2(RAIN_WIDTH, size),
BlendMode::Additive, -v, true, view);
break;