Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "Tiny Screen" Effect #3479

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChaosMod/ChaosMod.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
<ClCompile Include="Effects\db\Screen\Shaders\ScreenShaderShatteredScreen.cpp" />
<ClCompile Include="Effects\db\Screen\Shaders\ScreenShaderSwappedColors.cpp" />
<ClCompile Include="Effects\db\Screen\Shaders\ScreenShaderTextureless.cpp" />
<ClCompile Include="Effects\db\Screen\Shaders\ScreenShaderTinyScreen.cpp" />
<ClCompile Include="Effects\db\Screen\Shaders\ScreenShaderTnPanel.cpp" />
<ClCompile Include="Effects\db\Screen\Shaders\ScreenShaderWarpedCam.cpp" />
<ClCompile Include="Effects\db\Vehs\VehsCrumble.cpp" />
Expand Down
50 changes: 50 additions & 0 deletions ChaosMod/Effects/db/Screen/Shaders/ScreenShaderTinyScreen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <stdafx.h>

#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
}
);
1 change: 1 addition & 0 deletions ConfigApp/Effects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand Down