Original Post
I'm working on a 2D game with glowing lines similar to what you'd see on a modern clone of Geometry Wars (like this). How do they normally do this effect? I already have my basic rendering code set up to render 2D geometry and it's working fine. I'm quite sure you'll need to use shaders for such an effect, so how would you write vertex shaders for 2D shapes? I'm using assembly shaders for my project (or at least I was), but I do have HLSL support too. This is my HLSL passthrough shader which I can't get to work for the above code. 3D is fine though. How would I change this to work for 2D rendering? Should I be using an orthographic projection instead to calculate the WVP matrix? Would the D3DFVF_XYZRHW flag be a problem? Or should I just use an dynamic vertex buffer instead? Any ideas? Thanks.
// Vertex structure
struct VERTEX
{
D3DXVECTOR4 vecPosition;
DWORD dwColour;
static DWORD FVF;
};
DWORD VERTEX::FVF = ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE );
...
lpD3DDevice->DrawPrimitiveUP(...);
float4x4 mtxWVP : register (c0); // Put the WVP matrix into constant register c0-3
// This constant is set with the Direct3D API
// IDirect3DDevice9::SetVertexShaderConstantF
// Input vertex structure
struct VPIn
{
float4 ObjectPosition : POSITION;
float4 Colour : COLOR;
};
// Output vertex structure
struct VPOut
{
float4 ProjectedPosition : POSITION;
float4 Colour : COLOR;
};
// Vertex shader program entry point
VPOut main( VPIn In )
{
VPOut Out;
Out.ProjectedPosition = mul( mtxWVP, In.ObjectPosition ); // Transform the vertex into
// projected space
Out.Colour = In.Colour; // Passthrough vertex colour
return Out; // Return transformed vertex
}