:) Hi folks, first post here :)
I am a seasoned C++ coder working on a "starfield visualizer" (called "Galaxy Navigator 3D" by the way) and I need some help understanding my alternatives regarding shaders.
An early version of the program is up on youtube, but frankly, starfields aren't best friends with video compression :D (Try viewing in full HD). Or you can download it here.
The navigator currently displays a "point list" of more than 2 million points (stars). Each point has an associated 3d position, and a "brightness" (aka Magnitude in astronomy). As you move around in space, the brightness of all stars is recalculated (in my vertex shader) so as you move closer to the stars they become brighter, all according to standard magnitude calculations used in astronomy.
I am using Ogre3D 2.1 as render library, with Direct3D11, HLSL (but I intend on making this cross-platform in due time..).
It currently uses rather simple Vertex, Pixel and Geometry shaders that I have written. It's all simple and "sequential", because I'm still pretty new to this :D
Goals:
1) Really close stars need to be "even brighter" than a point (pixel) at colour (1.0, 1.0, 1.0), which I suppose should be accomplished by issuing textured quads for the closest points.
2) Interactivity: The user should be able to select a point (with a mouse) for some interaction, and also interact by simply hovering with the mouse pointer.
Problem1: I already easily detect which stars are the closest (I change their colour for indication), but I don't know how to emit quads from my Geometry Shader. I understand a GS can emit to several streams, but that seems to require Shader Model 5. Preferably, I would like to solve this without putting too many requirements on hardware, so currently using SM4. Is this a bad choice?. Can I get my GS to emit most of the points to the rasterizer, and a handful to a buffer containing quads? Maybe this requires a second pass? or another GS instance. I don't how this works : (
Problem2: Because of the number of points (which is going to grow), and because of the "ease", I think mouse picking would be best done in the GPU. Currently, I send the mouse position to the vertex shader, so it can identify which stars are "close enough". This works. I change the colour of the points closest to the mouse pointer. How do I get these points back to the CPU? The actual information sent to the CPU isn't defined yet, but it might by a 32-bit integer ID of sorts. Or maybe some floats. Say a maximum of 100 points, but typically no more than 10. Some sort of staging buffer? I don't know how this works either. Does the method of choice depend much on shader model?
All help appreciated!
/mmixLinus;