• Advertisement
  • entries
    743
  • comments
    1924
  • views
    581088

HUD stuff

Sign in to follow this  

98 views

Got a crosshair up and running:



Obviously the more important step is being now able to render any kind of HUD stuff over the top of a 3D screen.

I tried messing about with D3DXMatrixOrtho... stuff as Todo suggested, but I couldn't get it to work in the end.

So instead, I created a second vertex format with a RHW component and texture co-ordinates. It seems that I can now specify a vertex buffer of those with actual screen co-ordinates, then all I need to do is, after all the scene rendering, set the FVF to the new vertex format, switch of z-buffer testing and set the HUD vertex buffer as the stream source.

Obviously I've also had to switch alpha testing on for the crosshair then off for the main rendering since I believe it is quite expensive. I'm using the beast that is D3DXCreateTextureFromFileEx() for now to just autoset the alpha for any black pixels to 0. Better future options are the custom image format I developed with my 2D Direct3D games or maybe the DX Texture tool and .dds files or something.

Don't really care since all that is already well within capabilities. Just pleased to be able to render HUD stuff really.

For some reason though, and help if you can, while the texture alpha seems to be working, I've added a diffuse colour to the vertex format I use for the HUD and obviously assigned a colour to each of the crosshair vertices.

Now, I can modulade the colour of the crosshair using these per-vertex colours, but changing the alpha value of the colour of each vertex does not appear to have any effect.

I know the alphatest stuff is set up right since it is masking out the background of the crosshair texture image, but when I wrote my D3D 2D library, I could also then modulate the alpha of a vertex via the alpha component of the colour member of each vertex. Doesn't seem to work here.

Anyone got any thoughts on that? Appreciate is a bit of a long shot to expect anyone to be able to provide an answer from that rambling.

[EDIT] Christophedo's solved this for me. Vertex alpha working perfectly well now.
Sign in to follow this  


3 Comments


Recommended Comments

I remember having trouble with something like this a while back [smile]. I think it had something to do with D3D only using texture alpha and discarding vertex alpha. Try something like this so it modulates between the two:


D3DXSetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
D3DXSetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
D3DXSetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );



I may be wrong, but hopefully that helps [grin].

Share this comment


Link to comment
Quote:
Original post by Christophedo
I remember having trouble with something like this a while back [smile]. I think it had something to do with D3D only using texture alpha and discarding vertex alpha. Try something like this so it modulates between the two:

*** Source Snippet Removed ***

I may be wrong, but hopefully that helps [grin].


You are such a star. That worked perfectly. Thanks very much indeed.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement