Jump to content
hackbart

3D Anaglyph Shader

Recommended Posts

hackbart

Hi,

 

from time to time i get nagging emails and phone calls with questions about the new 3d Transmissions, and why i don't implement it - especially since "this is quite simple to realize".

Even if i honestly wonder about the inappropriate self confidence of some people it is quite an interesting topic. Let me point the following out:

The only acceptable solution we will implement is the usage of pixel shaders in order to manipulate the 3d video. Especially since neither Lars, nor myself is willing to splash multiple

cpu ressources for such a half baked hype.

 

A quite good ressource for more information can be found here: http://www.3dtv.at/knowhow/AnaglyphComparison_de.aspx

 

For this sample i use the real anaglyph technique:

 

// Anaglyph Shader V0.1 (C) 2010 Christian Hackbart
sampler s0 : register(s0);

float4 main(float2 tex : TEXCOORD0) : COLOR
{	
  float4 l = tex2D(s0, tex);
  tex.x = tex.x + 0.5;

  if (tex.x>1) {
return 0; // the pixel is on the right half picture, so we remove it
  }

  float4 r = tex2D(s0, tex);

  float red = l.r * 0.299 + l.g * 0.587 + l.b * 0.114;
  float green = 0;
  float blue = r.r * 0.299 + r.g * 0.587 + r.b * 0.114;

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

 

If the shader is enabled a 3d image like this:

original.jpg

 

will become to a 3d anaglyph picture:

dubois.jpg

 

Feel free to use this code in order to get your red/cyan glasses working o:)

 

Christian

  • Like 1

Share this post


Link to post
hackbart

This version is using the optimized anaglyph mode and works fine with the glasses i have here:

 

// optimized Anaglyph Shader V1.0 (C) 2010 Christian Hackbart
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);
}

 

A much more nicer algorithm made by Eric Dubois (http://www.swell3d.com/color-anaglyph-methods-compare.html) is using the following formula:

 

| 0.4561000  0.5004840  0.17638100|   |l.r| + |-0.0434706 -0.0879388 -0.00155529|   |r.r|
|-0.0400822 -0.0378246 -0.01575890| * |l.g| + | 0.3784760  0.7336400 -0.01845030| * |r.g|
|-0.0152161 -0.0205971 -0.00546856|   |l.b| + |-0.0721527 -0.1129610  1.22640000|   |r.b|

 

Christian

Share this post


Link to post
McenterFreak

Do you consider 3D as a feature you will implement in a future release?

If yes, would it be possible to use it on a standard monitor/TV, or is a 3D TV nessesary?

If this feature would be implemented, would it be possible to view 3D BluRay's? (we don't have any channel with 3D in Denmark, yet)

I know this post could belong to the Suggestions tread, but its really not a suggestion, just a question

Share this post


Link to post
Lars_MQ

Well, anaglyph 3D works, as it seems and it can be used now in the DVBViewer with side by side transmission and red/green glasses. This kind of 3D has nothing to do with bluray 3D or shutterglasses etc.

 

Shutterglasses 3D Hardware needed: http://www.nvidia.com/object/3d-vision-diy.html

 

As for the rest: Don't know.

Share this post


Link to post
Víctor P.

Thanks hackbart, works like a charm!

Share this post


Link to post
Víctor P.

The only drawback of using shaders is that you won't stream the final result but the original picture so I guess for that purpose it will need a different approach.

Share this post


Link to post
desweil

the client that displays the picture has to use the shader. If you stream to other DVBViewer clients(via the recodring service), then you can just activate the shader on every client. If you stream to vlc, then vlc has to implement this shader.

Share this post


Link to post
Víctor P.

Yes I know, actually what I had in mind was streaming the anaglyph picture to my Popcorn Hour in order to watch it on my TV.

Share this post


Link to post
Lars_MQ

Sorry that won't work. The PC has to decode the picture, compose a new one and reencode the picture and we're talking 1080i here with at least 25 pics/sec. You would need a mighty powerfull machine for it.

Share this post


Link to post
ElecardFAN

Nice, anyway it seems that the resolution of the source might cause problems with this algorithm. Usually a texture has a range of 0..1 inside the shader, but it seems to be that 0.5 is not always the real middle.

Anyway i suppose this 3d hype will be just short termed, i don't think people would like to wear glasses while watching tv the whole time - and i personally get headache after a while...

 

Peter

PS: Christian, its amazing that you got this one working with shaders. I never thought there might be such a smart solution for a problem like this!

Edited by ElecardFAN

Share this post


Link to post
dani11

Hello, I managed to see in 3D with the beta of DVBViewer, but I notice a change in colors, especially red and everything in general is seen with green shades, can you fix it?

Greetings

Share this post


Link to post
desweil

