| |
| † news/blog † |
|
« | ‹ Prev |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Next › | »  |
| |
| Sat 04 Jul 09 - 3D - Early Z culling |
|
Early Z culling is a technique that optimizes the rendering process and it was used by J. Carmack in Doom3. The main idea behind Early Z is to make a depth pass prior the actual rendering in order to fill the depth buffer, then the scene is rendered normally (with color, shading, lighting etc) using the already calculated depths as a comparison medium. Only the pixels that will pass the depth test will eventually be processed for lighting and shading and those will be written in the color buffer. For a W*H resolution the number of pixels that will pass the depth test is W*H. The only drawback of Early Z is of course the extra depth pass.
The implementation of Early Z is very very simple and it doesn't require the help of pixel shaders or any other extension. In the first pass, the depth pass, we enable depth testing, we disable color writing and then we render our scene. In the second stage, where we render our scene normally, we keep depth testing enabled, we change the depth function so that only the pixels that have equal depth with the depth buffer will pass the test, and we enable the color writing. In code this may look like this:
// depth pass
glDepthMask( true );
glClear( GL_DEPTH_BUFFER_BIT );
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LESS ); // the default depth testing function
glColorMask( false, false, false, false ); // no color writing
RenderScene();
// material stage
glColorMask( true, true, true, true ); // re-enable color writing...
glClear( GL_COLOR_BUFFER_BIT );
glDepthMask( false ); // ...but disable depth writing
glDepthFunc( GL_EQUAL );
RenderScene();
Very simple, right? Actually its too simple to be true and Im thinking if I understand the Early Z correctly. Further test will prove if it optimizes the rendering time or not. Until then... enjoy!!!! |
|
| |
| |
| Fri 26 Jun 09 - New poll |
|
There is a new poll on your right and its about one of the most difficult choices someone has to make. What do you chose to listen to, your heart or your reason? Maybe you can help me out with your choice. |
|
| |
| |
| Mon 01 Jun 09 - Lyrics/Poetry - Man Against Man |
|
The site has been populated with computer stuff the past few months and I dont think that thats a good decision. Programming and 3D graphics are interesting but only for the 1% of the visitors, so Its time to write about something else and change the subject.
These are lyrics or a poem or call it whatever you want. Its about war and its called "Man Against Man". Hope you like it.
Man against man
Blast!!
Thunderous sound deafens the land
a blast so tremendous arises from behind
I know the reason, I forecast the result
the war has begun and we are stuck... stuck to the past
Expected was this obnoxious moment
surprise was not as it was recurrent
excessive cupidity forges the motive
and human acts... acts narrow minded
I find myself in a wrecked setting
buildings demolished, the ruins are smoking
I don't know what to do, I just keep walking
too much to think off and crying isn't helping
Red is the sky
the buildings all ruins
the trees nude and burnt
the roads deserted
The eyes quickly move around
they see the blood
but they cant assimilate the spectacle
They simply cant
Where I walk, in my path
stack of bodies ripped apart
crosscut limbs full of blood
these are the horrors I leave behind
In moments like these
you hope for a god
to ease your sorrow
to reset you to the past
Alas...
the hope isn't here
and the god is a fraud
the sorrow remains
rooted in a heart colored black
Look of what you've done
for you a soul equals none
for money and power you turn
...man against man |
|
| |
| |
| Fri 29 May 09 - 3D - Take screenshot in OpenGL |
|
Here is a code snippet showing how to take a screenshot and save it as a TGA file.
void TakeScreenshot( const char* filename )
{
// open file and check
fstream fs;
fs.open( filename, ios::out|ios::binary );
if( !fs.good() )
{
cout << "Cannot create screenshot. File \"" << filename << "\"" << endl;
return;
}
// write headers
unsigned char tga_header_uncompressed[12] = {0,0,2,0,0,0,0,0,0,0,0,0};
unsigned char header[6];
header[1] = window_width / 256;
header[0] = window_width % 256;
header[3] = window_height / 256;
header[2] = window_height % 256;
header[4] = 24;
header[5] = 0;
fs.write( (char*)tga_header_uncompressed, 12 );
fs.write( (char*)header, 6 );
// write the buffer
char* buffer = (char*)calloc( window_width*window_height*3, sizeof(char) );
glReadPixels( 0, 0, window_width, window_height, GL_BGR, GL_UNSIGNED_BYTE, buffer );
fs.write( buffer, window_width*window_height*3 );
// end
fs.close();
free( buffer );
cout << "Screenshot \"" << filename << "\" saved" << endl;
}
Pretty simple, right? |
|
| |
| |
| Mon 18 May 09 - 3D - Three screens from my engine |
|
Here are three screenshots illustrating a few models illuminated by two point lights and one "projected texture" light which casts a shadow. The illumination process is being done using deferred shading and you can also see the SSAO filter.
The next step is to add shadows to the point lights and integrate normal mapping in the current pipeline. A video illustrating all these would be great, unfortunately though the video capturing programs (like FRAPS) in Linux have speed issues with OpenGL.
|
|
| |
| |
| |
|
« | ‹ Prev |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Next › | »  |
|
|
|