Jump to content
  • Advertisement
Sign in to follow this  
Sagito

Cel Shading effect

This topic is 4688 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
Advertisement
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
Ok, I took a SS from my engine, but I don't know where can I post it, so everyone could see it... =S Any idea (sites, servers,...)?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!