diff --git a/ChaosMod/ChaosMod.vcxproj b/ChaosMod/ChaosMod.vcxproj index 24b92cc7d..cd3d8a84c 100644 --- a/ChaosMod/ChaosMod.vcxproj +++ b/ChaosMod/ChaosMod.vcxproj @@ -208,6 +208,7 @@ + diff --git a/ChaosMod/Effects/db/Screen/Shaders/ScreenShaderTinyScreen.cpp b/ChaosMod/Effects/db/Screen/Shaders/ScreenShaderTinyScreen.cpp new file mode 100644 index 000000000..ce0235451 --- /dev/null +++ b/ChaosMod/Effects/db/Screen/Shaders/ScreenShaderTinyScreen.cpp @@ -0,0 +1,50 @@ +#include + +#include "Memory/Hooks/ShaderHook.h" + +static const char *ms_ShaderSrcPrefix = R"SRC( +Texture2D HDRSampler : register(t5); +SamplerState g_samLinear : register(s5) +{ + Filter = MIN_MAG_MIP_LINEAR; + AddressU = Wrap; + AddressV = Wrap; +}; + +float4 main(float4 position : SV_POSITION, float3 texcoord : TEXCOORD0, float4 color : COLOR0) : SV_Target0 +{ + float multiplier =)SRC"; + +static const char *ms_ShaderSrcSuffix = R"SRC(; + texcoord.x = (texcoord.x - 0.5) * multiplier + 0.5; + texcoord.y = (texcoord.y - 0.5) * multiplier + 0.5; + + if (texcoord.x > 1. || texcoord.y > 1. || texcoord.x < 0. || texcoord.y < 0.) { + return (0., 0., 0., 0.); + } + + return HDRSampler.Sample(g_samLinear, texcoord); +} +)SRC"; + +static void OnStart() +{ + Hooks::OverrideShader(OverrideShaderType::LensDistortion, ms_ShaderSrcPrefix + std::to_string(g_Random.GetRandomInt(9, 40)) + ms_ShaderSrcSuffix); +} + +static void OnStop() +{ + Hooks::ResetShader(); +} + +// clang-format off +REGISTER_EFFECT(OnStart, OnStop, nullptr, EffectInfo + { + .Name = "Tiny Screen", + .Id = "screen_tinyscreen", + .IsTimed = true, + .IsShortDuration = true, + .EffectCategory = EffectCategory::Shader, + .EffectGroupType = EffectGroupType::Shader + } +); \ No newline at end of file diff --git a/ConfigApp/Effects.cs b/ConfigApp/Effects.cs index 5d1796c91..0dd60367d 100644 --- a/ConfigApp/Effects.cs +++ b/ConfigApp/Effects.cs @@ -409,6 +409,7 @@ public enum EffectTimedType { "misc_muffled_audio", new EffectInfo("Muffled Audio", EffectCategory.Misc, true) }, { "misc_fakeuturn", new EffectInfo("Fake U-Turn", EffectCategory.Misc) }, { "misc_esp", new EffectInfo("ESP", EffectCategory.Misc, true) }, + { "screen_tinyscreen", new EffectInfo("Tiny Screen", EffectCategory.Screen, true, true) }, { "screen_bouncyradar", new EffectInfo("Bouncy Radar", EffectCategory.Screen, true) }, { "veh_boostbrake", new EffectInfo("Boost Braking", EffectCategory.Vehicle, true) }, { "cocktail_shaker", new EffectInfo("Cocktail Shaker", EffectCategory.Misc, true, true) },