Open neilmendoza opened 11 years ago
ofEnableLighting is enabling GL_NORMALIZE which should fix that.
I just assumed that ofDrawBox should produce a box with correct normals. If people are writing their own lighting code they may not enable GL_NORMALIZE as there's a performance hit to it.
Hey Neil!
This is a tricky one: if we don't use scaling for ofDrawBox, we'd have to get a new mesh primitive for every box drawn, which would totally zilch any performance gains for not using GL_NORMALIZE.
You can, however, use glEnable(GL_RESCALE_NORMAL) which is more performant in case your modelView Matrix is orthogonal (= as long as there is no shearing).
I'm seeing another issue with ofBoxPrimitive; is it possible that the normals are inverted? If you have a normal shader at hand, could you check the normals you get drawn by comparing ofDrawBox to ofDrawSphere, @neilmendoza ?
Also note that if you are using the ofGLProgrammableRenderer, the normals in an ofVbo are submitted in a more modern way, where they will automatically be normalized when submitted to GPU memory.
See: https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/gl/ofVbo.cpp#L689
we could have a normalizeNormals method in of3dPrimitive that way the default will be fast enough to draw lots of primitives using ofDrawBox but you can define your own primitives for using them with custom settings
ofDrawBox() uses scaling for it's size so normals are also scaled and any scene with lighting will end up looking wrong.