Kodi Community Forum

Full Version: Stereoscopic 3D support for half/full SBS, over/under, etc
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is this plugin also for fixing the problem if you play an 3D movie, with an SRT subtitles and when you switch your TV to 3d, the subtitles doesnt get duplicated and is smeared out big over the screen?

If so, also for frodo?
(2013-12-16, 20:38)Oxize Wrote: [ -> ]Is this plugin also for fixing the problem if you play an 3D movie, with an SRT subtitles and when you switch your TV to 3d, the subtitles doesnt get duplicated and is smeared out big over the screen?

If so, also for frodo?
It is not plugin, it is part of core xbmc. But only in gotham.

And yes it deals with subtitles properly.
(2013-12-16, 20:08)Lamerjack Wrote: [ -> ]Thanks a lot!
maybe this can be usefull to some developers:

sampler s0 : register(s0);
float4 p0 : register(c0);

#define width (p0[0])
#define height (p0[1])

float4 main(float2 tex : TEXCOORD0) : COLOR
{
tex.x = tex.x / 2;

float4 l = tex2D(s0, tex);

tex.x = tex.x + 0.5;

float4 r = tex2D(s0, tex);

float red = l.g * 0.7 + l.b * 0.3;
float green = r.g;
float blue = r.b;

return float4(red, green, blue, 1);
}

is the shader that i use with mpchc for optimized anaglyph (red cyan) the result is much better when there cyan or red things on the video

Thanks, but I'm not sure we're using a shader for this. We currently lack devs that know their way around with shaders, so if you like and can, we'd still need a shader to convert the input into row- and column-interleaved/interlaced (while row interleaved is the more demanding)
xbmc doesn't use shaders for anaglyph, but only shaders is way to implement interleaved stereo I think.
(2013-12-16, 21:06)nickr Wrote: [ -> ]
(2013-12-16, 20:38)Oxize Wrote: [ -> ]Is this plugin also for fixing the problem if you play an 3D movie, with an SRT subtitles and when you switch your TV to 3d, the subtitles doesnt get duplicated and is smeared out big over the screen?

If so, also for frodo?
It is not plugin, it is part of core xbmc. But only in gotham.

And yes it deals with subtitles properly.

Ah cool, Lets wait a few weeks (months), if they release gotham like all older releases.
Many people are using it now, it is mainly stable Smile
I have notice a slight bug with Videos not switching Stereoscopic modes when they are in a Playlist. Posted on trac -> http://trac.xbmc.org/ticket/14746
DecreasePAR/IncreasePAR when playing a side by side movie changes the width size, not the height. This is correct?
(2013-12-23, 15:37)tinybutstrong Wrote: [ -> ]DecreasePAR/IncreasePAR when playing a side by side movie changes the width size, not the height. This is correct?

Please be more specific. What exactly are you trying to do and why?
I'm trying to increase a bit the movie height, due big black bars in some movies.. I have set DecreasePAR/IncreasePAR in a custom keyboard shortcut. Works fine for "regular" movies, but not for 3D one.

Code:
<keymap>
  <FullscreenVideo>
    <keyboard>
      <up mod="alt,shift">DecreasePAR</up> <!-- Increase height of video -->
      <down mod="alt,shift">IncreasePAR</down> <!-- Decrease height of video -->
    </keyboard>
  </FullscreenVideo>
</keymap>

http://wiki.xbmc.org/index.php?title=Keymap
3D will get all screwed up if you change that. Accept the movie in the ratio intended by those who created it.
People , i have a fairly good pixel and vertex shader knowledge , i already developed an app that uses pixel shaders and support all kind of 3d

So i will post pixel shader for all kinds of 3D (Including line interleaved) that has the ability to display half size or full size or even 2D
As well as controlling depth and vertical alignment of the 2 cameras which is useful when the 3d is recorded with 2 Different video cams
That has some mis vertical alignment.
This is done with shader input parameters that if manipulated with the application can control 3D parameters.

So the only missing thing now is the subtitles 3d depth adjustment , if some one figures out how to do it then we will have a complete 3D solution.

Now enough of all that here are the actual pixel shaders i really hope that they come in handy:

///////////////Red-Cyan Anaglyph
sampler s0 : register(s0); // Video Texture
float fTU; // Width of the texture in Texels (0.0 to 1.0) (In our case the texture has the same resolution as the screen so we can put this =1.0)
float fTV; // Height of the texture in Texels (0.0 to 1.0)(In our case the texture has the same resolution as the screen so we can put this =1.0)
float depthDistanceV; // Vertical Offset in Texels
float depthDistanceH; // Horizontal Offset in Texels
bool displayOneSide; // TRUE if need to view 2D side only, FALSE if view 3D
bool reverseLR; // To Reverse Left and Right Cameras
bool isFullWidth; // TRUE for full size 3D, FALSE for half size
float scaleFactorX; // Scaling in Width for the viewing window (In case of full screen this =1.0 )
float scaleFactorY; // Scaling in Height for the viewing window (In case of full screen this =1.0 )

