Toon shader advice needed, pls help!

Posted By: JetpackMonkey

Toon shader advice needed, pls help! - 08/03/08 12:39

Hi there,

I need to use a toon shader in a night scene-- but everything I've managed with it looks simply bright and daytime, regardless of the brightness I set in the sun (e.g. 0 or -100).

Can someone please tell me a good way to get a night effect with a toon shader? Here's what I'm using..

Quote:

material mtl_toon
{
skin1=toonlookup_bmp;
effect =
"
matrix matWorldViewProj;
matrix matWorld;vector vecSunDir;
texture entSkin1;texture mtlSkin1;
technique t0{
pass p0 // shade it
{
zwriteenable= true;
zenable = true;
Texture[0]=<mtlSkin1>;
ColorOp[0]=Modulate;
ColorArg1[0]=Texture;
ColorArg2[0]=Texture;
AddressU[0]=Clamp;
AddressV[0]=Clamp;
AddressW[0]=Clamp;
TexCoordIndex[0]=0;
Texture[1]=<entSkin1>;
ColorOp[1]=Modulate;
ColorArg1[1]=Texture;
ColorArg2[1]=Current;
TexCoordIndex[1]=1;
VertexShaderConstant[0] = <matWorldViewProj>;
VertexShaderConstant[4] = <matWorld>;
VertexShaderConstant[7] = <vecSunDir>;

VertexShader = asm
{
vs_1_0
dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8
mov oT2.xy, v7
dp4 oPos.x, c0, v0
dp4 oPos.y , c1, v0
dp4 oPos.z, c2, v0
dp4 oPos.w, c3, v0
dp3 r0.x, c4.xyz, v3.xyz
dp3 r0.y, c5.xyz, v3.xyz
dp3 r0.z, c6.xyz, v3.xyz
dp3 oT0.x, r0.xyz, -c7.xyz
mov oT1.xyz, v8
};
}

pass p1 // ink it
{
CULLMODE=CW;
vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[16]=0;//0.2; // outline thickness
vertexShader = asm
{
vs_1_0
dcl_position v0
dcl_normal v3
dcl_texcoord v7
mov r0,v0
mul r1,c16.x,v3
// Scale the normal
add r0.xyz,r0.xyz,r1.xyz
m4x4 oPos,r0,c0
// Transorm position to clip space
mov oD0, c0
mov r0,c0
};
}
}
";
}

Posted By: TigerTao

Re: Toon shader advice needed, pls help! - 08/03/08 14:28

Have you tried darkening down the toonlookup.bmp? So white is a darkish blue and then all others periodically darker until completely black.
Posted By: JetpackMonkey

Re: Toon shader advice needed, pls help! - 08/03/08 15:19

Thanks Tiger, that worked great!
Posted By: cro_games

Re: Toon shader advice needed, pls help! - 08/03/08 15:21

The best way is to dark down the toonlookup_bmp..I have create cartoon night scene once..
Posted By: The_Clyde

Re: Toon shader advice needed, pls help! - 08/06/08 02:37

What if there were dark AND light places in a scene?

Is there a way to make the toonshader respond to level lighting the way the default shading does?
Posted By: lostclimate

Re: Toon shader advice needed, pls help! - 08/06/08 03:21

not with the wiki shader, but it is possible. one way is to use a ppe.
Posted By: The_Clyde

Re: Toon shader advice needed, pls help! - 08/06/08 14:53

is it possible to add the black-outlining pass from the toon shader to the built-in shading used when no shader is specified?
Posted By: lostclimate

Re: Toon shader advice needed, pls help! - 08/06/08 15:11

well it is possible to do the built in shading in a shader, and add the line.
Posted By: The_Clyde

Re: Toon shader advice needed, pls help! - 08/07/08 05:16

...what's the line? Where do I put it?

BTW, this is very helpful and I'm glad I didnt have to open up a new post on the same thing! laugh

Thanks!
Posted By: lostclimate

Re: Toon shader advice needed, pls help! - 08/07/08 06:20

well it wouldnt be up to you to add the line, you'd have to prolly beg a shader programmer to do it for you. I would but I have tons of work to do currently.
Posted By: The_Clyde

Re: Toon shader advice needed, pls help! - 08/29/08 07:23

meh. I'm very much the do-it-myself type anyway, and it looks like a matter of copying the black-outline pass and pasting it into the default shader.

I know how the outline works BTW; it takes the model and draws a duplicate tha'ts scaled a little bigger with the normals flipped.

So where do I find the shading code that is used when no shader is explicitly called for? o_O
© 2024 lite-C Forums