views:

263

answers:

3

We have a Silverlight application that shows text over video. Both the text and video can be considered variables. Sometimes we might have a dark video, sometimes a bright video, sometimes a video that has sections of both.

Think of credits at the end of a movie. We want to ensure the end user can always read the text being show over the video. The text is always an overlay on top of the video.

The simple solution is to two show the text twice once in white and once in black with a small offset. This almost works but actually looks a little rough, and takes away from the user experience.

Ideally we would have the text with slight semitransparent glow around the edges. So if the text were white there would be a black glow right around the edges.

Is there a way to do this? Or is there an equal or better work-around?

+1  A: 

You could try displaying it with a contrasting outline, rather than just a "drop shadow" like you get if you display it once with a small offset. To do this, display it four times in one color, then a fifth time with a contrasting color, centered over the four previous copies. The four first ones should be offset one pixel up, right, down and left of the center.

The net effect should be an outline. Of course, perhaps this too looks "rough", since it's computer-generated and thus not perfect with respect to issues like kerning, spacing between characters, and so on. But it's quick to try, at least.

In general, automatically finding good contrasting colors when the background is video sounds a bit difficult. In the worst case, the video contains text just like the one you want to display. The correct solution in that case is hard to imagine.

unwind
Thanks, the 4 direction shadow has the roughness as well. I think it need either the glow effect or an anti aliasing correction.Does anyone know if Silverlight 3.0 bitmap pixel shaders could do either of these?
CJCraft.com
+1  A: 

Sounds similar to the problem of ensuring subtitles are always readable in films/TV. The most robust, but not necessarily most elegant solution, is to have a coloured background rectangle for the text which is either opaque or has a low transparency value - often grey or black with good contrasting foreground colour.

Gordon Mackie JoanMiro
You're right that would work. That would take a lot of way from the user experience for this application. We'd probably leave as is if that ends up being only option.
CJCraft.com
+1  A: 

I've done this with the DropShadow pixel shader effect in Silverlight 3. It works nicely, but since the pixel shaders aren't executed on the hardware, it can have a pretty heavy impact on the performance of the application.

If you wanted to get ambitious, you could write your own pixel shader. Silverlight 3 supports HLSL Shaders.

Page Brooks