Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
Technical Blog: http://www.rastergrid.com/blog/
Hii Aqnuep,
if you don't mind, I wanna ask another question. Consider I have two objects, let's say a cube and a sphere. I wanna occluded the sphere with my cube. But before doing that, I wanna changed every pixel of the cube to be the pixel of my backgroud. therefore, when my cube occluded my sphere, it displayed the color of my background with the shape of cube. Can you help me how to do that?
thanks
Sorry but I don't understand completely what is your scenario.
So you have a real world image, having a cube in it and a sphere rendered? You want the real world cube to hide the sphere or the other way around? Also, what do you mean by the "color of your background"? You mean the real world image pixels?
Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
Technical Blog: http://www.rastergrid.com/blog/
Yes, I did. I said the color of my background e.g black, and did not talk about the real scene to simplify the scenario. it is exactly of what you said. I have a real world image, consists of real cube, virtual cube and sphere. as the virtual cube has been accurately registered to real cube, the projective position of virtual cube in the image plane is known. therefore, before occluding the sphere with the cube, I want to change every pixel of the virtual cube with the real one. after that, by making use of OpenGL depth buffer, every pixel of virtual sphere which depth value is less than 1.0 will be replaced by the pixel from the real cube's image.
You don't need to redraw the pixels of the cube, simply don't render it to the color buffer in the first place. When you render your virtual cube, simply disable all components of the color masks as I specified in an earlier post. That's all. Then when you render your cube, only the depth buffer is updated but you don't update any pixels of the screen. Then re-enable the color mask when rendering the sphere so that those pixels will get their way to the color buffer too.
Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
Technical Blog: http://www.rastergrid.com/blog/
Well, understood.. but, if I render the sphere after the cube, the depth value of my sphere is less than the cube so that the real scene pixel (from disabling glColorMask) will be occluded by the pixel of the sphere. Is it true according to my knowledge? Please correct me if i'm wrong.. thanks.