Jump to content

  • Log In with Google      Sign In   
  • Create Account

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.

  • You cannot reply to this topic
4 replies to this topic

#1 RobMaddison   Members   -  Reputation: 708

Like
1Likes
Like

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

Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 13634

Like
0Likes
Like

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.

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 RobMaddison   Members   -  Reputation: 708

Like
1Likes
Like

Posted 20 January 2013 - 03:27 PM

Great, thanks

#4 RobMaddison   Members   -  Reputation: 708

Like
1Likes
Like

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

#5 L. Spiro   Crossbones+   -  Reputation: 13634

Like
0Likes
Like

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


It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums




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.



PARTNERS