Agreed, this is awesome! I’ve gone ahead and used your example to implement the HLSL for those using DX11
HLSL for DX11
<renderpath>
<command type="quad" tag="Vibrance" vs="Vibrance" ps="Vibrance" output="viewport">
<texture unit="diffuse" name="viewport" />
<parameter name="Amount" value="1.0" />
<parameter name="Coeff" value="0.299 0.587 0.114 0.0" />
</command>
</renderpath>
#include "Uniforms.hlsl"
#include "Samplers.hlsl"
#include "Transform.hlsl"
#include "ScreenPos.hlsl"
#include "Lighting.hlsl"
cbuffer CustomVS : register(b6)
{
float cAmount;
float4 cCoeff;
}
void VS(
float4 iPos : POSITION,
out float2 oScreenPos : TEXCOORD0,
out float4 oPos : OUTPOSITION
)
{
float4x3 modelMatrix = iModelMatrix;
float3 worldPos = GetWorldPos(modelMatrix);
oPos = GetClipPos(worldPos);
oScreenPos = GetScreenPosPreDiv(oPos);
}
void PS(
float2 iScreenPos : TEXCOORD0,
out float4 oColor : OUTCOLOR0
)
{
float4 color = Sample2DLod0(DiffMap, iScreenPos);
float lum = dot(color, cCoeff);
float4 lum4 = float4(lum, lum, lum, lum); // hlsl wants this expressed explicitly.
float4 mask = (color - lum4);
mask = clamp(mask, 0.0, 1.0);
float lumMask = dot(cCoeff, mask);
lumMask = 1.0 - lumMask;
oColor = lerp(lum4, color, 1.0 + cAmount * lumMask);
}