Thanks Warpy!
This code works perfect (light vector and colors will be initiated once in the near future):
I also changed the quad positions used because they were slightly wrong (topleft = A, topright = B, bottomleft = C, bottomright = D).
I still haven't found the best light position, some seem to make the color change too intense, some not enough.
http://img252.imageshack.us/img252/2800/earlywithshadingmoew5.png
http://img252.imageshack.us/img252/7167/earlywithshadingdebuglizx0.png
This code works perfect (light vector and colors will be initiated once in the near future):
Local lvec:TVec3, light:Float, dp:Float lvec = New TVec3.Create(1 / Sqr(3), - 1 / Sqr(3), 1.0) Local normal1:TVec3, normal2:TVec3, normal:TVec3 normal1 = _quad.topright.Copy() normal2 = _quad.bottomright.Copy() normal1.SubtractVec(_quad.topleft) normal2.SubtractVec(_quad.topleft) normal = TVec3.CrossProduct(normal1, normal2) normal.Normalize() dp = normal.DotProduct(lvec) If dp < 0 Then dp = 0 light = dp * 0.4 + 0.6 SetColor(light * 255, light * 255, light * 255)
I also changed the quad positions used because they were slightly wrong (topleft = A, topright = B, bottomleft = C, bottomright = D).
I still haven't found the best light position, some seem to make the color change too intense, some not enough.
http://img252.imageshack.us/img252/2800/earlywithshadingmoew5.png
http://img252.imageshack.us/img252/7167/earlywithshadingdebuglizx0.png