RE: [Algorithms] Scaling Models
Brought to you by:
vexxed72
From: John W. <jo...@de...> - 2000-07-27 20:49:09
|
I sat down after I sent the message and came to the conclusion that in the general case I'd have to scale the normals too and perform a normalization per normal which is completely out of the question as the impact on the performance will be too excessive. I'm either going to do one of two things. 1) Ignore it and live with the slightly wrong lighting. I don't let the relative scales differ by too much as I don't trust the Mip-LOD functions when you get high U:V coverage ratios, so the effect shouldn't be too noticeable if at all. 2) make a copy of each model and recalculate the normals. The models which get scaled are quite low poly so the extra memory shouldn't be too much of a problem. I was planning to do this anyway to maximize the number of pols in the static VBs. I use the API to do the Local->Screen xforms but all the lighting xforms is completely in software so HW TnL isn't hampered. The API never sees the normals, I pass verts through in LVERTEX format. I was just wondering what D3D\OpenGL would do if I passed the normals through which is why I didn't mail to those groups. Thanks for the HW TnL warning though. JohnW -----Original Message----- From: Tom Hubina [SMTP:to...@3d...] Sent: 27 July 2000 21:15 To: gda...@li... Subject: Re: [Algorithms] Scaling Models 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 _______________________________________________ GDAlgorithms-list mailing list GDA...@li... http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list |