Rendering vector games on low end GPUs

I’ve been playing about with the standalone version of the Vectrex emulator used by Libretro so see what can be done using the GPU to render the screen with a view to porting the results to the lr-vecx core.

Anti-aliasing and transparency effects were pretty straightforward although the Vectrex’s habit of usually but not always putting bright dots at the end of lines cause a bit of a problem.

Given low end GPU’s, particularly tile based ones, aren’t capable of running the usual multiple shader passes glow implementations I’ve added a cut price version of that too.

Performance wise, it works well with my 256Mb Pi1B.

Some screenshots:

Mine Storm without glow.

Mine Storm with glow.

Pole Position with glow.

What do people think? Any thoughts on the practicalities of implementing it in the libretro core?

1 Like

It looks awesome! How’s the performance impact?

It seems fine. It’s a bit difficult to judge it exactly on my Pi1 since SDL seems to insist on a frame buffer that covers the whole screen rather than just the bit I’m using for the game so on a 16x9 screen it will be writing to nearly twice as much memory as it needs to. Running Pole Position, with it’s countdown timer, on my main PC at the same time as on my Pi1 shows that once up and running (after loading ROMs, etc) they both take the same time to finish a race.

The shaders are very simple. The fragment shader just does

vec3 colour = texture2D(texture, fragTexCoords).rgb;
gl_FragColor = vec4(colour, colour.r);

The glow bit is implemented by drawing the geometry twice. Once with wide lines at a low brightness for glow, followed by again with narrow lines and full brightness. There’s a bit more in the details but that’s basically it.

whoa, that’s a very convincing glow for such a simple process. kudos

It took a while to figure out something so simple. :smiley:

The texture is a circle with blurry edges to get the anti-aliasing, there are different ones for glow and normal lines. The trick with the glow is to stop it getting too bright when there’s lots of overwrites. Using the frame buffer alpha and the GL blend function means additional values can have less and less impact until you reach a limit.

1 Like

Actually, I missed a line out - it’s mixed up with some #defined conditional code to help with debugging which made miss it. It should be

vec3 colour = texture2D(texture, fragTexCoords).rgb;
colour *= fragColour;
gl_FragColor = vec4(colour, colour.r);
1 Like

A quick update on this in case anyone is wondering if I’ve got anywhere with it. I’ve not been able to spend much time on it but have managed to make some progress. Today I’ve got the GPU rendering working on my main PC (i.e. not a Raspberry Pi). It’s not in a state to release, even as an experimental version, yet and there’s still a lot of work to do but getting it rendering properly is a good start. I’ll post updates when there’s any more significant developments.

2 Likes

Heh, i was thinking just this morning “I wonder how that clever vector glow is coming along…” No hurry, I’m glad it’s still in the works :slight_smile: