🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How much is too much?

Started by
2 comments, last by GameDev.net 24 years, 7 months ago
Well, I can't really answer your first question (the one where 'how many divides is too much'), but I can give you some pointers.
First of all, if you have to do a lot of division, instead of dividing, multiply by the reciprocal. Multiplying is a lot faster than division.

reciprocal = 1.0f / value;

(x * reciprocal) == (x / value)

For texture mapping, you could precalculate the inverse Z1 and Z_delta, and linearly interpolate along there, and that way you wouldn't have to divide for each pixel, only multiply.

Also, for software perspective correct texture mapping, I recommend using the bilinear perspective correct method. This is where you recalculate the the correct coordinates every 8 or 16 pixels and then linearly interpolate between the coords. This is much faster and yields suprisingly decent results. This is what was done in the software rendering portions of Quake and Quake 2.

[This message has been edited by CodeDemon (edited November 22, 1999).]

Advertisement
Thanks for the reply. I am aware of the various texture mapping techniques that can be used to avoid the divides. I was really just using it as an example so as to get a handle on my question whic still remains. Can today's Pentium Computers handle one divide per pixel in the rendering phase of a 3d engine and still have the application run in real time??

Thanx all.

As I am fairly new to 3D programming I have yet to program a full 3D engine, I have merely tinkered around with teh various different aspects that go into an engine. Broadly stated, my quesion is, how much is too much. That is to say, how many divides can you have before you no longer have a real-time application? I know this is an extremely broad question so let me narrow it using an example.

To do exact perspective texture mapping requires at one per-pixel divide by z. If every other component of the engine was optimized would one per-pixel divide be too much??

I look forward to your comments.

I'm not sure about integer division but, from the Intel Optimization Manual:

single-precision divide = 17 cycles
double-precision divide = 36 cycles
extended-precision divide = 56 cycles

So in answer to your question, Yes. But you probably won't have much time to do anything else!

I wrote a program recently that needed the effect of one floating-point divide per pixel. Rather than do the divide, I used a lookup table of the reciprocals described by CD.

This topic is closed to new replies.

Advertisement