Toon lighting!
Hi
I''m interested in different ways to achieve a cell-shading effect. I''ve had a look at Nehe''s tutorial using 1D textures, but my problem is that I want everything rendered in this style (rooms, terrain, whatever) without losing too much rendering speed. Calculating the textures for every frame means you can;t use display lists(?), but what about vertex arrays? I thought maybe there is a way in opengl to alter the way lighting is calculated to give only a few lighting values (dark, medium, bright) rather than the usual ''smooth'' lighting.
If anyone has any ideas please let me know.
Thanks
the only way is to either calculate the lighting your self witht he 1d texture or use vertex shaders and the 1d texture method(may be called somethign different in opengl).
remember you dont need the edges around the meshes, since that causes probably the largest performence hit. rooms, terrain, etc will all use lightmaps and thus you can just posterize the light map data and your set. only dynamically lit objects (ussually only models and level areas lit by rockets or other light sources).
remember you dont need the edges around the meshes, since that causes probably the largest performence hit. rooms, terrain, etc will all use lightmaps and thus you can just posterize the light map data and your set. only dynamically lit objects (ussually only models and level areas lit by rockets or other light sources).
The Nehe tutorial really needs an equation saying what he is doing!
Anyway, you should be able to use a sphere map, unless the filtering is a problem. Equations to use, e.g., are at http://www.webnation.com/vidirep/panels/renderman/shaders/toon/toon.phtml
Anyway, you should be able to use a sphere map, unless the filtering is a problem. Equations to use, e.g., are at http://www.webnation.com/vidirep/panels/renderman/shaders/toon/toon.phtml
I think this is what you want : Take a look at http://farb-rausch.de under the "products" section, and download "ART (FR-010)" and the source of ART. I think you''ll like this...
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.
I was wondering about this too... one idea I had was to used (that''s right) 256 palettized colour without dithering. If you chose the right colours you could get that cartoony effect. I bet there''s a whole slew of problems with this approach, but that''s just my two cents worth.
"No break 'till you die!" - Mr. Foster, my English teacher
Thanks for the replies
NaliXL - that''s a cool demo, i like it
I had thought about using 8 bit colour, but not palettized, do you know how that would be done, and can you still use textures with a palette?
What would be ideal, would be to set something when the opengl stuff is initialized that makes everything look cartoony?
I know this sounds stupid, i know there isn''t a glEnable(GL_TOONY_LOOK) command, but maybe something using the various buffers (accumulation buffer?) to process the whole image after rendering to reduce the number of colours.
I know the answer''s out there somewhere!
More ideas please
NaliXL - that''s a cool demo, i like it
I had thought about using 8 bit colour, but not palettized, do you know how that would be done, and can you still use textures with a palette?
What would be ideal, would be to set something when the opengl stuff is initialized that makes everything look cartoony?
I know this sounds stupid, i know there isn''t a glEnable(GL_TOONY_LOOK) command, but maybe something using the various buffers (accumulation buffer?) to process the whole image after rendering to reduce the number of colours.
I know the answer''s out there somewhere!
More ideas please

It works!!
But only at 1fps
Using the accumulation buffer to divide colour values by 400 and then multiplying again by 400 means the values lose precision giving a beautiful cartoon effect. But my geforce 2 mx seems to take nearly a second to carry out those two operations.
Shame really, it looks sooo good
But only at 1fps

Using the accumulation buffer to divide colour values by 400 and then multiplying again by 400 means the values lose precision giving a beautiful cartoon effect. But my geforce 2 mx seems to take nearly a second to carry out those two operations.
Shame really, it looks sooo good
Yes finny, you've got the right method. Dividing the colours and then multiplying is the most universal method to reduce colors afaik.
Though, you have to take care that [future] framebuffers won't be 128 bpp otherwise you have to divide and multiply even more
Accumulation buffer is EXTREMELY slow because it is done in software. Nowadays, almost NO graphics card support that feature because it wastes ALOT of memory.
Anyway, you can simulate the behaviour of the accumulation buffer with other techniques (like render-to-texture) that are supported in hardware by most of todays graphics cards. If you want to know more, I'm sure lots of guys here can tell more about it
As a side note, have you tried something odd like getting a 8bpp (R2-G2-B2-A2) framebuffer ?
Since you can specify either a 16bpp or 32bpp framebuffer, it would be have immediate effect to use 8bpp. Then the only you'd need would be disabling dithering. Just a thought...
[edited by - vincoof on May 22, 2002 4:06:03 AM]
Though, you have to take care that [future] framebuffers won't be 128 bpp otherwise you have to divide and multiply even more

Accumulation buffer is EXTREMELY slow because it is done in software. Nowadays, almost NO graphics card support that feature because it wastes ALOT of memory.
Anyway, you can simulate the behaviour of the accumulation buffer with other techniques (like render-to-texture) that are supported in hardware by most of todays graphics cards. If you want to know more, I'm sure lots of guys here can tell more about it

As a side note, have you tried something odd like getting a 8bpp (R2-G2-B2-A2) framebuffer ?
Since you can specify either a 16bpp or 32bpp framebuffer, it would be have immediate effect to use 8bpp. Then the only you'd need would be disabling dithering. Just a thought...
[edited by - vincoof on May 22, 2002 4:06:03 AM]
Not entirely related, but you guys might like to take a look at the recently released movies for Zelda on the GameCube. Lots of nice toon rendering!
http://www.nintendo.com/games/gamepage/gamepage_main.jsp?gameId=823
Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
http://www.nintendo.com/games/gamepage/gamepage_main.jsp?gameId=823
Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Hey thanks again for your replies
I now have the effect I want at 145fps!!
What I''m doing is...
After drawing everything i want ''toon-style'', I''m drawing a rectangle (the same size as the window) using:
glBlendFunc( gl_zero,gl_src_alpha);
glColor4f(0.0, 0.0, 0.0, 0.09);
This reduces the colour values sufficiently to lose precision (depends on colour depth of course), then drawing another rectangle to brighten everything again
So by drawing just TWO QUADS you can do some excellent effects without losing performance
Hope this is of use to someone and thanks for all your suggestions
I now have the effect I want at 145fps!!
What I''m doing is...
After drawing everything i want ''toon-style'', I''m drawing a rectangle (the same size as the window) using:
glBlendFunc( gl_zero,gl_src_alpha);
glColor4f(0.0, 0.0, 0.0, 0.09);
This reduces the colour values sufficiently to lose precision (depends on colour depth of course), then drawing another rectangle to brighten everything again
So by drawing just TWO QUADS you can do some excellent effects without losing performance
Hope this is of use to someone and thanks for all your suggestions
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement