Grafica Computazionale: Lezione 30 Grafica Computazionale lezione30 Introduction to OpenGL Informatica e Automazione, "Roma Tre" May 20, 2010 OpenGL Shading Language Introduction to OpenGL OpenGL (Open Graphics Library) is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics The API consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives OpenGL was developed by Silicon Graphics Inc (SGI) in 1992 and is widely used in CAD, virtual reality, scientific visualization, information visualization, and flight simulation It is also used in video games, where it competes with Direct3D on Microsoft Windows platforms (see OpenGL vs Direct3D) OpenGL is managed by a non-profit technology consortium, the Khronos Group Hiding complexity... ;) OpenGL serves two main purposes: Hide complexities of interfacing with different 3D accelerators by presenting a single, uniform interface Hide differing capabilities of hardware platforms by requiring support of full OpenGL feature set for all implementations (using software emulation if necessary).
Basic operations OpenGL is a low-level, procedural API OpenGL s basic operation is to accept primitives such as points, lines and polygons, and convert them into pixels This is done by a graphics pipeline known as the OpenGL state machine Most OpenGL commands either issue primitives to the graphics pipeline, or configure how the pipeline processes these primitives (attributes) Prior to the introduction of OpenGL 2.0, each stage of the pipeline performed a fixed function and was configurable only within tight limits OpenGL 2.0 offers several stages that are fully programmable using GLSL. OpenGL is a low-level, procedural API, requiring the programmer to dictate the exact steps required to render a scene This contrasts with descriptive (aka scene graph or retained mode) APIs, where a programmer only needs to describe a scene and can let the library manage the details of rendering it OpenGL s low-level design requires programmers to have a good knowledge of the graphics pipeline, but also gives a certain amount of freedom to implement novel rendering algorithms. Rasterised points, lines and polygons as basic primitives Evaluation OpenGL has historically been influential on the development of 3D accelerators, promoting a base level of functionality that is now common in consumer-level hardware: Simplified version of the Graphics Pipeline Process: Transform and lighting pipeline Z-buffering Texture mapping Alpha blending excludes a number of features like blending, VBOs (Vertex Basic Objects) andlogicops: Evaluation, if necessary, of the polynomial functions which define certain inputs, like NURBS surfaces, approximating curves and the surface geometry.
Vertex operations Rasterisation Vertex operations, transforming and lighting them depending on their material. Also clipping non visible parts of the scene in order to produce the viewing volume Rasterisation or conversion of the previous information into pixels. The polygons are represented by the appropriate colour by means of interpolation algorithms. Per-fragment operations Frame buffer Per-fragment operations, like updating values depending on incoming and previously stored depth values, or colour combinations, among others. Lastly, fragments are inserted into the Frame buffer. A framebuffer is a video output device that drives a video display from a memory buffer containing a complete frame of data.
First example In the 1980s, developing software that could function with a wide range of graphics hardware was a real challenge Software developers wrote custom interfaces and drivers for each piece of hardware This was expensive and resulted in much duplication of effort By the early 1990s, Silicon Graphics (SGI) was a leader in 3D graphics for workstations Their IRIS GL API was considered the state of the art and became the de-facto industry standard, overshadowing the open standards-based PHIGS This was because IRIS GL was considered easier to use, and because it supported immediate mode rendering By contrast, PHIGS was considered difficult to use and outdated in terms of functionality. SGI s competitors (including Sun Microsystems, Hewlett-Packard and IBM) were also able to bring to market 3D hardware, supported by extensions made to the PHIGS standard This in turn caused SGI market share to weaken as more 3D graphics hardware suppliers entered the market In an effort to influence the market, SGI decided to turn the IrisGL API into an open standard Meanwhile, SGI would continue to try to maintain their customers tied to SGI hardware by developing the advanced and proprietary Iris Inventor and Iris Performer programming APIs As a result, SGI released the OpenGL standard 1992 SGI led the creation of the OpenGL architectural review board (OpenGL ARB), the group of companies that would maintain and expand the OpenGL specification 1995 Microsoft released Direct3D, which would become the main competitor of OpenGL. OpenGL 1.0 Released January, 1992. The first OpenGL specification was released by Mark Segal and Kurt Akeley. OpenGL 1.1 Released January, 1997. OpenGL 1.1 focused on supporting textures and texture formats on GPU hardware
OpenGL 1.2 Released March 16, 1998. OpenGL 1.2 focused on supporting volume textures, packed pixels, normal rescaling, clamped/edge texture sampling and image processing. OpenGL 1.2.1 Released October 14, 1998. OpenGL 1.2.1 was a minor release after OpenGL 1.2 (March 16, 1998) which added multi-texture, or texture units, to the rendering pipeline. This allowed multiple textures to be blended per pixel during rasterization. OpenGL 1.3 Released August 14, 2001. OpenGL 1.3 added support for cubemap texture, multi-texturing, multi-sampling, and texture unit combine operations (add, combine, dot3, border clamp). OpenGL 1.4 Released July 24, 2002. OpenGL 1.4 added hardware shadowing support, fog coordinates, automatic mipmap generation, and additional texture modes.
http://www.songho.ca/opengl/gl v bo.html[vbos), occlusionqueries, andex [0] Introduction to OpenGL OpenGL Shading Language OpenGL 2.0 Released September 7, 2004. OpenGL 2.0 added support for a true, GPU-based assembly language called ARB (designed by the Architecture Review Board), which would become the standard for vertex and fragment shaders. Cards released with OpenGL 2.0 were the first to offer user-programmable shaders. OpenGL 2.0 was conceived by 3Dlabs to address concerns that OpenGL was stagnating and lacked a strong direction 3Dlabs proposed a number of major additions to the standard Most of these were, at the time, rejected by the ARB or otherwise never came to fruition in the form that 3Dlabs proposed However, their proposal for a C-style shading language was eventually completed, resulting in the current formulation of GLSL (the OpenGL Shading Language, also slang) Like the assembly-like shading languages that it was replacing, it allowed the programmer to replace the fixed-function vertex and fragment pipe with shaders, though this time written in a C-like high-level language. The design of GLSL was notable for making relatively few concessions to the limitations of the hardware then available; this hearkened back to the earlier tradition of OpenGL setting an ambitious, forward-looking target for 3D accelerators rather than OpenGL 2.1 Released July 2, 2006. OpenGL 2.1 introduced support for pixel buffer objects (PBOs), srgb textures (gamma-corrected textures), and non-square matrices, and the Shading Language revision GLSL 1.20.[15]
Features of OpenGL 3.0 OpenGL Shading Language revision 1.30 (GLSL) OpenGL 3.0 Released July 11, 2008. OpenGL 3.0 added support for frame buffer objects, hardware instancing, vertex array objects (VAOs), and srgb framebuffers (gamma 2.2).[16] OpenGL 3.0 introduced a deprecation mechanism to simplify the API in future revisions. Vertex Array Objects More flexible Framebuffer Objects 32-bit (single precision) floating-point textures and render buffers 16-bit (half precision) floating-point vertex and pixel data Ability to render vertex transformations into a buffer Texture arrays 32-bit (single precision) floating point depth buffer support Features of OpenGL 3.1 OpenGL Shading Language revision 1.40 (GLSL) OpenGL 3.1 Released March 24, 2009 and updated May 28, 2009. OpenGL 3.1 introduces a range of features to make the API more convenient to use, in addition to performance oriented features Texture Buffer Objects - a new texture type that holds a one-dimensional array of texels Uniform Buffer Objects for fast data share/update Signed normalized textures (±1.0 range) Aminimumof16 texture units accessible by the vertex shader Primitive restart Instancing -drawingofobjectsmultipletimesthroughthere-useof vertex data CopyBuffer API for fast data copy; used in conjunction with OpenCL
OpenGL 3.2 Released 3 August 2009 and updated 7 December 2009. OpenGL Shading Language revision 1.50 (GLSL) Geometry Shader support BGRA vertex component ordering Shader Fragment coordinate convention control Seamless cube map filtering Fragment depth clamping Multisampled textures and texture samples for specific sample locations Sync and Fence objects OpenGL 4.0 Released 11 March 2010 SupportedCards : nvidiageforcegtx 400series, ATIRadeonHD5000series Features of OpenGL 4 OpenGL Shading Language revision 4.00 (GLSL) Two new shader stages that enable the GPU to offload geometry tessellation from the CPU. Per-sample fragment shaders and programmable fragment shader input positions for increased rendering quality and anti-aliasing flexibility Shader subroutines for significantly increased programming flexibility. Separation of texture state and texture data through the addition of a new object type called sampler objects. Drawing of data generated by OpenGL or external APIs such as OpenCL, without CPU intervention. 64-bit double precision floating point shader operations and inputs/outputs for increased rendering accuracy and quality. OpenGL Shading Language GLSL This document describes a programming language that is a companion to OpenGL 4.0 and higher, called The OpenGL Shading Language. The OpenGL Shading Language is part of the core OpenGL 4.0 specification. The recent trend in graphics hardware has been to replace fixed functionality with programmability in areas that have grown exceedingly complex (e.g., vertex processing and fragment processing) The OpenGL Shading Language has been designed to allow application programmers to express the processing that occurs at those programmable points of the OpenGL pipeline Independently compilable units that are written in this language are called shaders Performance improvements; such as instanced geometry shaders,
Agraphicsprogramisasetofshaders A program is a set of shaders that are compiled and linked together. The aim of this document is to thoroughly specify the programming language The OpenGL entry points that are used to manipulate and communicate with programs and shaders are defined separately from this language specification. The OpenGL Shading Language is based on ANSI C and many of the features have been retained except when they conflict with performance or ease of implementation Chasbeenextendedwithvectorandmatrixtypes(withhardware based qualifiers) to make it more concise for the typical operations carried out in 3D graphics Some mechanisms from C++ have also been borrowed, such as overloading functions based on argument types, and ability to declare variables where they are first needed instead of at the beginning of blocks.