@Assissin6691:
I'm not sure if the attached shader works in FPSC but I don't see any reason why not.I'm going to use it as the base shader for this.
To add cartoon effects to any fullscreen shader all you need to do is:
Add these lines to the section of the shader marked 'tweakables'
float2 PixelOffsets[9] =
{
{ -1, -1 },
{ 0, -1 },
{ 1, -1 },
{ -1, 0 },
{ 0, 0 },
{ 1, 0 },
{ -1, 1 },
{ 0, 1 },
{ 1, 1 },
};
float EdgeDetectH[9] =
{
-1, -2, -1,
0, 0, 0,
1, 2, 1
};
float EdgeDetectV[9] =
{
-1, 0, 1,
-2, 0, 2,
-1, 0, 1
};
float edgeSize
<
string UIWidget = "slider";
float UIMax = 3.0;
float UIMin = 0.01;
float UIStep = 0.01;
> = 1.000000;
Then find the pixel shader section and paste in this near the top
float edgeH = 0;
float edgeV = 0;
float2 scale = edgeSize/ViewSize;
color = tex2D( srcTex, IN.uv );
//Sobel filter to detect edges we want to highlight
for (int i = 0; i < 9; i++)
{
//convert pixel offsets into texel offsets via the inverse view values.
float pixel = tex2D( srcTex, IN.uv + PixelOffsets[i].xy*scale ).a;
edgeH += pixel*EdgeDetectH[i];
edgeV += pixel*EdgeDetectV[i];
}
float edge = edgeH*edgeH + edgeV*edgeV;
edge = edge > 0.0049; //clamp
And finally, find the line that starts with 'return'. Most shaders will have only the word 'final' after this. This tells the shader to use this line as the output. But replace final with
lerp(final,(1-edge),edge)
I hope this is easy enough to understand.
Insanity is doing the same thing everyday, same job, same route, same people and thinking 'Today will be different', thinking that over and over again. But not doing anything different.