Skip to main content
gamedev.net
🔒 Locked

Faster Transformations

Started by Mayrel 4 replies 350+ views
Original Post
Mayrel
Mayrel
Hullo. I''m trying to make a starfield populated with textured and blended quads. The stars get bigger when you''re close by, and the blending makes lots of stars together seem a lot brighter. Overall, the visual effect is pleasing, so I don''t want to change that. Although it looks good enough, it''s quite slow. On my K6/2-450Mhz w/Voodoo4, I can get around 1000 stars at a reasonable framerate. I haven''t measured it, but I''d guess it''s around 30. However, I''d _like_ more stars: 3000 or 5000. I can do that, quite zippily, if I forgo some of the transformations. Here''s a summary of what happens atm:
Translate the field away from the viewer.
Rotate the field.
For Each Star:
  glPushMatrix
  Translate to The Star''s Position
  Rotate the star so that it''s facing the viwer
  Draw It.
  glPopMatrix
 
The trouble is that the transformations in the loop slow everything down. I''m using three glRotatef calls for each iteration (and a glTranslatef), and it seems to me that there must be a way of converting three rotations around the canonical axes into one rotation around a different axis. If I don''t do the transformations, the stars don''t face towards the viewer: when the starfield is rotated 90 degrees you''re looking at the quads side on and the effect is not pleasing, to say the least. So I have to do the transformations in some form. I''ve tried without the matrix stack operations - just reversing the rotations and translations at the end of each iteration.
  Translate to The Star''s Position
  Rotate around x, y, z
  Draw It.
  Unrotate around z, y, z
  Untranslate
 
It''s a little bit slower. If the six rotations can be condensed into two operations, that''d probably be better. It just occured to me that using the second method I could precalculate the translation from one star to the next, and thusly avoid the untranslate.
One solution I tried was creating a display list of the star field. The list was made just fine, but when I play it back, it ignores any rotations I''ve applied to the modelview matrix. Is that how display lists are meant to operate, or must I be doing something wrong? Just Plain Wrong
Shag
Shag
Just out of interest, do you have a screen shot?

I'm doing a very similar thing, but using points rather than quads - 10,000 stars produce very exceptable framerates.

I'll probably use some textures for really bright stars, but I think the points look pretty nice.

Edited by - Shag on November 28, 2001 2:35:01 PM
terminate
terminate
Also, try using 2 triangles instead of a quad.
Those who dance are considered insane by those who cannot hear the music.
TheSalmon
TheSalmon
quote:
Original post by terminate
Also, try using 2 triangles instead of a quad.


Or maybe just one triangle...

---
No game will ever rule more than CBT!
---Mikael Lax
Fruny
Fruny
The problem with that method is that you are effectively combining a large number of transformations, accumulating numerical errors : rotating then ''unrotating'' will not return exactly to the same position.

That''s one of the reason why you get a stack of matrices.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.