DX9 Toon shader

Posted By: SingleCell

DX9 Toon shader - 11/19/04 04:44

Ok after stumbling round in the dark like an idiot, and much cussing, i got ventilators toon shader working under DX9.

So if you want good simple toon shading that works with ps1.2 and vs 1.1 (ie works on lower end cards as well as GF6 cards) and there seems to be a few of you. you can grab it from here.

www.single-cell.net/3dgs/downloads.htm

Regards

Tone
Posted By: Drew

Re: DX9 Toon shader - 11/19/04 05:04

HUGE THANKS!!!!!!!!
Posted By: Orange Brat

Re: DX9 Toon shader - 11/19/04 05:11

The old DX8 one worked the one time I tested it, but this one is giving me troubles. I set it up but my player model is bright white and is the same with all of the various bitmaps. I have a GeForce FX 5200 128MB, and I know it goes up to at least ps1.4, and according to the Pacific Assault demo, it can handle ps2.0.
Posted By: TheExpert

Re: DX9 Toon shader - 11/19/04 05:47

great !
thanks , i'll test it to see if it is ok with le latest beta.
Posted By: SingleCell

Re: DX9 Toon shader - 11/19/04 13:10

ORANGE BRAT: - This one NEEDS 6.31 or better. If the DX8 one works for you, use that, its the same shader. I just rejigged it to work with DX9.

DREW: Glad it was some help.

Anyone who knows about shaders: Ok, this shader works well for models but i also want to use it for view models (ie in the camera view - you know... the weapon arm and so forth.) Problem is, i cant quite figure out how you translate the sun position to the view. Using this shader, the views highlight is always in the same place no matter which way the view is facing - Can any one help with that?

Now im going back to drool over halflife 2... The Game is brilliance plus, but Steam.... well.... what a farce.

Tone
Posted By: Orange Brat

Re: DX9 Toon shader - 11/19/04 13:30

I am using 6.31.
Posted By: Drew

Re: DX9 Toon shader - 11/19/04 16:58

wow, just tried it, fantastic...great addition thanks to both you and ventialator! I love the material_model, works like a charm.
Posted By: TheExpert

Re: DX9 Toon shader - 11/19/04 19:23

Great work !

i've tried it with 6.31.2 (i have to reinstall 6.31.3), works great.
but the lightninig is the same all the time , it dosen't take account of the sun
or light position (no vecligh or sun light in the asm code).
i hope someone will add the sun lightning to make it final in some sort !

but i keep it , it works with DX9 and latest betas and works very great.
And a GREAT THANKS for the 4 toon tables and the given colormap and
that's easy to change in the code the outline or toomap for shading variation.
Posted By: 20BN

Re: DX9 Toon shader - 11/19/04 20:59

Good job! Thanks!
Posted By: SingleCell

Re: DX9 Toon shader - 11/20/04 10:07

The Expert:
Umm... it does use the sun position for the lighting... or at least it does for me. (but only on objects in the world, not view objects, i cant figure out how to get it to do that correctly.)

Try changing your sun_angle.pan and tilt in game while using the shader, you should see the highlights moving on models that use it.

Glad the art resources were usefull to people, I have some more stuff like that coming soon. A simple fur shader next, i think.

Tone
Posted By: Pappenheimer

Re: DX9 Toon shader - 11/21/04 00:37

Quote:

wow, just tried it, fantastic...great addition thanks to both you and ventialator! I love the material_model, works like a charm.




Totally agree! Worked great for me!
Posted By: TheExpert

Re: DX9 Toon shader - 11/21/04 07:41

Sorry singleCell ;
that's my fault , the shading was here when i tested it , that just the sun doesn't move
it works great , it's a great cell shading shader , and yes your ressources files
(tga toon map and color map) are very helpull.
Great work and thanks again !
Posted By: Wiz

Re: DX9 Toon shader - 01/20/05 04:40

I can't get this shader to work. All I get is black models. Anyone here that knows why?

I have an ATI x800 PRO and A6 Commercial v.6.31.4.
Posted By: Braxton

Re: DX9 Toon shader - 01/21/05 12:38

When I run it i get these errors:

< bmap_to_cubemap(mat_ToonShader.skin1)>
toonshaderdx9.wdl 22:0 Error(58): Parameter unknown mat_ToonShader keyword


and


< }>
toonshaderdx9.wdl 23:0 Error(96): Syntex error - nonexistent/empty function mtl_toon_int



