• FEATURED

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

## Rendering static images over game

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

Posted 20 January 2013 - 02:21 PM

Hi

When you want to show something like a health bar, a map, score or number of lives etc, I thought you might have to setup a specific view projection matrix, etc, but I just 'accidentally' did it by creating the graphic bounds using interpolated view projected vertices, e.g., the whole screen would be x and y -1,-1 to 1,1 respectively. In the vertex shader I just don't use a matrix to transform it and it works.

Is this how it's normally done anyway? Seems it would be quicker than doing it with matrices

### #2L. Spiro  Members

Posted 20 January 2013 - 02:54 PM

It’s not “normal” (as in not a lot of people are doing this) but it is the best way to go in terms of efficiency for some things.

If it is for the HUD and, as you say, static objects, yes, this is best.

For moving objects, you would have to convert from pixel coordinates to normalized screen coordinates manually on the CPU, which will likely be slower to do than on the GPU, especially for batch rendering.

For your case of static objects, omitting the matrix transform (which just transforms things into -1 to 1 anyway) is the best way to go.  Not only does it save on cycles but also on bandwidth, as there is less to send to the shaders.

L. Spiro

Edited by L. Spiro, 21 January 2013 - 12:34 AM.

Posted 20 January 2013 - 03:27 PM

Great, thanks

Posted 21 January 2013 - 04:25 PM

Another quick question on this, is this how sprites are also usually done? Or would you generally use point sprites - I'm using DX9.

The reason I'm asking is because for my level editor (which will just use the c++ game engine from a c# front end) I'm going to need to overlay sprite-type icons on objects/zones, etc. this way seems pretty convenient to me

Although I guess this kind of changes the title to non-static graphics!

Thanks

### #5L. Spiro  Members

Posted 22 January 2013 - 12:27 AM

Updating vertex buffers and calculating the normalized coordinates of vertices is slow.  You have to decide based on your usage.

If it doesn’t move or moves rarely, use this method.  If it moves a lot, use matrices.

HUD elements are just sprites, so there is no single answer.  Use this to decide when you should use matrices and when you should not.

L. Spiro

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.