(HLSL) Cel (Toon) Shading

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I'm pretty sure they are only available in GLSL...
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
oldskoolPunk
Posts: 199
Joined: Wed Nov 29, 2006 4:07 am

Post by oldskoolPunk »

ahh! Now I understand. Good work by the way.
Signature? I ain't signin nuthin!
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Yes but I am using the same outlining algo that you tried and threw away :P That's why I suggested using a post process for the outlines instead. Did you end up using something similar to that yourself?
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
oldskoolPunk
Posts: 199
Joined: Wed Nov 29, 2006 4:07 am

Post by oldskoolPunk »

Still reading.

Learning convolution is convoluted !

Lol not really. It seems image processing is the easiest form of shader programming so far. Dont know why I have put it off for so long. One shader can do all kinds of filters by just changing the matrix.
Signature? I ain't signin nuthin!
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

Hi
I have a little problem...
I want to use transparent textures in my model with this shader, and it works, but just partially.

Image

As you can see, it doesn't just make the model at that point transparent, but the other poligons behind it too.
in my model, there is the skin group, and in top of that there is the hotpants group.
probably its because it calculates the texture of that place (the toon), and gives the alpha value (if i set always the alpha to 255, it isn't transparent, but i can see the full model, so probably its because this), so that place become transparent..

can you help me?
Image
Image
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

in my model, there is the skin group, and in top of that there is the hotpants group.
:P

Ok first make sure you are using EMT_TRANSPARENT_ALPHA_CHANNEL (Without the _REF) as your base material.

Next you will have to change the last line of the shader to

Code: Select all

return(float4(saturate(lightColor * texCol + specular4).xyz, texCol.a));
and it should work correctly.

About the things behind it being invisible, etc, you may have to try enabling/disabling ZWriteEnable on the mesh. If it is too much trouble in the end I recommend just drawing the hotpants as a seperate object.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

thanks for the reply.
i changed that line, and nothing happened. xD
same us before... what does it do? xD

enabling zwrite did nothing (probably it was enabled before), disabling it made my model quite ugly.
so no good :(
Image
Image
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Ok it seems you will have to draw the hotpants separately, just load them as a separate scene node.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

thats what i can't do.
it will be an rpg game, so all of the clothes has to be the same format.
Image
Image
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

It's a transparency problem B@z. You usually need to draw as seperate objects to get around this.

If you still insist. Try using EMT_TRANSPARENT_ALPHA_CHANNEL_REF as a last shot. Also maybe playing around with the 1 Texture Blend material set as the base will get you something.

Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
shadowking97
Posts: 8
Joined: Mon Mar 09, 2009 5:55 am
Location: TX

Post by shadowking97 »

Just split the pants into a different mesh. Have it copy the position, rotation, and scale of the girl, play the same animation, and if you have everything right, The vertexes of both meshes will line up so it looks like one. You can do this with all your clothes, and after youve loaded all the clothes files, you can change the settings on the ones you need to.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

i know it, but it wont work.
coz there will be clothes what puts texture in the body model (for example tatoos and so on), so i HAVE to put it into the same model..
ohh and no, i dont want to save the clothes, and the clothes body in different models...
with this, i have around 60 model, and this is the begining.. if i put it seperated, it will be 120 xD no thanks :D

EMT_TRANSPARENT_ALPHA_CHANNEL_REF didnt do anything to me... maybe im using it wrong? xD
Image
Image
grumpymonkey
Posts: 222
Joined: Mon Jan 19, 2009 10:03 pm
Location: Miami, Florida
Contact:

Post by grumpymonkey »

I used to do this a long time ago when i used gamemaker, but not using this method.
what i did was this:

first, i got my regular model, and then loaded it with the texture, then I loaded another model with all the faces backwards, and i drew it ontop of the original one. I turned on back face culling(so that only the front of the faces are visible), and set the second models texture to just be completely black.

this method works, but i dont recomend it for complicated meshes as there will be double the amount of polygons as a regular model.

here is a crappy diagram of what i mean:
GREEN = VISIBLE
RED = INVISIBLE
O = CAMERA

O--> || ||

the player can only see the parts of the second mesh that are behind the oribinal mesh, so regardless of the angle it will always be outlined correctly

now, about the actual SHADING, i have no clue how to do that since gamemaker's 3D had really crappy shadows, and im still new to irrlicht(started a week ago)
Image
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

yep its for outline, but as you said it doesnt work with complex models...
so wont work with players xD
and it wont also work with concave models. so out of question xD
Image
Image
nickle
Posts: 17
Joined: Sun Feb 15, 2009 5:29 pm

outline extraction, edge detection

Post by nickle »

XEffects and render to depth map then add a post processing effect that compares the depth of different pixels and makes them dark if theres a reasonable difference, quite similar to simple ssao shader
by different pixels, do you mean the neighbouring 8 pixels depth? If so, I also checked out the screenQuad shader, I think the postprocessing shader for edge detection should have a input of the current screenRes in order to get the neighbouring 8 pixels texcoords. If not, could you show us how this could be done with more details? An edge detection postprocessing in a general purpose (not only cel shading) is also very useful. I am not so sure how to get this done without modifying the current screenQuad shader. [/quote]
Post Reply