Viewing stereoscopic 3D videos with Media Player Classic

Post Reply
Matthew
One Eyed Hopeful
Posts: 41
Joined: Tue Jun 25, 2013 11:45 pm

Viewing stereoscopic 3D videos with Media Player Classic

Post by Matthew »

Although there are a number of stereoscopic video player programs available, all of the ones I know of have one significant limitation:

They don't allow you to use GPU decoding. This is because they use DirectX filters to do the stereoscopic output, and DirectX filters are done in software.

There is a very simple way around this: Use a shader, instead of a filter, to do the stereoscopic output. This way, it is done GPU side, so it can be done with GPU decoding. It also is generally faster.

Although none of the stereoscopic video programs I know of allow this, Media Player Classic allows you to use custom HLSL shaders. Although Media Player Classic doesn't include support for stereoscopic viewing, you can use a shader to make it output in a stereoscopic format, which can be used with a 3D system.

I've written a shader for it that outputs in interleaved format. Here it is:


Code: Select all

sampler s : register(s0);
float2 size : register(c0);



#define TLEFT p.y -= size.y / 4.0; \
	if (any(p < float2(0.0, 0.0)) || any(p > float2(size.x, size.y / 2.0))) \
		return float4(0.0, 0.0, 0.0, 1.0);
#define TRIGHT p.y += size.y / 4.0; \
	if (any(p < float2(0.0, size.y / 2.0)) || any(p > size)) \
		return float4(0.0, 0.0, 0.0, 1.0);



#define T1 TLEFT
#define T2 TRIGHT



#define HINTERLEAVED



#define XSCALE
#define YSCALE



float4 main(float2 tc : TEXCOORD0) : COLOR
{
	float2 p = tc * (size / 2.0);

#ifdef HINTERLEAVED
	if ((p.y % 1.0) < 0.5)
#endif
#ifdef VINTERLEAVED
	if ((p.x % 1.0) < 0.5)
#endif
#ifdef CINTERLEAVED
	if (((p.x + p.y) % 1.0) < 0.5)
#endif
	{
		p = floor(p);
		p *= 2.0;

		T1
	}
	else
	{
		p = floor(p);
		p *= 2.0;

		T2
	}
#ifdef XSCALE
#ifdef YSCALE
	return (tex2D(s, (p + float2(0.5, 0.5)) / size) + tex2D(s, (p + float2(1.5, 0.5)) / size) + tex2D(s, (p + float2(0.5, 1.5)) / size) + tex2D(s, (p + float2(1.5, 1.5)) / size)) / 4.0;
#else
	return (tex2D(s, (p + float2(0.5, 0.5)) / size) + tex2D(s, (p + float2(1.5, 0.5)) / size)) / 2.0;
#endif
#else
#ifdef YSCALE
	return (tex2D(s, (p + float2(0.5, 0.5)) / size) + tex2D(s, (p + float2(0.5, 1.5)) / size)) / 2.0;
#else
	return tex2D(s, (p + float2(0.5, 0.5)) / size);
#endif
#endif
}


To use this shader, add it in Media Player Classic as a "pre-resize shader" and enable it. Make sure you set the proper settings so that the video is not scaled.

To set the stereoscopic parameters, use the macros. It takes a bit of programming knowledge, but by properly modifying those macros, you can make it use any "packed" format (over/under, left/right, right/left, etc.) and any of the three methods of interleaving (horizontal, vertical, checkerboard) and set the screen shift and interleaving alignment.

Although this is a hack, it works very well. It is useful for systems that aren't fast enough to smoothly play back high quality stereoscopic video without GPU decoding.

With my current computer system, this is actually the ONLY way I have of viewing high quality stereoscopic video -- the CPU is far too slow. I wonder why programs such as Stereoscopic Player don't allow this.
Post Reply

Return to “General Stereoscopic 3D Discussion”