Jump to content

3D Anaglyph Shader


hackbart

Recommended Posts

Hi rica, I saw your post on doom9 but will reply here until you have time to start a new thread.

 

Great work getting the script to load in DGDecNV, I will test it as soon as I have some time.

 

I was going to register and reply in your thread here: http://neuron2.net/board/viewtopic.php?f=8&t=110&start=10

 

...but those guys did not seem very helpful anyway!

 

:biggrin:

Edited by Nick [D]vB
Link to comment
vB' timestamp='1301518895' post='332590']

Hi rica, I saw your post on doom9 but will reply here until you have time to start a new thread.

 

Great work getting the script to load in DGDecNV, I will test it as soon as I have some time.

 

I was going to register and reply in your thread here: http://neuron2.net/board/viewtopic.php?f=8&t=110&start=10

 

...but those guys did not seem very helpful anyway!

 

:biggrin:

 

Self service or help yourself.

But it's a joke; neuron2 is always polite and helpful. I believe he had really no time to have a look my trial scripts.

Best.

Edited by ricabullah
Link to comment

Hi, I have done some quick tests with the scripts you posted on neuron2.net but I have not been able to get them working yet, sometimes I have had some output but it is very slow and corrupted, also it still shows anaglyph colors, but most of the time I just get black output with 100% CPU and massive memory usage of the player (700MB+). Other Cuda programs are working so I will do some more tests with very simple scripts to check DGDecNV is working ok. Maybe I have to change something in DGIndexNV? I will do some more tests soon, please let me know if you have any ideas? Thanks.

Link to comment

I hope i will add the new thread this Sunday.

 

Meanwhile you may test this basic script with VirtualDubMod or GraphStudio:

 

LoadPlugin("C:\DG\DGDecodeNV.dll")

DGSource("E:\TEST\3D.dgi")

info()

 

Preventing to use multiple instances of DGDecoderNV just change the first three lines of AnaExtract.avs:

 

LoadPlugin("C:\DG\DGDecodeNV.dll")

vidOrig = DGSource(anaglyphName)

vidL = vidOrig

 

 

_ _ _ _

Edited by ricabullah
Link to comment
  • 2 weeks later...
  • 5 months later...
  • 9 months later...

The following shader converts a Side By Side stream to Stereoscopic 3D:

 


sampler s0 : register(s0);

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

if (frac(tex.y*540)>0.5)
 tex.x = tex.x + 0.5;

return tex2D(s0, tex);
}

 

 

 

 

Christian

 

 

Link to comment

Hi, Christian Hackbart.

I own the LG D2342P polarized monitor, so I use the HDMI graphics card output and HDMI monitor input. That kind of system works well at all but normaly I need to exchange left and right eyes in the MONITOR's menu to obtain the correct stereo effect. Some time ago I noted that exchanging eyes from the monitor's menu causes font distortions (try exchange eyes from monitor's menu an take a look on the desktop WITHOUT POLARIZAD GLASSES and you'll see a font distortion) so I tried to exchange eyes by software (F7 into the Stereoscopic Player). The only thing I need in DVBViewer is a shader that exchanges left and right halfparts of half-Side-By-Side image.

1. Could you guide me how to create such kind of shader?

2. Another kind of shader that I need is to extend left or rigth parts (only left or only right) of hSBS image and see it like 2D-image movie without glasses.

3. Is there any GENERAL manual about how to create your own shader on the net? I took a look into the ../shaders folder and see that shader is a C-style function but I haven't understood what are the input and output variables and how it works. Could you explain this a little bit?

 

Thanks in advance.

Edited by madsilence
Link to comment

The following shader converts a Side By Side stream to Stereoscopic 3D:

 


sampler s0 : register(s0);

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

if (frac(tex.y*540)>0.5)
 tex.x = tex.x + 0.5;

return tex2D(s0, tex);
}

 

Christian can you confirm a 3D monitor & glasses are needed for this?

Link to comment
  • 4 weeks later...

The following shader converts a Side By Side stream to Stereoscopic 3D:

 


sampler s0 : register(s0);

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

if (frac(tex.y*540)>0.5)
 tex.x = tex.x + 0.5;

return tex2D(s0, tex);
}

 

 

 

 

Christian

 

Ok,

Finally I copy the above mentioned lines to notepad, giving the extension "xml" and copy to the shader folder .

Tried it with 3D channels but it seems that something is wrong with the code.

Please check it by recording few minutes from a 3D SbS channel and try to play it with DVBViewer, You didn't get the a 3D picture.

To understand what I mean, please play this file with the Stereoscopic Player from :

http://www.3dtv.at/Products/Player/Index_en.aspx

To see how the file should be.

I watch 3D by emitter & Universal Home/Pro 3D LCD Shutter Glasses

 

Rittberg

Edited by Rittberg
Link to comment

Hi, Christian Hackbart.

