PDA

View Full Version : Please, I need some help!!!!



ArkAnjo
12-05-2002, 05:56 PM
Hi,

Well, I need to do the following steps:

1 I will load a 3D Object and rotate it three times in different directions, then I'll save the buffers A, B and C ( A= Rotation 1, B= Rotation 2 and C= Rotation 3).... at buffer "A" I'll only let the RED Channel active (i.e. if the pixel "x" is 101,011,111 - it'll change to 101,000,000 ), at buffer "B" only GREEN channel.. and so on;

2 Now, I need to do an OR operation between the RGB Channels from the buffers ( A,B and C) for each pixel and save the result:

Pixel X in Buffer A: R -> (101,000,000)
Pixel X in Buffer B: G -> (000,110,000)
Pixel X in Buffer C: B -> (000,000,010)
----------------------------
Pixel X in Buffer R: RGB -> (101,110,010)

3 Show at screen

Well, the result is a Stereogram of the original 3D Object

=>Is there any other function besides glReadPixels() that will help me doing this?

[This message has been edited by ArkAnjo (edited 12-05-2002).]

rgpc
12-05-2002, 06:06 PM
glColorMask()

Ysaneya
12-06-2002, 12:30 AM
You need to stop thinking at the pixels level. You can't access the frame buffer directly, and if you do it indirectly with glReadPixels, chances are it will be extremely slow (unless you only do it for a small window) due to the video memory read back.

You can use the color mask; an alternative would be to use a pure red light in a first pass, render A; clear ZBuffer; then do again with a green light and B; clear and finally with a blue light and C.

Y.

ArkAnjo
12-06-2002, 02:19 AM
[This message has been edited by ArkAnjo (edited 12-06-2002).]

ArkAnjo
12-06-2002, 02:21 AM
Originally posted by Ysaneya:
"chances are it will be extremely slow"

Ysaneya: I know that if I do this operantion between pixels it 'll be really slow ( O n) but at this moment it isn't important in my work. I'll try the way you suggest too (Color Mask), Tks for your attention.

PS.: I've already think in this alternative that you suggest -> "using a pure red light in a first pass, render A; clear ZBuffer; then do again with a green light and B; clear and finally with a blue light and C"... but if I do this, it'll be a fake stereogram , because in any moment I did the operation between the channels color, the result is 3 frames rendering extremely fast that give the impression of a stereogram.


[This message has been edited by ArkAnjo (edited 12-06-2002).]

ArkAnjo
12-06-2002, 02:36 AM
Originally posted by rgpc:
glColorMask()

Tks for your help.

Ysaneya
12-06-2002, 08:41 AM
but if I do this, it'll be a fake stereogram , because in any moment I did the operation between the channels color, the result is 3 frames rendering extremely fast that give the impression of a stereogram.


I'm not sure to understand you well here :) Do you mean you're not using double-buffering, and you can see in "live" the objects being painted on screen ?

Y.

zeckensack
12-06-2002, 08:51 AM
*ahem*

glColorMask(true,true,true,true); //make sure we clear all colors
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
glColorMask(true,false,false,true);
render_thingy(); //will only go to red channel
glClear(GL_DEPTH_BUFFER_BIT);
jitter_a_bit();
glColorMask(false,true,false,true);
render_thingy(); //will only go to green channel
glClear(GL_DEPTH_BUFFER_BIT);
jitter_a_bit_more();
glColorMask(false,false,true,true);
render_thingy(); //will only go to blue channel
SwapBuffers(blabla);Rinse, wash, repeat.

ArkAnjo
12-06-2002, 09:02 AM
Originally posted by Ysaneya:
I'm not sure to understand you well here http://www.opengl.org/discussion_boards/ubb/smile.gif Do you mean you're not using double-buffering, and you can see in "live" the objects being painted on screen ?

Y.


I'll try to explain.. err http://www.opengl.org/discussion_boards/ubb/smile.gif let see...

When you told to me:

"using a pure red light in a first pass, render A; clear ZBuffer; then do again with a green light and B; clear and finally with a blue light and C"...

Did you mean that every time that I clear the ZBuffer I'll show it before clear, then do again with green light... show and clear.... and finally with a blue light.. show and clear... or am I wrong?


if I'm right, then.... this process didn't create a true stereogram, because it'll be showing the object in Red .. then Green and Blue ( 3 frames )... and i need all these frames in one

Well, if I'm wrong... heheh I didn't understand what did you try to explain to me http://www.opengl.org/discussion_boards/ubb/smile.gif before...

PS.: I need to use a Double Buffering... or I 'll never find a way to create my stereogram http://www.opengl.org/discussion_boards/ubb/smile.gif ...

ArkAnjo
12-06-2002, 09:32 AM
Originally posted by zeckensack:
*ahem*

glColorMask(true,true,true,true); //make sure we clear all colors
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
glColorMask(true,false,false,true);
render_thingy(); //will only go to red channel
glClear(GL_DEPTH_BUFFER_BIT);
jitter_a_bit();
glColorMask(false,true,false,true);
render_thingy(); //will only go to green channel
glClear(GL_DEPTH_BUFFER_BIT);
jitter_a_bit_more();
glColorMask(false,false,true,true);
render_thingy(); //will only go to blue channel
SwapBuffers(blabla);Rinse, wash, repeat.

Tks man.. I'll try it..

Ysaneya
12-06-2002, 10:55 AM
Did you mean that every time that I clear the ZBuffer I'll show it before clear, then do again with green light... show and clear.... and finally with a blue light.. show and clear... or am I wrong?


Nah, you're reading more than i wrote http://www.opengl.org/discussion_boards/ubb/smile.gif You don't display a ZBuffer (how can you do? it stores depth values, not colors!), you display a color buffer; you can clear the ZBuffer without having to render a new image in the color buffer. So basically, you clear the color buffer once, do the 3 rendering steps with the ZBuffer clear, THEN display the color buffer at the end.

This is kindda equivalent to the glColorMask method, except using lights instead of a mask. Probably no speed difference between the two (but anyway you're not worried with that!).

Y.


[This message has been edited by Ysaneya (edited 12-06-2002).]

ArkAnjo
12-06-2002, 07:37 PM
Originally posted by Ysaneya:
Nah, you're reading more than i wrote http://www.opengl.org/discussion_boards/ubb/smile.gif You don't display a ZBuffer (how can you do? it stores depth values, not colors!), you display a color buffer; you can clear the ZBuffer without having to render a new image in the color buffer. So basically, you clear the color buffer once, do the 3 rendering steps with the ZBuffer clear, THEN display the color buffer at the end.

This is kindda equivalent to the glColorMask method, except using lights instead of a mask. Probably no speed difference between the two (but anyway you're not worried with that!).

Y.


[This message has been edited by Ysaneya (edited 12-06-2002).]


hehehehe http://www.opengl.org/discussion_boards/ubb/smile.gif well, know it's clear.. hehehe.. I'll try both .. tks very much