toon shader...how to use?

Posted By: Blink

toon shader...how to use? - 08/19/08 23:49

i am a real noob when it comes to shaders. i finally got the chrome and normal maps for objects to work. my problem is toonshaders. i have a game that i would like to use them, but how do i get it to work? how do i set it up so everything on the level including the player and enemy models are "toon shaded"?
Posted By: ello

Re: toon shader...how to use? - 08/20/08 19:20

you could use my ready2use toon shader found here

or if you just want the outline apply to the standard shading use this:
Code:
float4x4 matWorldViewProj;

struct VS_IN 
{
	float4 pos : POSITION;
	float4 nrm : NORMAL;
};

struct VS_OUT 
{
	float4 oPos : POSITION;
	float4 oC0 : COLOR0;
	float4 oC1 : COLOR1;
};

VS_OUT OutlineVS (VS_IN In, uniform float scale, uniform float3 rgb)
{
	VS_OUT Out;
	In.pos.xyz += In.nrm.xyz*scale;
	Out.oPos = mul(In.pos,matWorldViewProj);
	Out.oC0 = Out.oC1 = float4(rgb,1.0);
	return Out;
}

technique test
{
	pass p1
	{
		CullMode = CCW;
	}
	pass p0
	{
		CullMode = CW;
		VertexShader = compile vs_2_0 OutlineVS(1,float3(0.5,0,0)); // thickness , rgb
	}
}


you could than go on and use vecSkill41 for the color and scale, so every entity could have its own color and thickness

hope this helps
Posted By: Blink

Re: toon shader...how to use? - 08/20/08 21:40

thanks ello, but how do i apply it? i added the scripts to my level, what am i missing? there is no change. my card is able to use shadermodel 2.0.
Posted By: Blink

Re: toon shader...how to use? - 08/20/08 22:52

ok, i got it working, but there is a thick line around my player and enemy models. what do i do about that?
Posted By: ello

Re: toon shader...how to use? - 08/21/08 14:34

you can adjust the thickness. btw, you can use vs_1_1 as well
Posted By: Blink

Re: toon shader...how to use? - 08/21/08 19:09

i tried the ready2use, that caused a massive amount of slowdown, and the thick outlines. should i be using the code you posted instead?
Posted By: ello

Re: toon shader...how to use? - 08/21/08 20:29

you could try that. i had no such massiv fps dropdowns when i created the ready2use

the code i posted is just creating the outline and can be combined with whatever you want
Posted By: Slin

Re: toon shader...how to use? - 08/21/08 20:31

Blink, the outline is a feature of the shader!
Posted By: Blink

Re: toon shader...how to use? - 08/21/08 23:12

you dont understand Nils, the outline is thicker than the models body. looks like he is encased in a blackhole. its a cool looking effect, but not like the effects i have seen here in the forums.
Posted By: ello

Re: toon shader...how to use? - 08/22/08 07:49

oh and btw, i dont have such thick lines. did you use it with lite-c? in that case you need to use floatv instead of float... dunno, just a guess
Posted By: Blink

Re: toon shader...how to use? - 08/25/08 11:25

no, i have A6.60. not sure why it looked like that.
© 2023 lite-C Forums