Wednesday, June 30, 2010

Windows 7 Dell Optiplex Gx620

Because OpenGL> Direct3D? 10 reasons.

El Sr. Engine ha recorrido un larguisimo camino, y la verdad es que finalmente se empieza a sentir que falta poco.
Aca hay una escena de prueba en progreso (todavia no esta terminada), lo mejor de todo es que por como esta programado, y gracias a hacks que solo se pueden hacer en OpenGL (no en Direct3D ) esto corre de forma safable hasta en una geforce 6100.



No hay nada precomputado ( lightmaps /ambientmaps/etc), todo es en tiempo real.
In large part, thanks to OpenGL. Why?
First of all it must be remembered that I am referring to GL 2.1 vs Directx9 (D3D10 and GL3 are almost identical), but if you want to do something that will run on all computers, you can not use DirectX10 or any form Lengua GL3

1) Batching

The GL function calls are infinitely cheaper than in D3D, first by not having to use objects, but because the userspace Batch commands are then sent to the driver. (In Direct3D almost everything goes straight to the driver ). This allows changes of materials / shaders / binder arrays / etc at low cost.

2) Built-in uniforms

OpenGL 2.1 is fixed throughout the state of pipeline access, all the lights, materials, etc. This allows, with a little effort, do not wear uniforms and create shaders very little ones, maximizing the possibility of using conditonal compilation, since the state is persistent even when switching between shaders (something like bindable uniforms in ancient plates), and switching between shaders is almost free (thanks to the batching and not have to climb uniforms), you can draw eg, multiple lights in one pass and switch between combinations of light to a huge performance.


3) Fast / deferred shader compile

The compilation of shaders OpenGL is very fast. Simply rapidisma. Mainly because the compiler only and then walks
code does the rest of the compilation on-demand (when the shader is used.) You can compile hundreds of shaders in a few seconds.
In D3D, the compilation is comparatively slower because there are several steps: a) Compilation of assembler (D3DX) b) Increase the assembler c) The assembler of D3DX decompiled and recompiled the driver optimized for the board (since the video card vendors optimize each one for your plate.) In theory, D3D can store precompiled shaders, which speeds up the process, but in practice, this last step makes it not too much difference.

4) Persistent attributes / texcoords

The texcoords and attributes are persistent. This means that although they are always not bind (the last value is set). In contrast, prohibits Direct3D9 create shaders using a TexCoord / that is not bind at a StreamSource. Simply the shader does not work.
This is horrible, because it allows an engine to have a separation between geometry and material without having to compile a version of the shader that uses the same arrays that have the geometry.

5) Readable / Writable Depth Buffer

The binder depth buffers can be read as OpenGL texture, and not only that but percolates even oldest hardware (provided they are power of 2!). That allows this? do A big things on old hardware that nothing else can be done in DX10, vista +, such as


  • Retrieve the position of a fragment




  • Shadow maps super cheap (just write a depth buffer), cheaper even using a 16-bit depth buffer




  • ESM (Exponential Shadow Maps) a bargain on ancient hardware, taking advantage that you can read / write using gl_FragDepth Blur, and filter




  • ZClipping of particles, with borders fadeados




  • superbarato SSAO (the depth buffer read / wrote the shadow buffer)




  • DOF superbarato





  • 6) read / write buffers and CopyTexSubImage

    Some techniques require make copies of buffers. GL provides read / write buffers, to do this without having to use shaders / geometry, which is also considerably faster. GL
    allows enable / disable writing to different components of a framebuffer . This is _buenisimo_, such components to store data in different countries. Techniques that were me were used this barbaric glow send the alpha channel (and lock when drawing transparent objects) and especially useful for techniques such as dual paraboloid shadow mapping or PSSM , because I can save the data (depth) in a single texture if I, help a lot to the cache and release texunits.

    8) Built-in TC

    In Direct3D texture compression formats exist, but you have to upload the data to hand tablets, or they are already saved. While it is becoming fashionable in DirectX10 make a DXT compression, BC, etc in a shader at the time to upload the texture . OpenGL makes it automatically (to ask him) even in old plaques.

    9) Built-in Memory Management

    In Direct3D there diferetes memory types (pools) where the arrays are the textures. Each has different restrictions. If you choose to send it to the video memory, then the texture or the array can not be recovered .. and if it devicelost occur (which happens only when a window resizer Cheesy), you lose everything! Some engines handle everything by hand, but the truth is that it's a letdown to have to worry about where each thing, so MANAGED Direct3D offers an option that saves a copy in system memory resource. If you ever wondered why D3D games take so much memory, this is the answer. Windows Vista virtualize video memory to avoid that when the hardware is provided. OpenGL on the other hand up and down the video memory resources when necessary and to provide algorithms LRU on old hardware, the programmer does not have to worry about where it going, or at best provide hints of use.

    10) OpenGL is a standard

    OpenGL is a standard, you can set / run on linux , windows, mac , cell , tablets, etc.

    Source: http://www.adva.com.ar/foro/index.php?topic=7005.0

    0 comments:

    Post a Comment