I'm currently trying to show a galaxy and have developed a compute shader that places/moves "stars".

Another vertex/fragment shader reads the buffer and currently places a point at each location.

I'm achieving this by getting a reference to the shader, binding the same compute buffer and then calling Graphics.DrawProceduralNow()

    private void InitialiseShaders() {
        int itemSize = Marshal.SizeOf(typeof(MapShaderStarDetail));
        starLocations = new ComputeBuffer(

        mapComputeShader.SetBuffer(Kernel("BuildStars"), "starBuffer", starLocations);
        Shader.SetGlobalBuffer(Shader.PropertyToID("starBuffer"), starLocations);

        mapMaterial = new Material(mapRenderShader);
        mapMaterial.SetBuffer("starBuffer", starLocations);

    private void Update() {
        mapComputeShader.Dispatch(Kernel("MoveStars"), threadDimensions.x, threadDimensions.y, threadDimensions.z);

    public void OnPostRender() {
        mapMaterial.SetFloat("maxRadius", maxRadius);
        Graphics.DrawProceduralNow(MeshTopology.Points, numStars, 1);

This works as expected...

Galaxy map

However, I need to use an obscenely large number of stars to get the visual density I'm looking for.

Ideally, instead of rending a point at each location, I'd render an instanced billboard with a circular sprite, then significantly reduce the number of stars.

This would also allow me to add dust clouds and similar for added visual complexity.

I've tried swapping MeshTopology.Points to MeshTopology.Quads but I've hit two issues:

  • The fragment shader only returns one point for each buffer item, so it effectively picks 4 random stars to form a quad, rather than 4 quads per star.
  • I don't see any obvious way to keep the billboard angled towards the camera.

I'd prefer to keep the existing data structure (entry per point, rather than entry per billboard corner) if possible, to avoid needless duplicating other properties.

Is this possible?


1 Answer 1


I think you might want to use DrawMeshInstancedIndirect (or another function in that family, like DrawMeshInstancedProcedural). That way, you can specify the mesh that you want to draw (in this case, a quad) at each of the points, and you get to write a vertex shader in which to do the billboarding.

  • \$\begingroup\$ Thanks for the pointer. I'll do some reading/testing to see if I can get it to work. \$\endgroup\$
    – Basic
    Commented Nov 14, 2022 at 21:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .