How to change variables on the Cartoon fx?
- TiagoR2
- Topic Author
Less
More
6 years 6 months ago - 6 years 6 months ago #1
by TiagoR2
How to change variables on the Cartoon fx? was created by TiagoR2
Hello!
I'm using the Nomad Mod for FPSC which includes ReShade (an older version, I imagine, given the age of the software)
I'm using the cartoon effect included in the cellshading.fx file with has the following:
Which gives the following output:
What I want to know is if it's possible to make changes to this file as to still have the edges on the models (and make them thicker) but not on the textures.
As it is, it appears to apply an edge-detection filter to the actual textures, giving most models a very dark, over-detailed look. You can see for example in the tip of the rug that is visible on the left, it becomes almost pitch black.
I have very little knowledge of shaders and filters, but basically I'm after the XIII look:
Any help is greatly appreciated!
I'm using the Nomad Mod for FPSC which includes ReShade (an older version, I imagine, given the age of the software)
I'm using the cartoon effect included in the cellshading.fx file with has the following:
Warning: Spoiler!
string Description = "Cartoon shader by Joshua Bawden Brett";
string Thumbnail = "EdgeDetect.png";
//Shader edited for Nomad Mod
float2 ViewSize : ViewSize;
float EdgeHardness
<
string UIWidget = "slider";
float UIMax = 3.0;
float UIMin = 0.0;
float UIStep = 0.01;
> = 1.000000;
//box filter, declare in pixel offsets convert to texel offsets in PS
float2 DownFilterSamples[9] =
{
{ -1, -1 },
{ -1, 0 },
{ -1, 1 },
{ 0, 1 },
{ 1, 1 },
{ 1, 0 },
{ 1, -1 },
{ 0, -1 },
{ 0, 0 },
};
float2 EdgeOffsets[9] =
{
{ -1, -1 },
{ 0, -1 },
{ 1, -1 },
{ -1, 0 },
{ 0, 0 },
{ 1, 0 },
{ -1, 1 },
{ 0, 1 },
{ 1, 1 },
};
float EdgeWeightsH[9] =
{
1, 2, 1,
0, 0, 0,
-1, -2, -1
};
float EdgeWeightsV[9] =
{
-1, 0, 1,
-2, 0, 2,
-1, 0, 1
};
texture frameImg : RENDERCOLORTARGET
<
string ResourceName = "";
float2 ViewportRatio = { 1.0, 1.0 };
>;
sampler2D frameImgSamp = sampler_state {
Texture = < frameImg >;
MinFilter = Linear; MagFilter = Linear; MipFilter = Linear;
AddressU = Clamp; AddressV = Clamp;
};
texture EdgeImg : RENDERCOLORTARGET
<
string ResourceName = "";
float2 ViewportRatio = { 1.0, 1.0 };
>;
sampler2D EdgeSamp = sampler_state {
Texture = < EdgeImg >;
MinFilter = Linear; MagFilter = Linear; MipFilter = Linear;
AddressU = Clamp; AddressV = Clamp;
};
struct input
{
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
struct output {
float4 pos: POSITION;
float2 uv: TEXCOORD0;
};
output VS( input IN )
{
output OUT;
//needs to be shifted by half a pixel.
//Go here for more info: http://www.sjbrown.co.uk/?article=directx_texels
float4 oPos = float4( IN.pos.xy + float2( -1.0f/ViewSize.x, 1.0f/ViewSize.y ),0.0,1.0 );
OUT.pos = oPos;
float2 uv = (IN.pos.xy + 1.0) / 2.0;
uv.y = 1 - uv.y;
OUT.uv = uv;
return OUT;
}
float4 PSEdgeDetect( output IN, uniform sampler2D srcTex ) : COLOR
{
float4 color=0;
float4 edgeH = 0;
float4 edgeV = 0;
float2 scale = EdgeHardness/ViewSize;
color = tex2D( srcTex, IN.uv );
//Filter to detect the edges
for (int i = 0; i < 9; i++)
{
float4 pixel = tex2D( srcTex, IN.uv + EdgeOffsets[i].xy*scale );
edgeH += pixel*EdgeWeightsH[i];
edgeV += pixel*EdgeWeightsV[i];
}
//merge horizontal and vertical edges into a single value
float edge = 1- saturate(abs(edgeH.r) + abs(edgeV.r));
//return edge;
return edge*color;
}
technique Blur
<
//specify where the original scene should be drawn
string RenderColorTarget = "frameImg";
>
{
//single pass to detect edges and output modified result to screen
pass EdgeDetect
<
string RenderColorTarget = "";
>
{
VertexShader = compile vs_1_1 VS();
PixelShader = compile ps_2_0 PSEdgeDetect( frameImgSamp );
}
}
Which gives the following output:
What I want to know is if it's possible to make changes to this file as to still have the edges on the models (and make them thicker) but not on the textures.
As it is, it appears to apply an edge-detection filter to the actual textures, giving most models a very dark, over-detailed look. You can see for example in the tip of the rug that is visible on the left, it becomes almost pitch black.
I have very little knowledge of shaders and filters, but basically I'm after the XIII look:
Any help is greatly appreciated!
Last edit: 6 years 6 months ago by TiagoR2.
Please Log in or Create an account to join the conversation.