HW accelerated anaglyph creation in C... Log Out | Topics | Search
Moderators | Register | Edit Profile

stereo3d.com webboard » 3D News - announce and discuss new products & services here » HW accelerated anaglyph creation in Cg (pixel and vertex shaders) « Previous Next »

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

M.H.

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, April 19, 2004 - 2:02 pm:   Edit PostDelete PostView Post/Check IPPrint Post

Cg tutorial showing HW acceleraten anaglyph creation
Top of pagePrevious messageNext messageBottom of page Link to this message

M.H.

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, April 19, 2004 - 2:07 pm:   Edit PostDelete PostView Post/Check IPPrint Post

I am not a big fan of anaglyph, but during my work on autostereoscopic
monitor support during DepthQ development, I have find a very effective
super fast flexible method for on the fly anaglyph creation of any sort ...

The technology can be used especially for on the fly anaglyph creation
in games or in stereo-video applications.
It could be used for user/device flexible ana glyph algorithm modification
without coding knowledge as well ...

Principle:
Transfer your data in 2 textures.
Use vertex and pixel shader to create the anaglyph ...

Non coding specialist can load the Cg Tutoral examples fron nVidia
www and put my code in the tutprial 3 (2 textures) example to see what I mean.

The method will work on both nVidia and ATI system uder boeth DirectX and OpenGL ....

Advantage of the methods:
1) Cg code producing the output can be outside the application - anybody can
create anagpyph based on his taste ...
2) Anaglyph is created in a way faster than any software way (even MMX optimzied) is capable ..
3) Application useing exteranl Cg script makes possible analgylph algorithm toning and modification
without original aplication modification

Vertex shader used in the example:
struct C3E5v_Output {
float4 position : POSITION;
float2 leftTexCoord : TEXCOORD0;
float2 rightTexCoord : TEXCOORD1;
};

C3E5v_Output C3E5v_twoTextures(float2 position : POSITION,
float2 texCoord : TEXCOORD0,

uniform float2 leftSeparation,
uniform float2 rightSeparation)
{
C3E5v_Output OUT;

OUT.position = float4(position, 0, 1);
OUT.leftTexCoord = texCoord + leftSeparation;
OUT.rightTexCoord = texCoord + rightSeparation;

return OUT;
}

Pixel shader used in the examlpe (showing 2 different anaglyph algoriehms):
void C3E7f_twoTextures(float2 leftTexCoord : TEXCOORD0,
float2 rightTexCoord : TEXCOORD1,

out float4 color : COLOR,

uniform sampler2D decal0,
uniform sampler2D decal1)
{
float4 leftColor = tex2D(decal0, leftTexCoord);
float4 rightColor = tex2D(decal1, rightTexCoord);

// Original code form nVidia SDK example
//color = lerp(leftColor, rightColor, 0.5);

// algorithm 1 simple color replacement from both sources
/*
color.g = leftColor.g;
color.r = rightColor.r;
color.b = rightColor.b;
*/

// algorithm 2 grayscale mixture in components (put the grayscale coeficeitn based on your taste)
float grayLeft=0.1*leftColor.b+0.3*leftColor.r+0.6*leftColor.g;
float grayRight=0.1*rightColor.b+0.3*rightColor.r+0.6*rightColor.g;
color.r = grayLeft;
color.g = 0;
color.b = grayRight;
// e.t.c e.t.c. ...
}

Add Your Message Here
Post:
Bold text Italics Underline Create a hyperlink Insert a clipart image

Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action:

Topics | Last Day | Last Week | Tree View | Search | User List | Help/Instructions | Program Credits Administration