BTW - I am using the A6 templates. And am using plBibed01.wdl as my movement script.


Can someone help me?!?!?!



Thanks in advanced,

Braxton
Posted By: Braxton

Re: DX9 Toon shader - 01/21/05 12:58

Now I have a new problem. when i run the level my model is just black. Why is that???


Thanks in advanced,

Braxton

BTW - i fixed my last problems.




EDIT - Does this need Pro... cause i have commercial.
Posted By: SlyBoots

Re: DX9 Toon shader - 01/21/05 13:29

I'd give it more than two thumbs up, but I only have two.
Posted By: Braxton

Re: DX9 Toon shader - 01/21/05 13:32

My question is, why do I get this...


out of this code:

// Simple Toon Shader
// Works with vs1.1 and ps1.2 - so it will work on most cards
// Works with DX 9 so it works with the 6.30 and above
// This is a modified version of ventilators original Simple Toon shader.

// To make this work you copy this stuff or add ths script.
// You also need two image files:
// 1 - tsnormalise.tga - which will get made into a normalisation cube map
// 2 - A shade map that determines the level and numer of shade bands in the paint section
// By default this shader uses ts2tone.tga which gives two tone shading.

// Normaliser cubemap sprite
bmap bmp_normalizationcube=<tsnormalise.tga>;
// Paint shade map for toonshader
bmap bmp_tstonemap=<ts3tone.tga>; // <<< CHANGE THIS TO CHANGE PAINT SHADING

// This Starter function takes the normaliser sprite and convirts it to a D3D cubemap
// This function is started on game start and needs to occur before the toon shader will work
// It creates a cubemap and assigns it to the shaders skin1 texture.


entity* player;

// Ink and paint toon shader - Takes light direction from sun direction vector
material material_ToonShader
{
skin1=bmp_normalizationcube; // This is the normalisation cubemap created by the starter function
skin2=bmp_tstonemap; // This is the shademap that determines the "shading" of the paint part of the shader

effect
"
texture entSkin1; // The models skin texture
texture mtlSkin1; // The normalisation map
texture mtlSkin2; // The tone map
matrix matWorldViewProj;
matrix matWorld;
vector vecSunDir; // Sun direction vector

technique TwoToneToon
{
// -------------- Painter --------------------
pass p0
{
texture[0]=<mtlSkin1>; // The normalisation map
texture[1]=<mtlSkin2>; // The shade map
texture[2]=<entSkin1>; // The models skin texture

addressU[1]=clamp;
addressU[2]=wrap;
addressV[2]=wrap;
magFilter[2]=linear;
minFilter[2]=linear;
mipFilter[2]=linear;

vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[4]=<matWorld>;
vertexShaderConstant[16]=<vecSunDir>;

vertexShader=asm
{
vs.1.1
dcl_position v0
dcl_normal v3
dcl_texcoord0 v7

m4x4 oPos,v0,c0 // transform position to clip space
m3x3 r0,v3,c4 // transform normal to world space
dp3 r0.w,r0,r0 // renormalize it
rsq r0.w,r0.w
mul r0,r0,r0.w
mov oT0.xyz,r0.xyz // output normal to oT0
mov oT1.xyz,-c16.xyz // output light direction to oT1
mov oT2.xy,v7.xy // output uvs to ot2
};
pixelShader=asm
{
ps.1.2
tex t0 // fetch normalized normal
texdp3tex t1,t0_bx2
tex t2 // sample color map
mul r0,t2,t1 // modulate with shading
};
}
// -------------- Outliner -------------------
pass p1
{
CULLMODE=CW;
vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[16]=0.8; // outline_thickness, def0.8 << CHANGE THIS TO CHANGE OUTLINE THICKNESS

vertexShader=asm
{
vs.1.1
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 // Shell offset (vertex pos + Scaled Normal)
m4x4 oPos,r0,c0 // Transorm position to clip space
};
pixelShader=asm
{
ps.1.1
def c0,0,0,0,5 // outline rgba << CHANGE THIS TO CHANGE OUTLINE COLOUR
mov r0,c0
};
}
} // End of technique

technique fallback // empty fallback causes normal rendering without outline
{
pass p0 { }
}
"; // end of effect
}


starter mtl_toon_init()
{
bmap_to_cubemap(material_ToonShader.skin1);
}


