Disabling Lighting on certain things, and switching view in the middle of the render

Started by
3 comments, last by nickwinters 18 years, 8 months ago
I'm currently writing up my HUD system. The question is how to render it. One option is to put it on the near Z plane, but that would take a bit of math. My other idea would be to switch from perspective to ortho once I'm done rendering the scene and ready to render my hud. Is this possible? I also want to turn off lighting on them, and it just display the rectangles and textures. Is it possible to turn off lighting on them? Thanks. -Nick
Advertisement
People sometimes think about this in ways that are too complicated... but to me Direct3D just draws stuff, your HUD is just what gets drawn last. You can use screen transformed vertices or an ortho projection, it's your choice. Just disable lighting, disable your Z test, and keep rendering. It's definitely ok to change states, render, change states, etc... in fact it's essential!

If you want to use screen transformed coordinates, I recommend you set up a "virtual resolution" so that your controls/text/etc appear the same physical size regardless of the actual resolution. Scaling all your vertices to the "virtual resolution" would be the very last step before you render your quads.
MasterWorks is right, I just want to add a little more because implementing screen space coords for the first time can sometimes be confusing.

You're probaly going to want to use transformed coordinates, which are positions in screen space. If you are using a vertex buffer to hold a triangle list of all the quad's, then you will need to specify D3DFVF_XYZRHW as your flexible vertex format flag. That specifies your positions will use screen space coordinates. RHW stands for recipical of homogenous w or 1/w. This says that all the x,y,z coordinates have already gone through the divide by w(projection).

You can leave your z test on if you want to have some windows be overlapped or you can simply sort them back to front and render with z-test off. But regardless of the z value you put in no perspective will be used because you are specifying the x,y in screen space coordinates. Like MasterWorks already suggested, you should probaly create your hud system using percentages instead of hardcoded values so you can switch resolutions without a hitch.

[Edited by - ph33r on July 25, 2005 1:51:06 AM]
Good stuff to know. Thanks!
Thanks.

This topic is closed to new replies.

Advertisement