You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.4 KiB
54 lines
1.4 KiB
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
|
|
|
// STATIC: "PS3REGCOUNT12" "0..0"
|
|
|
|
#define HDRTYPE HDR_TYPE_NONE
|
|
#include "common_ps_fxc.h"
|
|
|
|
// This pixel shader compares the luminance against a constant value and retruns all 1's when greater
|
|
|
|
sampler TexSampler : register( s0 );
|
|
|
|
struct PS_INPUT
|
|
{
|
|
float2 uv0 : TEXCOORD0;
|
|
};
|
|
|
|
float3 g_vComparisonMinMaxScale : register( c0 );
|
|
#define g_flComparisonMin g_vComparisonMinMaxScale.x
|
|
#define g_flComparisonMax g_vComparisonMinMaxScale.y
|
|
|
|
struct PS_OUTPUT
|
|
{
|
|
float4 color : COLOR0;
|
|
#ifndef _X360
|
|
float depth : DEPTH; // Workaround for ATI driver bug
|
|
#endif
|
|
};
|
|
|
|
PS_OUTPUT main( PS_INPUT i )
|
|
{
|
|
float3 color = tex2D( TexSampler, i.uv0 ).xyz;
|
|
|
|
// Formula for calculating luminance based on NTSC standard
|
|
float3 tmpv = { 0.2125f, 0.7154f, 0.0721f };
|
|
float flLuminance = dot( color.rgb, tmpv.rgb );
|
|
|
|
// Alternate formula for calculating luminance for linear RGB space (Widely used in color hue and saturation computations)
|
|
//float3 tmpv = { 0.3086f, 0.6094f, 0.0820f };
|
|
//float flLuminance = dot( color.rgb, tmpv.rgb );
|
|
|
|
// Simple average
|
|
//float flLuminance = ( color.r + color.g + color.b ) * 0.33333f;
|
|
|
|
PS_OUTPUT o;
|
|
o.color.a = step( g_flComparisonMin, flLuminance ) * step( flLuminance, g_flComparisonMax );
|
|
o.color.rgb = 1.0f;
|
|
#ifndef _X360
|
|
{
|
|
o.depth = 0.0f; // Workaround for ATI driver bug
|
|
}
|
|
#endif
|
|
|
|
return o;
|
|
}
|