Torque3D/Templates/Modules/PostFXPack/Shaders/edgeDetectionP.hlsl
Areloch f1777016b8 GFX card profile config file logging moved to debug only
WIP mode of guiSliderCtrl to be a filled rectangle instead of a textured UI
Fixed bug with guiTextEditCtrl losing focus updating history passing malformed strings
Updated WIP options menu
Editor/Project settings WIP
Updated editor theme to be consistent, and feed off the editor settings
Updated popup menus to reference renamed profiles
Added more in-progress modules for examples/stress testing
2019-06-17 02:30:45 -05:00

48 lines
No EOL
1 KiB
HLSL

#include "shaders/common/postFx/postFx.hlsl"
#include "../../torque.hlsl"
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
uniform float threshold;
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
{
float4 base = TORQUE_TEX2D(backBuffer, IN.uv0);
const int NUM = 9;
const float2 c[NUM] =
{
float2(-0.0078125, 0.0078125),
float2( 0.00 , 0.0078125),
float2( 0.0078125, 0.0078125),
float2(-0.0078125, 0.00 ),
float2( 0.0, 0.0),
float2( 0.0078125, 0.007 ),
float2(-0.0078125,-0.0078125),
float2( 0.00 , -0.0078125),
float2( 0.0078125,-0.0078125),
};
int i;
float3 col[NUM];
for (i=0; i < NUM; i++)
{
col[i] = TORQUE_TEX2D(backBuffer, IN.uv0 + 0.2*c[i]);
}
float3 rgb2lum = float3(0.30, 0.59, 0.11);
float lum[NUM];
for (i = 0; i < NUM; i++)
{
lum[i] = dot(col[i].xyz, rgb2lum);
}
float x = lum[2]+ lum[8]+2*lum[5]-lum[0]-2*lum[3]-lum[6];
float y = lum[6]+2*lum[7]+ lum[8]-lum[0]-2*lum[1]-lum[2];
float edge =(x*x + y*y < threshold)? 1.0:0.0;
base.rgb *= edge;
return base;
}