I own the LG D2342P polarized monitor, so I use the HDMI graphics card output and HDMI monitor input. That kind of system works well at all but normaly I need to exchange left and right eyes in the MONITOR's menu to obtain the correct stereo effect. Some time ago I noted that exchanging eyes from the monitor's menu causes font distortions (try exchange eyes from monitor's menu an take a look on the desktop WITHOUT POLARIZAD GLASSES and you'll see a font distortion) so I tried to exchange eyes by software (F7 into the Stereoscopic Player). The only thing I need in DVBViewer is a shader that exchanges left and right halfparts of half-Side-By-Side image.

1. Could you guide me how to create such kind of shader?

2. Another kind of shader that I need is to extend left or rigth parts (only left or only right) of hSBS image and see it like 2D-image movie without glasses.

3. Is there any GENERAL manual about how to create your own shader on the net? I took a look into the ../shaders folder and see that shader is a C-style function but I haven't understood what are the input and output variables and how it works. Could you explain this a little bit?

 

Thanks in advance.

 

Try this post:

 

http://www.DVBViewer...s-to-interlace/

 

Or from above:

 

Change the tex.x = tex.x + 0.5

to tex.x = tex.x*0.5

(i think)

Edited by Imbalanced Zero
Link to comment

tex.x = tex.x*0.5 - Are you sure?

The Texturerange is in between 0 and 1. You already divided the position to the half and if you multiply it again with 0.5 you get 1/4 of the original position. This does not seem correct.

Link to comment
  • 7 months later...

According to the Oculus Rift SDK i created the following shader script. It should run, but i don't have such a device for testing​



//=========================================
// Name: Oculus Rift Shader
// Author: Christian Hackbart
//=========================================

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

#define ScreenCenter float2(0.5, 0.5)
#define LensCenter float2(0.5, 0.5)
#define Scale float2(0.35, 0.35)
#define ScaleIn float2(2,2)
#define HmdWarpParam float4(1.0, 0.22, 0.24, 0)

float2 HmdWarp(float2 in01)
{
float2 theta = (in01 - LensCenter) * ScaleIn; // Scales to [-1, 1]
float rSq = theta.x * theta.x + theta.y * theta.y;
float2 rvector = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq +
HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);
return LensCenter + Scale * rvector;
}

float4 main(float2 tex : TEXCOORD0) : COLOR
{
float xOffset = 0;
float2 clampOffset = float2(0.5,0.5);

tex.x = tex.x * 2;

if (tex.x > 1)
{
tex.x = tex.x - 1;
xOffset = 1;
}

float2 tc = HmdWarp(tex);

if (any(clamp(tc, ScreenCenter-clampOffset, ScreenCenter+clampOffset) - tc))
return 0;

tc.x = (tc.x + xOffset) / 2;
return tex2D(s0, tc);
}





Link to comment
  • 4 months later...

According to the Oculus Rift SDK i created the following shader script. It should run, but i don't have such a device for testing​



//=========================================
// Name: Oculus Rift Shader
// Author: Christian Hackbart
//=========================================

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

#define ScreenCenter float2(0.5, 0.5)
#define LensCenter float2(0.5, 0.5)
#define Scale float2(0.35, 0.35)
#define ScaleIn float2(2,2)
#define HmdWarpParam float4(1.0, 0.22, 0.24, 0)

float2 HmdWarp(float2 in01)
{
float2 theta = (in01 - LensCenter) * ScaleIn; // Scales to [-1, 1]
float rSq = theta.x * theta.x + theta.y * theta.y;
float2 rvector = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq +
HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);
return LensCenter + Scale * rvector;
}

float4 main(float2 tex : TEXCOORD0) : COLOR
{
float xOffset = 0;
float2 clampOffset = float2(0.5,0.5);

tex.x = tex.x * 2;

if (tex.x > 1)
{
tex.x = tex.x - 1;
xOffset = 1;
}

float2 tc = HmdWarp(tex);

if (any(clamp(tc, ScreenCenter-clampOffset, ScreenCenter+clampOffset) - tc))
return 0;

tc.x = (tc.x + xOffset) / 2;
return tex2D(s0, tc);
}





Hi,

 

i got my Oculus Rift a few days ago. But with this shader i can not get a 3d effect on for example Sky 3d or Astra 3d Demo Channel.

One reason is that the Picture is to big. So first i changed the size of the picture to fit better for the oculus rift display:

 

#define Scale float2(0.625, 0.95)

 

Now there is another Problem that the 2 rendered Pictures are each centered in the MIddle of their Screen side. This does not Match the Middle of the Oculus Rift Screen for left and right side. Then there is no 3d effect. The 2 Rendered Pictures need to be closer together to the Middle of the Screen. I need to move the left Picture more to the right and the right picture more to the left.

 

Do you have any hints for me to achieve this?

Link to comment

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...