#### Archived

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

# silhouette rendering

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

## Recommended Posts

Hi. I am using silhouette rendering and cel-shading in my game to make it look cartoon-like. To speed up my code I use triangle strips to simulate lines, because my card does not have hw-acceleration for lines. That''s why I have to determine myself whether a triangle is front-facing the camera or not. But that doesn''t work well, it seems like it is a little inaccurate of I am using the wrong coordinates. Here is my code: First the transformations: VERTEX Vt; // the camera is behind the player Vt.x=3.0*sinyrot; Vt.y=3.0*(float)sin(lookupdown*piover180); Vt.z=3.0*cosyrot; // calculate translations and rotations. xtrans = -xpos-Vt.x; ytrans = -yheight-1.35f-Vt.y; ztrans = -zpos-Vt.z; sceneroty = 360.0f - yrot; // Rotate and Translate glRotatef(lookupdown, 1.0f, 0, 0); glRotatef(sceneroty, 0, 1.0f, 0); glTranslatef(xtrans, ytrans, ztrans); then the backface-stuff in the drawing routine: int backfacing(VERTEX v,VERTEX n,float x,float y,float z) { VERTEX v2; v2.x=v.x-x; v2.y=v.y-y; v2.z=v.z-z; float l=sqrt(v2.x*v2.x+v2.y*v2.y+v2.z*v2.z); v2.x/=l; v2.y/=l; v2.z/=l; float DOT=Dot(v2,n); return (DOT>0.0); } Call the function: if(backfacing(trigz[2].midpoint,tris[trigz.ID].normal,-xtrans,-ytrans,-ztrans)) draw outlines What''s wrong?

1. 1
2. 2
3. 3
4. 4
Rutin
14
5. 5

• 10
• 11
• 14
• 10
• 25
• ### Forum Statistics

• Total Topics
632651
• Total Posts
3007657
• ### Who's Online (See full list)

There are no registered users currently online

×