I am not an expert but I think that this is one of the inherent drawbacks of the anaglyph technique, so there is no "fix"

Share this post


Link to post
Nimloth

Hello,

 

JSC Sport 3D uses this technique (2 plit screens).

How to use this script to get 3D working?

 

Thanks

Share this post


Link to post
desweil

-use the latest beta version of DVBViewer

-copy the script above

-paste it into a file just like the other xml shaders in the DVBViewer/shaders directory

-activate the shader in DVBViewer

Share this post


Link to post
Lars_MQ

Dont forget to put the red/green glasses on ;)

Share this post


Link to post
Placenta

Hi, I have tried the above anaglyph shader, unfortunately it does not display for me correctly (the left/right images are not positioned correctly, they seem too far apart), am I doing something wrong or is it a setting within DVBViewer beta I am over looking?

 

http://img706.imageshack.us/img706/1601/24674498.png

Share this post


Link to post
desweil

is it a side-by-side transmission(see first post)? If not then it will not work. You can not "create" a 3d image. Just convert the 3d transmission format(sidebyside) to a format useable by the red/cyan glasses.

Share this post


Link to post
Placenta

Thanks for clearing that up, I think thats where I was going wrong....time to find a side-by-side transmission.

Share this post


Link to post
fundom

@ Christian

While the following works fine....

// optimized Anaglyph Shader V1.0 © 2010 Christian Hackbart

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);

}

 

How to use the following:

A much more nicer algorithm made by Eric Dubois (http://www.swell3d.com/color-anaglyph-methods-compare.html) is using the following formula:

 

| 0.4561000 0.5004840 0.17638100| |l.r| + |-0.0434706 -0.0879388 -0.00155529| |r.r|

|-0.0400822 -0.0378246 -0.01575890| * |l.g| + | 0.3784760 0.7336400 -0.01845030| * |r.g|

|-0.0152161 -0.0205971 -0.00546856| |l.b| + |-0.0721527 -0.1129610 1.22640000| |r.b|

Share this post


Link to post
hackbart

I honestly did not thought that reading and multiplicating a matrix (http://en.wikipedia.org/wiki/Matrix_(mathematics)) would cause that much trouble :(

 

 float red = 0.456100*l.r + 0.500484*l.g + 0.176381*l.b  - 0.0434706*r.r - 0.0879388*r.g - 0.00155529*r.b;
 float green = -0.0400822*l.r - 0.0378246*l.g -0.0157589*l.b + 0.378476*r.r + 0.73364*r.g - 0.0184503*r.b;
 float blue = -0.0152161*l.r - 0.0205971*l.g -0.00546856*l.b - 0.0721527*r.r - 0.112961*r.g + 1.2264*r.b;

 

Christian

Share this post


Link to post
fundom

THXXXXXXXXXX Christian. BTW I'm 64. Matrix is not for me :)

Share this post


Link to post
85sat

Hi , i was install latest beta version(4.3.1.5) but didn't find any thing like EVR costumer in the option>directx and shader menu in the view toolbar . :o

what can i do?

Share this post


Link to post
desweil

in options->directx activate thr checkbox "use custom renderer". then you can choose the custom evr renderer.

Share this post


Link to post
alec1976

thanx a lot for this :)

BTW , Are u guys watching FIFA IN 3D ?

IT is free to air

 

BRASIL - NORTH KOREA

 

Eutelsat W1 (10.0°E)

 

 

Fréquence: 12725 - Pol: H - SR: 20665 - FEC: -

DVB S2 (8PSK ))

FREE TO AIR

THAT IS technical feed ( NOT for residential users MPEG 2 4:2:0 video decoder needed )

d87449d75566.jpg

Share this post


Link to post
85sat

Hi gays , you can use this file for 3d .(copy in : DVBViewer\shaders\...)

anaglyph.xml

Share this post


Link to post
85sat

Hi guys , you can use this file for 3d .(copy in : DVBViewer\shaders\...)

this file is current you can download it

anaglyph.xml

Edited by 85sat

Share this post


Link to post
Bobben

thanx a lot for this :)

BTW , Are u guys watching FIFA IN 3D ?

IT is free to air

 

BRASIL - NORTH KOREA

 

Eutelsat W1 (10.0°E)

 

 

Fréquence: 12725 - Pol: H - SR: 20665 - FEC: -

DVB S2 (8PSK ))

FREE TO AIR

THAT IS technical feed ( NOT for residential users MPEG 2 4:2:0 video decoder needed )

 

 

If someone has problem receiving the feed try to set FEC= 2/3 and pilot=On.

As the transmission is MPEG2 main profile high level 4:2:0 most HD receivers will work. My

Topfield 7700 HDPVR works without any problems and usually most HD receivers supports

MPEG2 main profile high level 4:2:0 .

 