float4 main(float2 tex0 : TEXCOORD0) : COLOR
{
float4 stereoscope;
if (!isFullWidth) tex0.x *= scaleFactorX;
float4 l = tex2D(s0, tex0);
if (displayOneSide)
stereoscope = l;
else
{
float4 r;
tex0.x += fTU / 2.0 - depthDistanceH;
tex0.y += depthDistanceV;
if (tex0.x < fTU / 2.0f || tex0.x > fTU || tex0.y < 0.0 || tex0.y > fTV)
{
l = float4(0, 0, 0, 1);
r = float4(0, 0, 0, 1);
}
else
{
r = tex2D(s0, tex0);
}
if (!reverseLR)
{
float redGray = dot(l, float4(0.299, 0.587, 0.114, 0));
stereoscope = float4(redGray, r.g, r.b, 1.0);
}
else
{
float redGray = dot(r, float4(0.299, 0.587, 0.114, 0));
stereoscope = float4(redGray, l.g, l.b, 1.0);
}
}
return stereoscope;
}

//////////////Green Magenta
sampler s0 : register(s0); // Video Texture
float fTU; // Width of the texture in Texels (0.0 to 1.0)
float fTV; // Height of the texture in Texels (0.0 to 1.0)
float depthDistanceV; // Vertical Offset in Texels
float depthDistanceH; // Horizontal Offset in Texels
bool displayOneSide; // TRUE if need to view 2D side only, FALSE if view 3D
bool reverseLR; // To Reverse Left and Right Cameras
bool isFullWidth; // TRUE for full size 3D, FALSE for half size
float scaleFactorX; // Scaling in Width for the viewing window
float scaleFactorY; // Scaling in Height for the viewing window

float4 main(float2 tex0 : TEXCOORD0) : COLOR
{
float4 stereoscope;
if (!isFullWidth) tex0.x *= scaleFactorX;
float4 l = tex2D(s0, tex0);
if (displayOneSide)
stereoscope = l;
else
{
float4 r;
tex0.x += fTU / 2.0f - depthDistanceH;
tex0.y += depthDistanceV;
if (tex0.x < fTU / 2.0f || tex0.x > fTU || tex0.y < 0.0 || tex0.y > fTV)
{
l = float4(0, 0, 0, 1);
r = float4(0, 0, 0, 1);
}
else
{
r = tex2D(s0, tex0);
}
if (!reverseLR) stereoscope = float4(r.r * 1.2, l.g * 1.2, r.b * 1.2, 1.0);
else stereoscope = float4(l.r * 1.2, r.g * 1.2, l.b * 1.2, 1.0);
}
return stereoscope;
};

//////////////Color Coded (Blue amber)
sampler s0 : register(s0); // Video Texture
float fTU; // Width of the texture in Texels (0.0 to 1.0)
float fTV; // Height of the texture in Texels (0.0 to 1.0)
float depthDistanceV; // Vertical Offset in Texels
float depthDistanceH; // Horizontal Offset in Texels
bool displayOneSide; // TRUE if need to view 2D side only, FALSE if view 3D
bool reverseLR; // To Reverse Left and Right Cameras
bool isFullWidth; // TRUE for full size 3D, FALSE for half size
float scaleFactorX; // Scaling in Width for the viewing window
float scaleFactorY; // Scaling in Height for the viewing window

float4 main(float2 tex0 : TEXCOORD0) : COLOR
{
float4 stereoscope;
if (!isFullWidth) tex0.x *= scaleFactorX;
float4 l = tex2D(s0, tex0);
if (displayOneSide)
stereoscope = l;
else
{
float4 r;
tex0.x += fTU / 2.0f - depthDistanceH;
tex0.y += depthDistanceV;
if (tex0.x < fTU / 2.0f || tex0.x > fTU || tex0.y < 0.0 || tex0.y > fTV)
{
l = float4(0, 0, 0, 1);
r = float4(0, 0, 0, 1);
}
else
{
r = tex2D(s0, tex0);
}
if (!reverseLR){
float blueGray = dot(r, float4(0.15, 0.15, 0.99, 0));
stereoscope = float4(l.r * 1.25, l.g * 1.25, blueGray * 1.25, 1.0);}
else{
float blueGray = dot(l, float4(0.15, 0.15, 0.99, 0));
stereoscope = float4(r.r * 1.25, r.g * 1.25, blueGray * 1.25, 1.0);}
}
return stereoscope;
};

