Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Creating a hud/gui with GLSL


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 Richard Goodrum   Members   -  Reputation: 107

Like
0Likes
Like

Posted 22 March 2012 - 07:00 PM

Hi, I am creating a game for my university project and now I am coming round to creating a hud, but I don't know how I should go about doing it with glsl. Can anyone help please?

Sponsor:

#2 pilarsor   Members   -  Reputation: 130

Like
0Likes
Like

Posted 23 March 2012 - 04:52 AM

Try the following steps:

1.) Switch to orthographic projection
2.) Prepare your hud geometry
3.) Apply a vertex and fragment shader to your hud geometry
4.) Draw your triangles describing or hud geometry


When you choose your vertex shader, think about, how you would like to transform your vertices... e.g. just as linear transform e.g. applying the mere modelviewproj transform, or as non-linear transform, e.g. where you treat each vertex with a different offset vector ( computed in the vertex shader ).
Prepare the fragment shader with values per vertex to be interpolated for each fragment.

For your fragment shader, think about how you would change your fragments of your rendered hud area on screen. E.g. use interploated uv values across the triangles as input for a function for pixel color distortion ( executing inside the fragment shader ), or anything else what comes into your mind...

#3 Richard Goodrum   Members   -  Reputation: 107

Like
0Likes
Like

Posted 23 March 2012 - 03:50 PM

ok I'll try and implement this, so I will have to rotate the vertices as the game is a first person shooter, so it rotates with the camera. Also, how can I create a dynamic text variable for the hud, such as the score?

#4 Richard Goodrum   Members   -  Reputation: 107

Like
0Likes
Like

Posted 23 March 2012 - 03:51 PM

Well, I mean how can I show it through the shader?

#5 pilarsor   Members   -  Reputation: 130

Like
0Likes
Like

Posted 23 March 2012 - 04:33 PM

Dynamic text is something, that you might want to prepare in your c++ code.
Take a texture containing the letters of the alphabet, each letter in the texture equally spaced in width and height.
Write a C++ module, that inputs a string and you basically convert each character in the string to an u,v offset in the 2D alphabet texture.
For rendering this text as textured quads for example, you can just use a standard vertex and fragment shader, which has the functionality of a vertex/fragment shader pendant of a fixed function pipeline.

But sure, if you like, go ahead and do something fancy with that text, e.g. like displacing the quad vertices, distorting the uv coords, or applying some function for color generation...




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