The following games is produced in 3D:

 

* 18. june: Slovenia vs USA

* 19. june: Holland vs Japan

* 20. june: Brasil vs Ivory Coast

* 21. june: Spain vs Honduras

* 22. june: Nigeria vs Korea

* 23. june: Ghana vs Germany

* 24. june: Slovakia vs Italy

* 25. june: Portugal vs Brasil

* 27. june: nr. 1 group B vs nr. 2 group A

* 28. june: nr. 1 group E vs nr. 2 group F

* 28. june: nr. 1 group G vs nr. 2 group H

* 02. july: Quarterfinal

* 03. july: Quarter final

* 03. july: Quarter final

* 06. july: Semi final

* 07. july: Semi final

* 10. july: Third place final

* 11. july: Final

Edited by Bobben

Share this post


Link to post
dani11

If someone has problem receiving the feed try to set FEC= 2/3 and pilot=On.

As the transmission is MPEG2 main profile high level 4:2:0 most HD receivers will work. My

Topfield 7700 HDPVR works without any problems and usually most HD receivers supports

MPEG2 main profile high level 4:2:0 .

 

The following games is produced in 3D:

 

* 18. june: Slovenia vs USA

* 19. june: Holland vs Japan

* 20. june: Brasil vs Ivory Coast

* 21. june: Spain vs Honduras

* 22. june: Nigeria vs Korea

* 23. june: Ghana vs Germany

* 24. june: Slovakia vs Italy

* 25. june: Portugal vs Brasil

* 27. june: nr. 1 group B vs nr. 2 group A

* 28. june: nr. 1 group E vs nr. 2 group F

* 28. june: nr. 1 group G vs nr. 2 group H

* 02. july: Quarterfinal

* 03. july: Quarter final

* 03. july: Quarter final

* 06. july: Semi final

* 07. july: Semi final

* 10. july: Third place final

* 11. july: Final

 

Thank you very much for your information

Share this post


Link to post
dani11

Again I make my interest in the possibility of adjusting the colors in the way anaglyph, can be improved?

Share this post


Link to post
Lars_MQ

No. Anaglyph is this way. Live with it.

Share this post


Link to post
dani11

Thank you for your quick response, sorry to be so, I very interested in this topic.

Regards

Share this post


Link to post
samiusta

<?xml version="1.0" encoding="iso-8859-1"?>

<Shader>

<Profile>ps_2_0</Profile>

<Description>AnaglyphOPT</Description>

<Code>// optimized Anaglyph Shader V1.0 © 2010 Christian Hackbart

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;

 

float4 l = tex2D(s0, tex);

 

tex.x = tex.x + 0.008;

 

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);

}</Code>

</Shader>

Mit etwas Anderung können sie auch normale Tv Sendung auch 3D sehen.

Share this post


Link to post
guenti51

Mit etwas Anderung können sie auch normale Tv Sendung auch 3D sehen.

Mit 3D hat das dann aber nichts zu tun.

Wo sollen die Tiefeninformationen auch herkommen bei einen 2D Bild ?

Share this post


Link to post
samiusta

Sehen Sie tridef3D Programme.Die Programme aendert die 2D auf 3D .Man braucht nicht zwei Bilder .

Share this post


Link to post
McenterFreak

Sehen Sie tridef3D Programme.Die Programme aendert die 2D auf 3D .Man braucht nicht zwei Bilder .

At the top: DVBViewer community forum> English> General

Share this post


Link to post
guenti51

@McenterFreak

 

Sorry für die Störung in German!

Share this post


Link to post
McenterFreak

@McenterFreak

 

Sorry für die Störung in German!

It is not because i am disturbed, but i do not understand German, like you would not understand if i start to write in Danish

The reason for me to write about this, is that there are a very large section i German about DVBViewer, and some small ones i English. If they also change to German, we dont have a chance!

Share this post


Link to post
ZappoB

Again I make my interest in the possibility of adjusting the colors in the way anaglyph, can be improved?

 

Why? Do you get bad results and shadows with your red/blue-glasses? Try to increase the color-settings of your TV to the max and increase also the contrast.

Share this post


Link to post
dani11

Why? Do you get bad results and shadows with your red/blue-glasses? Try to increase the color-settings of your TV to the max and increase also the contrast.

Hello I've tried, but did not improve, the problem is that it distorts the colors

Share this post


Link to post
alec1976

Hello I've tried, but did not improve, the problem is that it distorts the colors

that's the price u have to pay if u've chosen anaglyph , although u can get "proper" colors with FULL COLOR anaglyph MODE but it is dramatically reduce deepness of a 3D

HINT:

- POSTPROCESS plugin

- 3dtv.at directshow filter ( coming along with Stereoscopic player )

Edited by alec1976

Share this post


Link to post
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...