//////Line Interleaved
struct VertexPositionTextureTexture {
float4 Position : POSITION0;
float2 Texture : TEXCOORD0;
float2 NormalisedTexture : TEXCOORD1;
};

sampler ImageSampler : register(s0); // Video Texture
float fTU; // Width of the texture in Texels (0.0 to 1.0)
float fTV; // Height of the texture in Texels (0.0 to 1.0)
float depthDistanceV; // Vertical Offset in Texels
float depthDistanceH; // Height of the texture in Texels (0.0 to 1.0)
float height; // Video Height
float posY; // The Top Left Y position of the viewer window
bool displayOneSide; // TRUE if need to view 2D side only, FALSE if view 3D
bool reverseLR; // To Reverse Left and Right Cameras
float scaleFactorX; // Scaling in Width for the viewing window
float scaleFactorY; // Scaling in Height for the viewing window

float4 main(VertexPositionTextureTexture input ) : COLOR0
{
float4 retColor = float4(0.0, 0.0, 0.0, 1.0);

input.Texture.x *= scaleFactorX;
input.Texture.y *= scaleFactorY;

if (displayOneSide)
retColor = tex2D(ImageSampler, input.Texture);
else
{
float ry = (input.Texture.y * (height / scaleFactorY) + posY) * 0.5f;
float4 retColorL = float4(1.0, 1.0, 1.0, 1.0);
float4 retColorR = float4(0.0, 0.0, 0.0, 1.0);
retColorL = tex2D(ImageSampler, input.Texture);
input.Texture.x = input.Texture.x + fTU / 2.0f - depthDistanceH;
input.Texture.y = input.Texture.y + depthDistanceV;
if (input.Texture.y >= 0.0 && input.Texture.y <= fTV)
retColorR = tex2D(ImageSampler, input.Texture);
else
{
retColorL = float4(0.0, 0.0, 0.0, 1.0);
retColorR = float4(0.0, 0.0, 0.0, 1.0);
}
input.Texture.x = input.Texture.x - fTU / 2.0f;
if (input.Texture.x <= fTU / 2.0f && input.Texture.x >= 0.0)
{
float rem = abs(ry - round(ry));
if (rem < 0.1f)
{
if (!reverseLR)
retColor = retColorR;
else
retColor = retColorL;
}
else
{
if (!reverseLR)
retColor = retColorL;
else
retColor = retColorR;
}
}
else
{
retColorL = float4(0.0, 0.0, 0.0, 1.0);
retColorR = float4(0.0, 0.0, 0.0, 1.0);
}
}
return retColor;
}

//////////////Side by Side
sampler s0 : register(s0); // Video Texture
bool displayOneSide; // TRUE if need to view 2D side only, FALSE if view 3D
bool isFullWidth; // TRUE for full size 3D, FALSE for half size

float4 main(float2 tex0 : TEXCOORD0) : COLOR
{
float4 retColor = float4(0.0, 0.0, 0.0, 1.0);
if (isFullWidth) tex0.x *= 2.0;
if (displayOneSide)
{
tex0.x = tex0.x / 2.0;
retColor = tex2D(s0, tex0);
}
else
retColor = tex2D(s0, tex0);
return retColor;
};
Hi guys

Been trying out the latest monthly build with some HSBS and FSBS files. It 'works' but not as it should. For example, when I play a HalfSBS file XBMX seems to 'see' it's a 3D file and asks me in which format to play it. When I choose 'same as movie' I get a 3D picture, but it seems the picture is squashed vertically by 50%. This is also apparent when I choose '2D', then the movie plays fine but it's just 50% of its original size vertically. When I play a movie in 2D and/or 3D, subtitles seem to be duplicated left/right too. Tested with the latest nightly build, same issue.

Strange thing is, this is on my Mac Mini running Win7. When I use the same monthly build on OSX, it works fine.

Any idea what might be causing this?

edit: seems it's not exaclty ok on osx too, so I suppose some encoding difference? This is the differences I see using mediainfo (left file=wrong, right file=plays fine). I see a difference in the values "original display aspect ratio", "bits/(pixel*frame)". I suppose it's the latter that is the culprit? How do I fix this?

Image
Found a strange behavior, after to enable the option Settings -> Video -> Playback -> Adjust display refresh rate to match video, my TV is auto switching to 3D mode when playing a normal movie non 3D. (Samsung TV)

This is correct? I remember in Frodo my tv changes to 24p mode.
Latest is not a version.