Sign in to follow this  

Cel Shading effect

This topic is 4376 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I want to give my graphic engine a cel-shaded effect (I'm working with C++ 6.0 and DirectX 9.0), but I don't know how to create this kind of look inside my own engine. I tried to export it from Maya, but I lose the ink outline. =S Besides that, all the textures in my engine look really bad (looks like they have 2x2 pixels when they are 1024x768), don't know why... If it helps, I may post my code here... Can anyone explain how I can create this cel-shaded effect, and make my textures look a little better, please? =) Thanks everyone, Merry Christmas...

Share this post


Link to post
Share on other sites
Cel shading comes in a lot of different flavors. If you are using shaders, you can download and check out my showcase entry linked in the signature for a simple gooch shader with an outline. The units use the effect 'Gooch.fx', which you can find in the Data/Effects subfolder of the main directory. Feel free to use the .fx file if it will help you out.

For your textures you'll probably have to post some code or pictures, but as a first guess do you know if you are using point sampling to sample the texture? This often leads to blocky looking textures if the texels are used to color an area that is larger than a screen size pixel. Its just a guess though...

Share this post


Link to post
Share on other sites
I'm not so sure how you attempting to create the cel-shaded affect in Maya, but if you need a good overview and some sample code to guide you, I just finished writing a cel-shaded renderer and have an overview and tutorial here

If you need more specific help, maybe you should post more detail about what the problem is?

Share this post


Link to post
Share on other sites

Thanks for your posts and for the tutorial, it really will help in the creation of the cel shaded effect... =D

Well, about the textures, I'm using this piece of code to manage the texturing and normals in my engine (as I said before, I'm using DirectX 9.0c):

Device->SetRenderState(D3DRS_NORMALIZENORMALS, true);
Device->SetRenderState(D3DRS_SPECULARENABLE, true);
Device->SetRenderState(D3DRS_ALPHABLENDENABLE, true);

Device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
Device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);

Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
Device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);

I believe the problem is somewhere in here, but I really don't know were I should change the code to make it look better...

Thanks again... =)

Share this post


Link to post
Share on other sites
hi,

i can not help you with the cell shading,
but I want to say, that 1024x768 is a bad resolution
for a texture...
You should use power of 2 sized textures,
some other member's in this board had big troubles with other
resolutions.
And is 1024x1024 not a bit to big (If you use many textures...)

Bye,
Marc

Share this post


Link to post
Share on other sites

Hmm... I'm using pre-rendered cenarios, so it doesn't really have a lot of textures... But do you think that's the reason they come out so blocky? =
Thx...

Share this post


Link to post
Share on other sites
Quote:
Original post by Sagito

Hmm... I'm using pre-rendered cenarios, so it doesn't really have a lot of textures... But do you think that's the reason they come out so blocky? =
Thx...


I'm not sure I understand what you mean when you say that you are using prerendered scenarios? I think I picture of the problem would be very helpful. :)

And so we're on the same page, you are using a shade table type approach to celshading where you do an intensity lookup based on the dot product of the light and normal vector? Or are you using some other sort of algorithm?

Share this post


Link to post
Share on other sites

Hmm... I'm using pre-rendered scenarios, like for example those of Syberia or Syberia II. Here is a pic from this game: http://www.armchairempire.com/images/Reviews/pc/syberia/syberia-4.jpg

Right now, I'm trying to write my own vertex shader to get this effect, and setting it with IDirect3DDevice9::SetVertexShader(...). But the textures still look like blocks of 2x2 pixels... =S Do you think it has anything to do with the code I posted before?

Share this post


Link to post
Share on other sites
Don't use Mip-mapping fo rthe background image, mip-maps are a chain of textures, each 1/2 the resolution of the last. This increases quality and speed in rendering textures at a smaller-than-actual-size scale. In your case, though, creating a mip-map chain isn't wanted (it requires more video memory) and is probably rescaling your 1024x768 texture to 512x512 (or something similar) resulting in a less-detailed look.
After you fix the low-res texture problem, it might still look "blurry", or not quite as crisp as it should. There's an article which explains mapping texture pixels to screen pixels on a quad.
You'll want to look into this if the resulting texture isn't as crisp as the original.

You'll also want to post a picture of the actual problem that you're having. Ya know, take a screenshot. This will help people diagnose your problem much more efficently.

-Michael g.

Share this post


Link to post
Share on other sites
Thanks for the link... =) Here is the texture trouble:

http://img529.imageshack.us/my.php?image=errosdetextura9cd.jpg

All my textures look like those, with very low-res... =S

Share this post


Link to post
Share on other sites
What size textures are you using? I think the problem is that you are using small, non power-of-two textures which results in the streching and blurry effect.

Hth,

Share this post


Link to post
Share on other sites
After marcjulian's post, I started using 1024 * 1024 textures (which are huge, I think), instead of 1024 * 768, and the result is still the same, nothing changed... =\ I checked DX Flags, and tried several combinations, however, it only got worse, so I got back to LINEAR...

Thx...
Tiago...

Share this post


Link to post
Share on other sites

Ok, finally, I got my vertex shader working, including the code to compile it from a file... It works fine for textures, but the "ink" outlines have a strange behaviour... =S

http://img353.imageshack.us/my.php?image=error1ip.jpg

Any idea why? I will post the code, if you think necessary...

Thx again...
Merry Christmas.

Share this post


Link to post
Share on other sites
it looks to me like you may be addressing your index or vertex buffer wrong. I know I have gotten a similar effect when I address a vertex that is invalid memory it determines the value to be some point far off in space. My recommendation would be to check that first.

Share this post


Link to post
Share on other sites
Not to draw attention off topic at all, but I have a question I have wanted answered just for the sake of curiosity. Is there any specific method to drawing or creating the textures you make when you are turning them into cell shaded anyways? Do you draw the textures as though you are making a cartoon (by that i mean adding the specular lighting beforehand). How much do you concentrate on details, and how much do you leave to the shader? etc.

Basicaly im just asking this from the standpoint of developing the art that we will be plugged into the shader at a later time. Im presuming you still do use textures, though honestly I have no clue here.

Curiously
Richard

Share this post


Link to post
Share on other sites
Hmm... I will check that, thanks a lot... =) Anyway, I will post the code here as soon as I can (it's in another computer), because it's likely that I can't find the bug (don't really have much experience...). =
Thx... =D

Share this post


Link to post
Share on other sites

This topic is 4376 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this