Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

siddim

cellShading color index?

This topic is 5687 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, i am trying to figure out some code out of the cell shading article of http://www.gamedev.net/reference/programming/features/celshading/ everyting is working fine until i try to use the color instead of the 1d texture. i don''t understand how i can have the sharp lighting effect (the cel shading effect). Do i have to redefine the color index or something? because right now when i am mapping the light value from my array(0-31) that contain mainly 0.0 - 0.4 and 0.8 value the polygon only merge the color from one index to the other instead of having a clean separation. any solution? thanks siddim

Share this post


Link to post
Share on other sites
Advertisement
If you want to replace 1D texturing by OpenGL's standard colouring, I'm afraid you won't get the desired effect.

>> because right now when i am mapping the light value from
>> my array(0-31) that contain mainly 0.0 - 0.4 and 0.8 value
>> the polygon only merge the color from one index to the
>> other instead of having a clean separation.
I don't see very good the problem. Could you please post a screenshot ?

[Edit]
I've read the article again and now I think I see what you mean, if you're talking about cel-shading over a textured model.
The Sharp Lightmap is based on the fact that interpolating integers do not keep fractional parts of floating-point numbers. Unfortunately, there is no such control over OpenGL since interpolation is done regardless the color is an integer or not, and unless you post-multiply (multipass, thus slow and awful). Moreover I'm not sure that Direct3D could do it either.
In other words, this algorithm may not work.

The best you could do is multitexturing which is really straight-forward according to the fact that you already have a working cel-shading rendering for texture-less models.

[edited by - vincoof on March 25, 2003 8:41:44 AM]

Share this post


Link to post
Share on other sites
here''s a screen shot of the normal rendering without any shading:

http://www.thinbox.ca/_images/goliath/noShading.jpg

and here is the version with the cell shading tentative that is''n working:

http://www.thinbox.ca/_images/goliath/NotWorkingCelShading.jpg

the cell shading is working but only if we scale the model on the cell pass:
http://www.thinbox.ca/_images/goliath/scaleCelShading.jpg

but this cause the cell to display a little off the model and will produce bad display on concave model:

http://www.thinbox.ca/_images/goliath/scaleCelShadingMistake.jpg

so you think we better go with multitexturing?

siddim


Share this post


Link to post
Share on other sites
ok. if you scale the model, that means you are using a multipass technique and you are experiencing z-fighting issues.

If I get the idea right, you have 2 passes :
- the first pass renders the textured model,
- the second pass renders the cell-shaded model.

In that case, you need to setup a special depth test for the second pass, but you don''t need to scale :

renderTexturedModel();
glDepthFunc(GL_EQUAL); // set depth test to equality
renderCelShadedModel();
glDepthFunc(GL_LESS); // restore depth test

Yes it would be better with multitexturing. It would be faster and there would be no depth artefact. The only con is that the multitexture extension must be supported, which is not guaranteed on all OpenGL-compatible cards (although more than 95% graphics cards support multitexturing today).

Share this post


Link to post
Share on other sites
i just enable the depth call you tell me, and it work fine, but still i think i will try the multitexturing because the way we do it right now can can''t have darker color for the shader, or i have''n try enough

http://www.thinbox.ca/_images/goliath/CelShadingWithDepth.jpg

thanks alot.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
here''s the blending function, have''n play alot with it yet.

glBlendFunc(GL_ONE_MINUS_SRC_COLOR,GL_ONE);

Share this post


Link to post
Share on other sites
To get darker, you could call
glBlendFunc(GL_DST_COLOR, GL_ZERO) or glBlendFunc(GL_ZERO, GL_SRC_COLOR), both for exactly the same result.

Share this post


Link to post
Share on other sites
nice,

it work fine now, thanks

http://www.thinbox.ca/_images/goliath/CelShading.jpg

you beleive that multitexturing is better and faster then this method?

Share this post


Link to post
Share on other sites
Faster... no doubt multitexturing is.
Better ? That''s up to you to evaluate what "better" is !

Do you target a minium hardware ? If the program will only run on graphics cards that have (at least) two texture units, you should really use multitexturing.
Your application can speed up up to twice as fast (generally, 30-40% faster).

For the moment if the speed is good enough you can keep your rendering as is, but in the future if you want to optimize the gfx engine this will be one of the first things you will have to do.

Share this post


Link to post
Share on other sites

  • 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!