MMX Vs. Floating Point Question submitted by (07 June 2000) | Return to The Archives

| Hi, I'm using DirectDraw to write a 3d software-rendering engine, and I've been using MMX for vertex colouring. Now, I wanted to use the MMX vertex colouring for a lighting solution, but the problem is that if I want textures on the polygons as well as vertex lighting, I need to do my texture filling in MMX, but I can't see how to do texture correction without using floating points. If I try to use floating points in combination with MMX I get horrible crashes.
Do I need to do my lighting in a separate pass from the texturing, or is there some way to work around this?

| Performing multi-pass rendering in software is usually not a good idea. At the very least, it's an extra write to and a read from the frame buffer. By "texture correction", I will assume you mean perspective correction which can be done using fixed-point math. You'll need quite a bit of accuracy here, so rather than performing 1/U and 1/V, you can use (0xFFFFFFFF/U) and (0xFFFFFFFF/V). Follow this up with a couple shifts to bring your results into range (how much to shift depends on the initial precision of U and V.)
Response provided by Paul Nettle

This article was originally an entry in flipCode's Ask Midnight, a Question and Answer column with Paul Nettle that's no longer active.

Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.