Optimization of toon shading with vertex shader

I’m still try to render toon shading.

Here is the base alorithm:

_ Render only filled front faces with toon texture.
_ Render only back faces in wire frame with size of 10 for example in black.(this render the silhouette)

With two pass, the algorithm works well.

Now, i try to render the scene in one pass!
I set the toon texture with GL_MODULATE.
In the vertex program, i put white color in the register for front face color
and black color in the register for back face color and then render the scene(front filled face and back face in line).
The problem is that back face(in line) are in toon shading and i want them black(for the silhouette).

When did back face color are used in OpenGL?
Do i have to activate an extension or OpenGL lighting system??



Thanks to help me!!!

I have tried what you gave me but nothing change.

I have also called glEnable(GL_LIGHTING); but no effect. Moreover , i don’t want to use GL_LIGHTING because it’s not fast enought.

The problem still exist…

actually twosided lighting isn’t the right way to do siluette detection for toon rendering.
on new hw i would use fp’s for this task (take a look at the NPR-demo from the ATI-website)
when you want to remain compatible with “old” hw below dx9 level, i suggest detecting the siluette edges on the cpu, and draw the siluettes only.
take a look at the stencil-shadow-volume extrusion alogrithm. simply use the viewport position instead of the lightposition to determine the siliette edges and then simply draw them using GL_LINES or - more sophisticated - with screenaligned quads.

try this links for more general infos about toonshading: http://www.gamedev.net/reference/articles/article1438.asp http://www-evasion.inrialpes.fr/people/Philippe.Decaudin/Cartoon.html http://developer.nvidia.com/object/1Pass_Silhouette_Rendering%20.html http://developer.nvidia.com/object/silhouette_rendering.html http://developer.nvidia.com/object/Cartoon_Rendering_GeForce_256.html http://developer.nvidia.com/object/Toon_Shading.html

for a very good explaination of the siluette detection algo i suggest (and btw. after reading this you can also add shadows to your scene ) :
http://developer.nvidia.com/object/inf_shadow_volumes.html http://developer.nvidia.com/object/robust_shadow_volumes.html

…or just google for yourself

Yeah thanks for these links!!!

I have already implement silhouette by texturing.

I want to optimise so in one drawing, the model will be in toon shading.

I have already thought about your algorithm. II want implement the both(mine and your) to know the one who is the faster.

_ one rendering front filled and back line.

_ one rendering with back face culling and front face filled and then compute silhouette and render it in line.

Wihch one is faster? : hard to know but i think that the first is faster. Wathever i want implement both.

If someone want the prog, i can send him if he want to see what id the problems.