For the render of the red image.
Code:
#ifdef __CloseToDeathIndicator
if (g_pPlayer && g_Option.deathIndication)
{
if (g_pPlayer->GetHitPointPercent() < 10)
{
static bool loadedAlready = false;
static CTexture* injuredTexture = nullptr;
if (!loadedAlready)
{
std::thread([&]() { injuredTexture = m_textureMng.AddTexture(pd3dDevice, "Theme/Injured.png", 0xffff0000, true); }).detach();
loadedAlready = true;
}
if (injuredTexture != nullptr)
{
static int alpha = 255;
static bool subtract = true;
const float fX = static_cast<float>(g_Option.m_nResWidth) / static_cast<float>(injuredTexture->m_size.cx);
const float fY = static_cast<float>(g_Option.m_nResHeight) / static_cast<float>(injuredTexture->m_size.cy);
injuredTexture->RenderScal(&g_Neuz.m_2DRender, CPoint(0, 0), alpha, fX, fY);
if (subtract)
--alpha;
else
++alpha;
if (alpha == 255)
subtract = true;
else if (alpha == 125)
subtract = false;
}
}
}
include <thread> and cwndworld::OnEraseBkgnd
dark illusion shader from jospi then with added vignette filter (fx).
Code:
texture Tex_Diffuse;
sampler Samp_Diffuse = sampler_state
{
Texture = <Tex_Diffuse>;
MinFilter = ANISOTROPIC;
MagFilter = ANISOTROPIC;
MipFilter = NONE;
MaxAnisotropy = 16;
};
struct VS_OUTPUT_TEXTURE
{
float4 Pos : POSITION;
float2 Tex : TEXCOORD0;
};
VS_OUTPUT_TEXTURE VS_PostBlackWhite( float4 Pos : POSITION, float2 Tex : TEXCOORD0 )
{
VS_OUTPUT_TEXTURE Out = (VS_OUTPUT_TEXTURE)0;
Out.Pos = Pos;
Out.Tex = Tex;
return Out;
}
float4 PS_PostBlackWhite(VS_OUTPUT_TEXTURE In) : COLOR
{
float4 Color = 0;
float2 Center = {0.5, 0.5};
float BlurStart = 1.0;
float BlurWidth = -0.01;
float samples = 10;
for(int i = 0; i < samples; i++)
{
float scale = BlurStart + BlurWidth * (i / (samples - 1));
Color += tex2D(Samp_Diffuse, (In.Tex - 0.5) * scale + Center );
}
Color /= samples;
Color.rgb = dot(Color.rgb, float3(0.3, 0.59, 0.11));
Color.a = 1.0f;
float tex_xy = dot(float4(In.Tex, In.Tex), float4(-In.Tex, 1.0, 1.0));
Color.rgb = saturate(tex_xy * 2.0) * Color.rgb;
return Color;
}
technique PostProcess
{
pass p0
{
VertexShader = compile vs_2_0 VS_PostBlackWhite();
PixelShader = compile ps_2_0 PS_PostBlackWhite();
}
}