HLSL and Stars

Started by
4 comments, last by Erik Rufelt 14 years, 5 months ago
Hi there, for my game i'm using Direct3D9 and HLSL. I've been looking at several ways to render stars (my game is based in space). I've looked at skyboxes and skydomes but one dominant flaw is the fact that they will never be truely 3d, so from any angle other than directly facing stars will look distorted due to projection. I had an idea that i could use a skybox, but instead of texturing it normally i could use HLSL to render in real time stars and make them appear more realistic. To explain it further, i'm not sure exactly how i will achieve this but could anyone shed any light on this? I don't really mind about close stars and simulating it truely 3d. I just want to be able to look at the stars at any angle and not be able to tell that i'm actually looking at a sphere or skybox. I was thinking that obviously one of the key factors is camera projection. To demonstrate it further here is some images demonstrating what i'm talking about: This shows what it will actually appear like ingame because of projection. And this is the effect i desire, that no matter where you look, the stars appear to be facing you relative, because light sources aren't solid and shouldn't be projected flat. Any help you could provide me with is greatly appreciated, Thanks, Dan
Advertisement
With a properly rendered skybox you will never see the stars from more than one angle, even when rotating the camera. I think a high-resolution skybox will give very good results. I've seen it used in many games with realistic space scenes.
I found the following thread right here at GameDev.net with Google: http://www.gamedev.net/community/forums/topic.asp?topic_id=463506.
Thanks for the input, well my main problem is, i'm using an engine which doesn't directly support traditional skyboxes, and natively supports physical skydomes which you place above the level. Which is probably the main reason why i'm facing this problem.

I've updated the thread with examples of my problem.

Thanks,
Dan
The engine should have some kind of documentation about how you're supposed to make skies..

In any case, any engine can easily use sky-boxes. All you need to do is draw a cube viewed from the inside without depth-testing, centered on the origin, the first thing every frame, instead of clearing the back-buffer color. Set up your matrices with only the camera rotation and no translation, and that's it.
Quote:Original post by Erik Rufelt
All you need to do is draw a cube viewed from the inside without depth-testing, centered on the origin, the first thing every frame, instead of clearing the back-buffer color.


Bad bad bad bad baaaad idea. DO NOT DO THIS. Every presentation or summit I've ever run across on the subject of performance explicitly states you should Clear() at the beginning of a frame. This breaks more internal optimizations than you can shake a stick at. Also, you can avoid redundant ROP and texture traffic by doing the skybox *last* and taking advantage of depth culling.
clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.
Good advise. =) I was mostly trying to explain the process as easily as possible, getting the skybox as the background. I don't think it's that essential to clear color buffers though.. for example http://developer.download.nvidia.com/presentations/2008/GDC/GDC08-D3DDay-Performance.pdf even says that on Radeon cards you should not clear render targets unnecessarily.

This topic is closed to new replies.

Advertisement