mirror of
https://github.com/hedge-dev/UnleashedRecomp
synced 2026-06-06 03:39:09 -04:00
Implement text skew, grayscale image, and marquee fade.
Marquee fade currently does not work with text shadow as the repeatedly drawn font accumulates its alpha.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "../imgui_common.h"
|
||||
|
||||
struct PushConstants
|
||||
{
|
||||
float2 GradientMin;
|
||||
float2 GradientMax;
|
||||
float2 BoundsMin;
|
||||
float2 BoundsMax;
|
||||
uint GradientTop;
|
||||
uint GradientBottom;
|
||||
uint ShaderModifier;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "imgui_common.hlsli"
|
||||
#include "../imgui_common.h"
|
||||
|
||||
float4 DecodeColor(uint color)
|
||||
{
|
||||
@@ -82,11 +81,22 @@ float4 main(in Interpolators interpolators) : SV_Target
|
||||
if (g_PushConstants.Texture2DDescriptorIndex != 0)
|
||||
color *= g_Texture2DDescriptorHeap[g_PushConstants.Texture2DDescriptorIndex].Sample(g_SamplerDescriptorHeap[0], interpolators.UV);
|
||||
|
||||
if (any(g_PushConstants.GradientMin != g_PushConstants.GradientMax))
|
||||
if (g_PushConstants.ShaderModifier == IMGUI_SHADER_MODIFIER_MARQUEE_FADE)
|
||||
{
|
||||
float2 factor = saturate((interpolators.Position.xy - g_PushConstants.GradientMin) / (g_PushConstants.GradientMax - g_PushConstants.GradientMin));
|
||||
color *= lerp(DecodeColor(g_PushConstants.GradientTop), DecodeColor(g_PushConstants.GradientBottom), factor.y);
|
||||
float minAlpha = saturate((interpolators.Position.x - g_PushConstants.BoundsMin.x) / g_PushConstants.Scale.x);
|
||||
float maxAlpha = saturate((g_PushConstants.BoundsMax.x - interpolators.Position.x) / g_PushConstants.Scale.x);
|
||||
|
||||
color.a *= minAlpha;
|
||||
color.a *= maxAlpha;
|
||||
}
|
||||
else if (any(g_PushConstants.BoundsMin != g_PushConstants.BoundsMax))
|
||||
{
|
||||
float2 factor = saturate((interpolators.Position.xy - g_PushConstants.BoundsMin) / (g_PushConstants.BoundsMax - g_PushConstants.BoundsMin));
|
||||
color *= lerp(DecodeColor(g_PushConstants.GradientTop), DecodeColor(g_PushConstants.GradientBottom), smoothstep(0.0, 1.0, factor.y));
|
||||
}
|
||||
|
||||
if (g_PushConstants.ShaderModifier == IMGUI_SHADER_MODIFIER_GRAYSCALE)
|
||||
color.rgb = dot(color.rgb, float3(0.2126, 0.7152, 0.0722));
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
#include "imgui_common.hlsli"
|
||||
|
||||
void main(in float2 position : POSITION, in float2 uv : TEXCOORD, in float4 color : COLOR, out Interpolators interpolators)
|
||||
{
|
||||
float2 correctedPosition = g_PushConstants.Origin + (position - g_PushConstants.Origin) * g_PushConstants.Scale;
|
||||
interpolators.Position = float4(correctedPosition * g_PushConstants.InverseDisplaySize * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
|
||||
{
|
||||
if (g_PushConstants.ShaderModifier == IMGUI_SHADER_MODIFIER_TEXT_SKEW)
|
||||
{
|
||||
if (position.y < g_PushConstants.Origin.y)
|
||||
position.x += g_PushConstants.Scale.x;
|
||||
}
|
||||
else if (g_PushConstants.ShaderModifier != IMGUI_SHADER_MODIFIER_MARQUEE_FADE)
|
||||
{
|
||||
position.xy = g_PushConstants.Origin + (position.xy - g_PushConstants.Origin) * g_PushConstants.Scale;
|
||||
}
|
||||
|
||||
interpolators.Position = float4(position.xy * g_PushConstants.InverseDisplaySize * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
|
||||
interpolators.UV = uv;
|
||||
interpolators.Color = color;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user