Skip to content

Commit

Permalink
+ tree amplitude (sway amount) aka LA. For best visuals, set tree_amp…
Browse files Browse the repository at this point in the history
…litude_intensity, wind_direction, and wind_velocity for each weather config. Can be completely disabled with TREE_WIND_EFFECT define
  • Loading branch information
avoitishin authored and Xottab-DUTY committed Aug 19, 2017
1 parent a91ff26 commit ea1b5a6
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/Common/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
//#define MOUSE_MOVE_CALLBACK // expose mouse move callback to scripts (configure in bind_stalker)
//#define KEY_RELEASE_CALLBACK // expose key release callback to scripts (configure in bind_stalker)
//#define KEY_HOLD_CALLBACK // expose key hold callback to scripts (configure in bind_stalker)
//#define FP_DEATH // first person death view

// VISUAL:
#define DETAIL_RADIUS // detail draw radius (by K.D.)
#define ECO_RENDER //ECO_RENDER adds a small delay between rendering, reduce FPS in main menu or in videos
#define NEW_ANIMS // use new animations. Please enclose any new animation additions with this define
#define NEW_SOUNDS // use new sounds. Please enclose any new sound additions with this define
#define ECO_RENDER // limit FPS in menu to prevent video card overheat (by alpet)
#define TREE_WIND_EFFECT // configurable tree sway, can be used to have trees sway more during storms or lightly on clear days.
//-VISUAL

// TWEAKS:
//#define FP_DEATH // first person death view
#define DEAD_BODY_COLLISION // restore collision with dead bodies (thanks malandrinus)
#define NEW_ANIMS // use new animations. Please enclose any new animation addions with this define
#define NEW_SOUNDS // use new sounds. Please enclose any new sound addions with this define
//#define CONFIG_SUN_MOVEMENT // With this defined sun will move as configured in weather ltx files
//-TWEAKS
19 changes: 18 additions & 1 deletion src/Layers/xrRender/FTreeVisual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "xrCore/FMesh.hpp"
#include "FTreeVisual.h"

#include "Common/Config.hpp"

shared_str m_xform;
shared_str m_xform_v;
shared_str c_consts;
Expand Down Expand Up @@ -92,11 +94,26 @@ struct FTreeVisual_setup
{
dwFrame = Device.dwFrame;

// Calc wind-vector3, scale
float tm_rot = PI_MUL_2 * Device.fTimeGlobal / ps_r__Tree_w_rot;

// Calc wind-vector3, scale
#ifdef TREE_WIND_EFFECT
CEnvDescriptor& env = *g_pGamePersistent->Environment().CurrentEnv;

wind.set(_sin(tm_rot), 0, _cos(tm_rot), 0);
wind.normalize();
#if RENDER!=R_R1
float fValue = env.m_fTreeAmplitudeIntensity;
wind.mul(fValue); // dir1*amplitude
#else // R1
wind.mul(ps_r__Tree_w_amp); // dir1*amplitude
#endif //-RENDER!=R_R1
#else //!TREE_WIND_EFFECT
wind.set(_sin(tm_rot), 0, _cos(tm_rot), 0);
wind.normalize();
wind.mul(ps_r__Tree_w_amp); // dir1*amplitude
#endif //-TREE_WIND_EFFECT

scale = 1.f / float(FTreeVisual_quant);

// setup constants
Expand Down
14 changes: 14 additions & 0 deletions src/Layers/xrRenderPC_R2/r2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "Layers/xrRender/dxWallMarkArray.h"
#include "Layers/xrRender/dxUIShader.h"

#include "Common/Config.hpp"

CRender RImplementation;

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -84,6 +86,18 @@ static class cl_water_intensity : public R_constant_setup
}
} binder_water_intensity;

#ifdef TREE_WIND_EFFECT
static class cl_tree_amplitude_intensity : public R_constant_setup
{
void setup(R_constant* C) override
{
CEnvDescriptor& env = *g_pGamePersistent->Environment().CurrentEnv;
float fValue = env.m_fTreeAmplitudeIntensity;
RCache.set_c(C, fValue, fValue, fValue, 0);
}
} binder_tree_amplitude_intensity;
#endif

static class cl_sun_shafts_intensity : public R_constant_setup
{
virtual void setup(R_constant* C)
Expand Down
14 changes: 14 additions & 0 deletions src/Layers/xrRenderPC_R3/r3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "Layers/xrRenderDX10/3DFluid/dx103DFluidManager.h"
#include "D3DX10Core.h"

#include "Common/Config.hpp"

CRender RImplementation;

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -95,6 +97,18 @@ static class cl_water_intensity : public R_constant_setup
}
} binder_water_intensity;

