Using Normals for backface-culling...

Blitz3D Forums/Blitz3D Programming/Using Normals for backface-culling...

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

BTW.:
If I Do this, instead, it works perfectly...

Function drawSphere()
For i% = 0 To 15
For j% = 0 To 7
x0# = +rx#(i%, j%) * 100.00 + 512.00
y0# = -ry#(i%, j%) * 100.00 + 384.00
x1# = +rx#((i% + 1) Mod 16, j%) * 100.00 + 512.00
y1# = -ry#((i% + 1) Mod 16, j%) * 100.00 + 384.00
x2# = +rx#((i% + 1) Mod 16, (j% + 1) Mod 9) * 100.00 + 512.00
y2# = -ry#((i% + 1) Mod 16, (j% + 1) Mod 9) * 100.00 + 384.00
x3# = +rx#(i%, (j% + 1) Mod 9) * 100.00 + 512.00
y3# = -ry#(i%, (j% + 1) Mod 9) * 100.00 + 384.00
If Abs(x2# - x3#) < 0.01 Then
dx1# = x2# - x0#
dy1# = y2# - y0#
dx2# = x2# - x1#
dy2# = y2# - y1#
Else
dx1# = x3# - x1#
dy1# = y3# - y1#
dx2# = x3# - x2#
dy2# = y3# - y2#
EndIf
bf# = (dx1# * (dy2# - dy1#)) - ((dx2# - dx1#) * dy1#)
If bf# > 0.00 Then
;If rnz#(i%, j%) > 0.00 Then
If (j And 1) Then
Color 255, 0, 0
Else
Color 0, 255, 0
EndIf
Line x0#, y0#, x1#, y1#
Line x1#, y1#, x2#, y2#
Line x2#, y2#, x3#, y3#
Line x3#, y3#, x0#, y0#
EndIf
Next
Next
End Function

Why is that?
I hope it is just some programming error of mine, as opposed to a flaw in the algorythm itself.
(In other words, I am dtrying to use the rotated normals for lighting the polygons properly, as well as performing backface-culling.
But, as far as I can tell, and if there is no "programming error" or typo in the code, I must assume that the rotated normals are not accurate enough for performing back-face culling.
If that is the case, what kind of algorythm should I employe?)
Thanks a lot,

Rui Barbosa Jr.