Path: chuka.playstation.co.uk!news From: Craig Graham Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: Environment Mapping Date: Mon, 29 Mar 1999 09:39:55 +0000 Organization: Data Uncertain Lines: 82 Message-ID: <36FF4A6B.93A706E9@hinge.mistral.co.uk> References: <36FCF4E8.63C0@mdx.ac.uk> <7dlhjs$7a21@scea> <36FE86BD.6FE0@mdx.ac.uk> NNTP-Posting-Host: d3-s43-199-telehouse.mistral.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.5 [en] (X11; I; Linux 2.0.36 i586) X-Accept-Language: en Harvey Cotton wrote: > > Nathan Miller wrote: > > > > >Can anyone help me with implementing environment mapping? I asked this > > >a while back and I got some help, but I've still been unsuccessful. > > >I've tried looking this topic up on the net, but found nowt. I know > > >the basics of the technique but I don't fully understand how you > > >go about applying a texture around an object. Any help with this would > > >be greatly appreciated. > > > > Another technique is to use two models, one with the env map, and the other > > as whatever you are mapping. Unfortunately, this technique causes sorting > > problems on the psx. But, you might want to try it and see. You will still > > have to do y rotation for the texture, but the second model can be of a > > lower polygon count than the first. > > This is the technique I am working towards. I still have a slight lack > of > understanding of environment mapping - but I am getting closer! > Apparently > the technique you describe is the method used by Dr Steve Collins (who > wrote that fancy car demo). He used two models, one of the car and the > other a transparent environment mapped shell that overlays the model. > > > >Also, can anyone recommend any good 3d books? I'm looking for a graphics > > >book that covers engines and effects (featuring environment mapping > > >amongst other things) and something with a bit of C code in as well. > > >I will be using the book for research. > > > > The best place for up-to-date info like this is on the web. But I heard > > that Andre LaMothe is comming out with a new book an 3d programming next > > month. You should check out amazon.com or barnsandnoble.com for more info. > > Hope it works out... > > I tried checking the web for information on environment mapping, but I > couldn't find anything. However, this book sounds interesting. I've got > LaMothe's excellent Games Programming in 21 days. Thanks for the tip! I don't know of any game that does true environment mapping (as it takes ages to calculate). However, I did post some code ages ago that would do 1 or 2 axis mapping single texture mapping for a TMD model made up of textured gourard poly3's - all it would take to make it work as an overlay would be a second copy of the object (sharing the same normal and vertex segments as the mapping overlay) to be sorted first. I seem to remember that someone else also posted their code to do the mapping as well (with a slightly different algorithm). The basic approach to the mapping is to take each vertex normal (important, you must use textured gourard poly's so that the vertex normals are available) then rotate it using the local to world matrix. Then scale the rotated vector to be length ONE, and finally use: texture_u=(rotated_scaled_normal.x * (texture_width-1))/ONE; texture_v=(rotated_scaled_normal.y * (texture_height-1))/ONE;  Repeat for each vertex normal and cache the results in a lookup table indexed via the vertex number. Then go through the poly's section filling in the texture UV's of each primitive from the lookup table you generated (each vertex will have a UV pair, and the poly hold the index of the vertex). For a bit of extra pace (on models of < 512 vertices) put the UV cache in the scratch pad. If you go back over old messages you'll find my code that does just this.... > Harvey | ICQ: 4269478 Craig.