Path: chuka.playstation.co.uk!news From: Harvey Cotton Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: Environment Mapping Date: Mon, 29 Mar 1999 18:20:05 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 53 Message-ID: <36FFB645.61B4@mdx.ac.uk> References: <36FCF4E8.63C0@mdx.ac.uk> <7dlhjs$7a21@scea> <36FE86BD.6FE0@mdx.ac.uk> <36FF4A6B.93A706E9@hinge.mistral.co.uk> NNTP-Posting-Host: stu-dialup9.mdx.ac.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.04Gold (Win95; I) > 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.... > > Craig. Thanks for this! I did have your original source code that you posted a while back, but until now I didn't fully understand it. I believe the playstation 2 can do true environment mapping. I remember seeing the gran turismo technical demo with proper reflections off the cars. Or was I imagining things? Anyway, many thanks. Harvey.