action Model_Me
{
player = me;

my.material = material_ToonShader;

while (1)
{
if (key_w == on)
{
c_move (my, nullvector, vector(5 * time,0,0), GLIDE);
}

if (key_a == on)
{
c_move (my, nullvector, vector(0,5 * time,0), GLIDE);
}

if (key_d == on)
{
c_move (my, nullvector, vector(0,-5 * time,0), GLIDE);
}

if (key_s == on)
{
c_move (my, nullvector, vector(-5 * time,0,0), GLIDE);
}

wait (1);
}
}

Posted By: JvsJGameDesign

Re: DX9 Toon shader - 01/21/05 14:12

Ehm.... Do you have a videocard that supports Pixelshader 1.1 or better?
Posted By: Braxton

Re: DX9 Toon shader - 01/21/05 14:25

I don't know, how can I tell???
Posted By: Braxton

Re: DX9 Toon shader - 01/22/05 09:01

I wish there was one for lower graphics cards!!!
Posted By: JvsJGameDesign

Re: DX9 Toon shader - 01/22/05 12:39

Shaders are only for card that support them...
You can fake the toon shaders. Some people on the next forum are very busy with faking toon shaders so it works on every videocard that can run the A6 Engine:

Many faked toon models: RGames model page

What kind of videocard do you have? I have the ATI Radeon 9550 with Pixelshader 2.0.
Posted By: sixfeetunder

Re: DX9 Toon shader - 01/22/05 20:45

Hi!
Could you please explain the toon-shading effect closer?
How can the user modify thickness and color of the outline and count of colors.
ToonShading is one of the most interesting possibilities of shading - so it would be very nice to get more information of one of the "cracks" like ventilator, steem or you, single! Thanks in anyway.
Posted By: JvsJGameDesign

Re: DX9 Toon shader - 01/22/05 23:24

Yeah. Can somebody make a tutorial of it? So other people know that the command in the scripts mean etc.
Posted By: Braxton

Re: DX9 Toon shader - 01/23/05 04:37

Do your research, that is waht I am doing.

Also to answer your question, sixfeetunder, you use bitmaps to make the colors that will happen, and use code to edit the thickness.

_ Braxton
Posted By: sixfeetunder

Re: DX9 Toon shader - 01/27/05 21:00

Hallo, ich mächte meinen Teil zum "Toonen" beitragen!
Wenn Ihr für jedes Objekt eine eigene Liniendicke haben wollt, dann müßt Ihr oben im Code nach "vector vecsundir" die skill41 für die Liniendicke mit
Code:
vector vecskill41; 

definieren.

Unten bei "outliner" muß die Zeile
"vertexsahderconstant[16]=0.8 mit dem oben vordefinierten
ersetzt werden

Code:
  
vertexshaderconstant=<vecskill41>;



anschließend kann man wieder in der action mit my.skill41=float(...) eine eigene Liniendicke für das Objekt definieren.

Sorry , kenne mich nicht mit shadern aus - das war alles durch Rumgepfusche.
Die Farben kann man ändern in der Zeile def c0, rot, grün, blau,1
Posted By: Muki

Re: DX9 Toon shader - 02/03/05 05:44

Yeah, we could really use a full wmb file zipped here. If you don't wanna leave your model out in the open to be grabbed, I can donate mine. ^_^
Posted By: Wiz

Re: DX9 Toon shader - 03/28/05 21:02

I have been looking at this stuff for quite some time now, but I can't seem to figure it out. All I get is a black model with fuzzy edges. Is there anybody that has got a clue? Is there something I forget, like special setup, lightning, etc?
Posted By: Nems

Re: DX9 Toon shader - 03/29/05 06:37

Quote:

The old DX8 one worked the one time I tested it




Hi OB, do you still have the DX8 shader script?
If so, could you please share it, its something I'd really like to play with.
Thanks
Posted By: Orange Brat

Re: DX9 Toon shader - 03/29/05 06:51

It's the Simple toon shader in the wiki. It'll only function under DX8 version of 3DGS, though.
Posted By: Nems

Re: DX9 Toon shader - 03/29/05 06:55

Thanks OB,
Cheers.
Posted By: sPlKe

Re: DX9 Toon shader - 04/08/05 13:41

i really apreciate that new shader!
thankx alot!
Posted By: Format

Re: DX9 Toon shader - 04/09/05 08:23

I need old wiki toon shader (DX 8), but when i try to load wiki page it asks me for my login/pass... Please, guys, give me that shader, i'm unregistered user
© 2024 lite-C Forums