Toonshading
From GameStudio Wiki
Thanks to ello for sharing this shader!
[edit]
Lite-C:
Material and function to adjust the effect:
//Toonshading
MATERIAL* Toonshading_mat =
{
effect = "Toonshading.fx";
}
function Toonshading_set_Value(r,g,b)
{
Toonshading_mat.skill1 = floatv(r); //4 looks okay
Toonshading_mat.skill2 = floatv(g); //same as above
Toonshading_mat.skill3 = floatv(b); //same as above
}
The Toonshading.fx file:
////Makes Details invisible and the colors a bit more intensive, which gives the Level a toon like look
float4 vecSkill1; //"Details" for the rgb values
float4 vecViewPort;
Texture TargetMap;
sampler2D smpSource = sampler_state { texture = <TargetMap>; };
float4 dirtyToonPS( float2 Tex : TEXCOORD0 ) : COLOR0
{
half4 Color = tex2D(smpSource,Tex.xy);
Color.r = round(Color.r*vecSkill1.x)/vecSkill1.x;
Color.g = round(Color.g*vecSkill1.y)/vecSkill1.y;
Color.b = round(Color.b*vecSkill1.z)/vecSkill1.z;
return Color;
}
technique postFX
{
pass p1
{
PixelShader = compile ps_2_0 dirtyToonPS();
}
}
technique fallback { pass one { } }
[edit]
C-Script
Material and function to adjust the effect:
//Toonshading
material Toonshading_mat
{
effect = "Toonshading.fx";
}
function Toonshading_set_Value(r,g,b)
{
Toonshading_mat.skill1 = floatv(r); //4 looks okay
Toonshading_mat.skill2 = floatv(g); //same as above
Toonshading_mat.skill3 = floatv(b); //same as above
}
The Toonshading.fx file:
////Makes Details invisible and the colors a bit more intensive, which gives the Level a toon like look
float4 vecSkill1; //"Details" for the rgb values
float4 vecViewPort;
Texture entSkin1;
sampler2D smpSource = sampler_state { texture = <entSkin1>; };
float4 dirtyToonPS( float2 Tex : TEXCOORD0 ) : COLOR0
{
half4 Color = tex2D(smpSource,Tex.xy);
Color.r = round(Color.r*vecSkill1.x)/vecSkill1.x;
Color.g = round(Color.g*vecSkill1.y)/vecSkill1.y;
Color.b = round(Color.b*vecSkill1.z)/vecSkill1.z;
return Color;
}
technique postFX
{
pass p1
{
PixelShader = compile ps_2_0 dirtyToonPS();
}
}
technique fallback { pass one { } }
--Slin 15:49, 17 November 2007 (CET)
