In my particles system (using shaders), i store the quad's centre position and an 'index' for each vertex.
for the 2 triangles that make up the quad, i store indices (0,1,3) and (3,1,2) where the indices are clockwise around the quad
In the setup for the shader, i then set four vector4's representin each corner (the same as your original version) these are set up based on the view matrix, the same as your non-shader version.
Vector4[] quads = new Vector4[4];DirectX.Matrix view = Camera.ViewMatrix;DirectX.Vector3 right = new DirectX.Vector3(view.M11, view.M21, view.M31);DirectX.Vector3 up = new DirectX.Vector3(view.M12, view.M22, view.M32);right.Normalize();up.Normalize();quads[0] = new Vector4(up.X - right.X, up.Y - right.Y, up.Z - right.Z, 0f) * 0.5f;quads[1] = new Vector4(right.X + up.X, right.Y + up.Y, right.Z + up.Z, 0f) * 0.5f;quads[2] = -quads[0];quads[3] = -quads[1];SetVertexShaderConstant(EShaderConstants.Quads, quads); SetVertexShaderConstant(EShaderConstants.Transform, Camera.ViewProjectionTranspose);
I then set those 4 vector4's as constants, and in the shader, use the quad index stored with each vertex to index the contants ...
mov r0, v0 ; v0 is the quad's CENTRE positionmov a0.x, v3.x ; v3 is my quad coordadd r0, c[QUADS + a0.x] ; QUADS is a constant to say which is the first vector4m4x4 oPos, r0, c[TRANSFORM] ; TRANSFORM is my transpose view * proj transform
My particle system does a lot more than that in the shaders - scales, moves, textures and colours the quads, but the above is how it works out the facing etc. Not sure if using indexers is the best way, but it works.
hope that helps
Wyzfen