Click to See Complete Forum and Search --> : Can someone explain the buffers(stencil) to me?(and more...)


Alluminitti
March 4th, 2005, 05:23 AM
What I know so far...
Hello,
Let me try to get this straight. When you setup a video mode to have 32 Bits-Per-Pixel you basically have a color buffer of the size of 2^32, meaning that you application can display 2^32 different colors if the GPU allows it. When you set a depth buffer to be 16 bits this means that your depth buffer is of size 2^16 and has 2^16 "levels" of z values(I'm still a little fuzzy on this one).

Stencil buffer concerns.
What about the Stencil buffer? My book says that you could use the Stencil buffer to block out portions of the screen from rendering. With this in mind how in the world can you make shadows by blocking out portions of the screen? That certainly doesn't make any sense unless the Stencil buffer has more uses than this.

Depth buffer question.
Back to the depth buffer. When a vertex passes the depth test this means that it's z-value is closer to the camera than the other vertex that the API compared it to? Of course this would depend on what kind of depth test you're performing. In OpenGL I always use GL_LEQUAL.


Matrix transformation order in OpenGL.
In OpenGL, the world/model and camera/view matrices are combined into one, modelview matrix. If memory serves me correct, the multiplication order of matrices are somewhat significant and typically in 3D applications you'd load the modelview matrix and then multiply that with the projection matrix. How comes in OpenGL(using it with SDL) its the complete opposite? I setup the projection matrix first, right after the window is created and then when I begin my scene I multiply an identity matrix with my camera. It stills work with OpenGL so I guess there is no significances with the order in which you concatonate/multiply matrices in OpenGL?

Leo77
March 5th, 2005, 12:37 PM
Im not the master about buffers... but as far as I know, stencil buffer is like a mask - you choose an area of the scene to draw. You can use it to make mirrors for exemple - this way you could draw only in the mirror area...

hope I could help

Elementer
March 6th, 2005, 07:19 AM
Hello,
reply need about 3000 pages :D
Suppose you want to restrict the rendering rectangle within the window, you must mask out an irregularity shaped area. Insted using a scissor box, you can use a stencil pattern. You can image the stencil as a flat piece of cardboard that has a pattern cut out of it, for example the "A" pattern, and when you spray on it, the "A" will be draw, and other color that doesn't need, remain on the cardboard.
OGL have the stencil buffer for this, where you can create the stencil pattern by yourself, you can create all pattern you want simple with rendering commands.

OGL draw in a lot of buffers, the color values are placed into a color buffer etc..., and the depth values of pixels are placed in the depth buffer. Thus, if depth test is enabled, OGL perform some tests on pixels values for undestand what pixel is visible if there are a lot of pixel one on the other, otherwise, OGL will write the depth values for all color fragment that go to the color buffer.

About matrix, that thing is simple. The projection matrix is used for setup the camera, so perspective view, angle of view, layout and viewport calculation etc... must be here. Other things (drawing) must be in modelview matrix. What type of order are you say about ? If you mean rotation, scale and translation, there is difference between rotate-translate and translate-rotate, becouse if you suppose a object at (0,0) that you want to move it on right, if you rotate first, your object will be in the plane X+Y+, else, if you translate first, the object will be on X+ axis at some distance from origin.

Regards :)