diff --git a/README.md b/README.md index 7363cfd..5232b5d 100644 --- a/README.md +++ b/README.md @@ -1,70 +1,10 @@ -# Fake-CSM-Source-2013 -Recreated env_cascade_light from CS GO based on env_projectedtexture and Real CSM GMod addon. +# Fake-CSM-Source-2013 Dev mapbase 7.1 branch +This branch contains some changes for mapbase 7.1 and some test shit. -- It's not finished yet, but some basic functionality is already there. There are also some issues with lighting orientation, so if you get very strange lighting position behavior then try manually rotating it to the same position as light_environment. Also he have some problems with models. +#Branch Features -``This was written for Mapbase, so I'm not sure if it will work if you don't have mapbase`` - -You can change csm settings in console, just type `csm_`. - -`If you know how to fix bugs or some visual shit dont be shy and tell me about it` - -| Game | Can Work | -|----------------|---------------:| -|CSS | NO | -|Sdk 2013 SP | Yes | -|Sdk 2013 MP | Yes | -|Linux |looks like its not| - - -Here is video demonstration: https://www.youtube.com/watch?v=3ERKBZsuLR4 -(Bad fps because i have bad pc, not because of lightning) - - -Right now im trying to make this work (or look) almost like actual CSM, so work in progress. - -# Features -- Partial compatibility with CSGO. - -# How to add this to your Source 2013 mod? -Copy client and server foldert to your "source code/game" folder, then find client_base/server_base.vpc files in these folders and add `$Include "csm.vpc"` to the top, open createallprojects.bat (or creategameprojects.bat) and add "-f" to the end of the line. After all this stuff you should launch your bat file. - -if you can't compile the code then make sure you have lights.h in your project and it has this code: - -```cpp -class CEnvLight : public CLight -{ -public: - DECLARE_CLASS(CEnvLight, CLight); - - bool KeyValue(const char* szKeyName, const char* szValue); - void Spawn(void); -}; -``` - -Then copy materials folder to the your mod folder. - -Your `mat_depthbias_shadowmap` better should be `0.00001`, `mat_slopescaledepthbias_shadowmap` should be `4` and `r_flashlightdepthres` should be more then `2048`. Its only for better visual and you not literally should do that. - -If you have `r_flashlightdepthres 4096` then better change `csm_filter` to `0.5`. - -# How to add this light in your map -Copy csm.fgd from fgd folder to bin folder in SDK Base 2013. -Add this fgd to your hammer. -Add env_cascade_light to the map and set it to the angle you want. -If you want to use the angle from light_environment then you need to set `Use light_environment's angles` to Yes and do some manipulation with your light_environment: -- Add any targetname to your light_environment -- Copy Pitch to second number of the Angle. -- Thats how it should looks like: - -![Alt-текст](https://github.com/celisej567/Fake-CSM-Source-2013/blob/main/screen1.png "") - -here is example - -![Alt-текст](https://github.com/celisej567/Fake-CSM-Source-2013/blob/main/example.png "") - -``IF THIS IS WORKS BAD YOU NEED TO FIND RIGHT ANGLE BY YOURSELF!`` - -# If you have some problem or question -then go to the [Discord server](https://discord.gg/DaBHDTwAU7) and describe the problem. +-Somehow fixed model lighting problems +-Changes intensity because mapbase updates. +-Added light_env changes to csm.fgd. +`ALSO NOW YOU SHOULD COPY PITCH PARAMETERS EXECLY HOW IT SHOULD BE (PITCH YAW ROLL)` \ No newline at end of file diff --git a/client/c_env_cascade_light.cpp b/client/c_env_cascade_light.cpp index 6c61534..20eee20 100644 --- a/client/c_env_cascade_light.cpp +++ b/client/c_env_cascade_light.cpp @@ -18,10 +18,13 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -static ConVarRef mat_slopescaledepthbias_shadowmap("mat_slopescaledepthbias_shadowmap"); -static ConVarRef mat_depthbias_shadowmap("mat_depthbias_shadowmap"); +//ConVar csm_slopescaledepthbias_shadowmap("csm_slopescaledepthbias_shadowmap", "0.00005"); +//ConVar csm_depthbias_shadowmap("csm_depthbias_shadowmap", "4"); + static ConVar scissor("r_flashlightscissor", "0"); ConVar csm_enable("csm_enable", "1"); +//ConVarRef csm_second_intensity("csm_second_intensity"); +ConVar csm_intensity("csm_intensity", "1000"); #ifdef MAPBASE //static ConVar csm_ortho("csm_ortho","0", 0, "Turn light into ortho. Im lazy right now to make this works fine"); @@ -172,7 +175,6 @@ void C_EnvCascadeLight::OnDataChanged( DataUpdateType_t updateType ) BaseClass::OnDataChanged( updateType ); } -ConVar csm_intensity("csm_intensity","1"); void C_EnvCascadeLight::UpdateLight( bool bForceUpdate ) { @@ -300,8 +302,8 @@ void C_EnvCascadeLight::UpdateLight( bool bForceUpdate ) state.m_Color[3] = m_flAmbient; // fixme: need to make ambient work m_flAmbient; state.m_NearZ = m_flNearZ; state.m_FarZ = m_flFarZ; - state.m_flShadowSlopeScaleDepthBias = mat_slopescaledepthbias_shadowmap.GetFloat(); - state.m_flShadowDepthBias = mat_depthbias_shadowmap.GetFloat(); + state.m_flShadowSlopeScaleDepthBias = ConVarRef("mat_slopescaledepthbias_shadowmap").GetFloat();//csm_slopescaledepthbias_shadowmap.GetFloat(); + state.m_flShadowDepthBias = ConVarRef("mat_depthbias_shadowmap").GetFloat();//csm_depthbias_shadowmap.GetFloat(); state.m_bEnableShadows = m_bEnableShadows; state.m_pSpotlightTexture = materials->FindTexture(m_SpotlightTextureName, TEXTURE_GROUP_OTHER, false); state.m_nSpotlightTextureFrame = m_nSpotlightTextureFrame; @@ -608,8 +610,8 @@ void C_EnvCascadeLightSecond::UpdateLight(bool bForceUpdate) m_flFarZ = 16000; state.m_NearZ = m_flNearZ; state.m_FarZ = m_flFarZ; - state.m_flShadowSlopeScaleDepthBias = mat_slopescaledepthbias_shadowmap.GetFloat(); - state.m_flShadowDepthBias = mat_depthbias_shadowmap.GetFloat(); + state.m_flShadowSlopeScaleDepthBias = ConVarRef("mat_slopescaledepthbias_shadowmap").GetFloat();//csm_slopescaledepthbias_shadowmap.GetFloat(); + state.m_flShadowDepthBias = ConVarRef("mat_depthbias_shadowmap").GetFloat();//csm_depthbias_shadowmap.GetFloat(); state.m_bEnableShadows = m_bEnableShadows; state.m_pSpotlightTexture = materials->FindTexture(m_SpotlightTextureName, TEXTURE_GROUP_OTHER, false); state.m_nSpotlightTextureFrame = m_nSpotlightTextureFrame; diff --git a/example.png b/example.png deleted file mode 100644 index 8e6b6a2..0000000 Binary files a/example.png and /dev/null differ diff --git a/fgd/csm.fgd b/fgd/csm.fgd index 9bd35f7..bace0f8 100644 --- a/fgd/csm.fgd +++ b/fgd/csm.fgd @@ -25,4 +25,19 @@ input Texture(string) : "Change texture" input LightColor(color255) : "Set the light color." input SetAngles(string) : "Set the sun direction." +] + +@PointClass base(Angles) iconsprite("editor/light_env.vmt") = light_environment : + "Sets the color and angle of the light from the sun and sky." +[ + targetname(string) : "Name" + pitch(integer) : "Pitch" : 0 : "The downward pitch of the light from the sun. 0 is horizontal, -90 is straight down." + _light(color255) : "Brightness" : "255 255 255 200" + _ambient(color255) : "Ambient" : "255 255 255 20" + _lightHDR(color255) : "BrightnessHDR" : "-1 -1 -1 1" + _lightscaleHDR(float) : "BrightnessScaleHDR" : "1" : "Amount to scale the light by when compiling for HDR." + _ambientHDR(color255) : "AmbientHDR" : "-1 -1 -1 1" + _AmbientScaleHDR(float) : "AmbientScaleHDR" : "1" : "Amount to scale the ambient light by when compiling for hdr." + pitch(integer) : "Pitch" : 0 : "The downward pitch of the light from the sun. 0 is horizontal, -90 is straight down." + SunSpreadAngle(float) : "SunSpreadAngle" : 0 : "The angular extent of the sun for casting soft shadows. Higher numbers are more diffuse. 5 is a good starting value." ] \ No newline at end of file diff --git a/screen1.png b/screen1.png deleted file mode 100644 index 95ef88e..0000000 Binary files a/screen1.png and /dev/null differ diff --git a/server/env_cascade_light.cpp b/server/env_cascade_light.cpp index ca38245..48fa804 100644 --- a/server/env_cascade_light.cpp +++ b/server/env_cascade_light.cpp @@ -20,8 +20,10 @@ static ConVar defdist("csm_default_distance", "1000", FCVAR_DEVELOPMENTONLY, "De static ConVar curdist("csm_current_distance","14000", 0, "Current Z distance. You can change it."); static ConVar defFOV("csm_default_fov","15", FCVAR_DEVELOPMENTONLY, "Default FOV. Used for some fov calculations. Please dont change"); static ConVar curFOV("csm_current_fov","15", 0, "Current FOV. You can change it"); -static ConVar csm_second_fov("csm_second_fov", "26", FCVAR_NONE ,"FOV of the second csm."); +static ConVar csm_second_fov("csm_second_fov", "25", FCVAR_NONE ,"FOV of the second csm."); ConVar csm_enable("csm_enable", "1"); +ConVar csm_second_intensity("csm_second_intensity", "1000"); + //ConVar csm_ortho("csm_ortho", "0"); class CLightOrigin : public CPointEntity @@ -70,7 +72,6 @@ void CLightOrigin::Spawn() CEnvLight* pEnv = dynamic_cast(pEntity); QAngle bb = pEnv->GetAbsAngles(); - //bb.x = bb.x; SetAbsAngles(bb); ConColorMsg(Color(0,230,0), "light_environment Founded!\n"); @@ -126,6 +127,8 @@ private: CNetworkVar(float, m_flNearZ); CNetworkVar(float, m_flFarZ); CNetworkVar(int, m_nShadowQuality); + + }; LINK_ENTITY_TO_CLASS(second_csm, CEnvCascadeLightSecond); @@ -390,7 +393,6 @@ CEnvCascadeLight::CEnvCascadeLight(void) } -ConVar csm_second_intensity("csm_second_intensity", "2"); void CEnvCascadeLight::Preparation() {