#ifdef TREE_WIND_EFFECT
static class cl_tree_amplitude_intensity : public R_constant_setup
{
void setup(R_constant* C) override
{
CEnvDescriptor& env = *g_pGamePersistent->Environment().CurrentEnv;
float fValue = env.m_fTreeAmplitudeIntensity;
RCache.set_c(C, fValue, fValue, fValue, 0);
}
} binder_tree_amplitude_intensity;
#endif

static class cl_sun_shafts_intensity : public R_constant_setup
{
virtual void setup(R_constant* C)
Expand Down
14 changes: 14 additions & 0 deletions src/Layers/xrRenderPC_R4/r4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "Layers/xrRender/ShaderResourceTraits.h"
#include "D3DX10Core.h"

#include "Common/Config.hpp"

CRender RImplementation;

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -101,6 +103,18 @@ static class cl_water_intensity : public R_constant_setup
}
} binder_water_intensity;

#ifdef TREE_WIND_EFFECT
static class cl_tree_amplitude_intensity : public R_constant_setup
{
void setup(R_constant* C) override
{
CEnvDescriptor& env = *g_pGamePersistent->Environment().CurrentEnv;
float fValue = env.m_fTreeAmplitudeIntensity;
RCache.set_c(C, fValue, fValue, fValue, 0);
}
} binder_tree_amplitude_intensity;
#endif

static class cl_sun_shafts_intensity : public R_constant_setup
{
virtual void setup(R_constant* C)
Expand Down
5 changes: 5 additions & 0 deletions src/xrEngine/Environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "xrCommon/xr_vector.h"
#include "xrCommon/xr_map.h"

#include "Common/Config.hpp"

// refs
class ENGINE_API IRender_Visual;
Expand Down Expand Up @@ -172,6 +173,10 @@ class ENGINE_API CEnvDescriptor
float m_fSunShaftsIntensity;
float m_fWaterIntensity;

#ifdef TREE_WIND_EFFECT
float m_fTreeAmplitudeIntensity;
#endif

// int lens_flare_id;
// int tb_id;
shared_str lens_flare_id;
Expand Down
15 changes: 15 additions & 0 deletions src/xrEngine/Environment_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "Common/object_broker.h"
#include "Common/LevelGameDef.h"

#include "Common/Config.hpp"

void CEnvModifier::load(IReader* fs, u32 version)
{
use_flags.one();
Expand Down Expand Up @@ -218,6 +220,10 @@ CEnvDescriptor::CEnvDescriptor(shared_str const& identifier) : m_identifier(iden
m_fSunShaftsIntensity = 0;
m_fWaterIntensity = 1;

#ifdef TREE_WIND_EFFECT
m_fTreeAmplitudeIntensity = 0.01;
#endif

lens_flare_id = "";
tb_id = "";

Expand Down Expand Up @@ -295,6 +301,11 @@ void CEnvDescriptor::load(CEnvironment& environment, CInifile& config)
if (config.line_exist(m_identifier.c_str(), "water_intensity"))
m_fWaterIntensity = config.r_float(m_identifier.c_str(), "water_intensity");

#ifdef TREE_WIND_EFFECT
if (config.line_exist(m_identifier.c_str(), "tree_amplitude_intensity"))
m_fTreeAmplitudeIntensity = config.r_float(m_identifier.c_str(), "tree_amplitude_intensity");
#endif

C_CHECK(clouds_color);
C_CHECK(sky_color);
C_CHECK(fog_color);
Expand Down Expand Up @@ -436,6 +447,10 @@ void CEnvDescriptorMixer::lerp(
m_fSunShaftsIntensity = fi * A.m_fSunShaftsIntensity + f * B.m_fSunShaftsIntensity;
m_fWaterIntensity = fi * A.m_fWaterIntensity + f * B.m_fWaterIntensity;

#ifdef TREE_WIND_EFFECT
m_fTreeAmplitudeIntensity = fi * A.m_fTreeAmplitudeIntensity + f * B.m_fTreeAmplitudeIntensity;
#endif

// colors
//. sky_color.lerp (A.sky_color,B.sky_color,f).add(Mdf.sky_color).mul(modif_power);
sky_color.lerp(A.sky_color, B.sky_color, f);
Expand Down

0 comments on commit ea1b5a6

Please sign in to comment.