Re: [Algorithms] Scaling Models
Brought to you by:
vexxed72
From: Tom H. <to...@3d...> - 2000-07-27 20:15:06
|
At 05:06 PM 7/27/2000 +0100, you wrote: >If you set a scaling matrix as part of the transformation pipeline what >happens to the normals? >I currently use D3D\OpenGL to do the transformation but use my own lighting >code. If I set a scaling factor to each of the 3 axes the angles of most of >the faces in the model will change (unless the scaling factor is the same >for all three axes). An extreme example is when XSc=ZSc=1.0f; YSc=0.0f; All >normals will either become 0,0,0 (for triangles with a normal perpendicular >to the Yaxis) or 0,1,0 for all other normals. > >Rebuilding the normal list is not an option as the models are shared >multiple times with different scalings. > >Anybody else encountered this problem? And how does D3D\OpenGL cater for >this? In GL the normals are scaled and rotated by the modelview matrix (homogenous matrix stuff ... translations are ignored). GL allows you to normalize the transformed normals with: glEnable(GL_NORMALIZE); This does come with an added per-normal cost, but on T&L cards like the GeForce, the operation is done by the hardware so you don't lose the ability to use hardware transforms. I don't know if there is a similar operation under DX, but it seems likely. Something just dawned on me though, you use the API do the transforms, but you do your own lighting ... If you're querying the API for the results of the transformations you're really going to ruin performance on hardware T&L cards. If you don't need the transformed coordinates to do your lighting, then you probably don't need to send normals to the API at all. They're only used for lighting and some of the texture coordinate generation modes (spherical I think). Specific OpenGL and Direct3D issues should be taken to their respective mailing lists. Tom |