Framebuffer Objects. Emil Persson ATI Technologies, Inc.
|
|
- Juniper Simon
- 6 years ago
- Views:
Transcription
1 Framebuffer Objects Emil Persson ATI Technologies, Inc. Introduction Render-to-texture is one of the most important techniques in real-time rendering. In OpenGL this was traditionally handled with calls to glcopyteximage2d() and glcopytexsubimage2d(). The problem with this approach, however, is that window size limits the maximum possible resolution of the rendered texture, particularly with power-of-two textures. For example, the largest possible render target for an 800x600 window is only 512x512. Also, all render-to-texture operations must be completed in the beginning of the frame in order to not overwrite any content of the framebuffer. In response to all these limitations, PBuffers got utilized as a render-to-texture solution and quickly became the standard method for implementing render-to-texture in OpenGL. PBuffers permit off-screen rendering and allow resolutions independent of the main framebuffer, but require a copy to occur from the PBuffer data into a texture. To solve this problem WGL_ARB_render_texture was introduced, allowing applications to bind a PBuffer to a texture directly; avoiding the copy. This is where render-totexture in OpenGL has been for quite a while now. The solution has not been popular among developers, though, for several reasons, and many have looked to Direct3D s implementation of render-to-texture as a standard for how render to texture should really be implemented. One of the biggest complaints of PBuffers is their requirement for unique GL contexts. This means that the application must keep track of multiple sets of states, which is cumbersome and inconvenient. Additionally, context switching is an expensive operation. Another important issue with PBuffers is that each PBuffer has its own color, depth and stencil buffers and there is no way to share them. This is both expensive in terms of memory and limiting in terms of functionality. For example, it is not possible to perform depth-only rendering. Instead, a color buffer must always be present. Another problem is that PBuffers are windowing system dependent. PBuffers started off as an extension to GLX and later a WGL version was ratified. This means that applications wishing to run on more than one OS would have to use different code paths. Also, no GLX version of WGL_ARB_render_texture was ever ratified by the ARB (however, there is a GLX_ATI_render_texture). Other complaints are that initialization is cumbersome and too disconnected from regular textures, that it requires additional calls when binding a PBuffer as a texture, that there s no control over when the mipmaps are actually generated when automatic mipmap generation is enabled, and so on. Only the least desirable characteristic of Direct3D render targets is also present with PBuffers, namely the fact that buffers can get lost. So in short, OpenGL needed a better render-to-texture solution; enter the FramebufferObject extension.
2 The GL_EXT_framebuffer_object extension (FBO for short) is essentially built from scratch and does not carry with it the baggage of earlier render-to-texture solutions. FBO has all of the following attributes: Integrates directly with regular textures Requires no extra GL contexts Is windowing system independent Allows the application to control when mipmap generation occurs Allows rendering to a target without a colorbuffer Allows depth, stencil and color buffers to be shared, and No buffers ever get lost The basics Objects There are a number of important kinds of objects in GL_EXT_framebuffer_object. The central part of FBOs is the framebuffer object, which encapsulates all the state related to a framebuffer. A framebuffer in this context means a collection of logical buffers. A logical buffer is one of color, depth or stencil buffer. The logical buffers are created independently and are attached to framebuffer objects. A framebuffer object can have one or more color buffers, one depth buffer and one stencil buffer attached. A logical buffer can be attached to one or more framebuffers objects. Attach in this context means that the logical buffer gets connected to the object in a similar way as various bind operations (such as glbindtexture()) work, except that attaching does not create a new object if an unused value is passed to it. Each framebuffer object has a set of attachment points that logical buffers can be attached to. The attachment points are COLOR[n], DEPTH and STENCIL. The logical buffers can be attached to several framebuffer objects. Creating buffers To create a framebuffer object the glgenframebuffersext() command is called. Color buffers are created with the regular glgentextures() call and set up with the glteximage2d() function, except when you want to create a render target you typically pass NULL to the pixels parameter. It is valid however to provide an image and later overwrite it or parts of it by rendering to the texture. A typical FBO initialization code looks something like this:
3 GLuint fbo, color; // Create an FBO glgenframebuffersext(1, &fbo); // Create color texture glgentextures(1, &color); glbindtexture(gl_texture_2d, color); // Bind the FBO and attach color texture to it glbindframebufferext(gl_framebuffer_ext, fbo); GL_TEXTURE_2D, color, 0); To render to this color texture simply call: glbindframebufferext(gl_framebuffer_ext, fbo); And to return to rendering to the main framebuffer you would call: glbindframebufferext(gl_framebuffer_ext, 0); Now color can be used like any regular texture for rendering. Normally you would also like to use a depth buffer when rendering to a texture. Depth and stencil buffers are created with glgenrenderbuffersext() and set up with glrenderbufferstorageext(). The additional code for creating a depth buffer looks as follows: // Create depth renderbuffer glgenrenderbuffersext(1, &depth); glbindrenderbufferext(gl_renderbuffer_ext, depth); glrenderbufferstorageext(gl_renderbuffer_ext, GL_DEPTH_COMPONENT16, height); width, To attach it to the currently bound FBO you call: glframebufferrenderbufferext(gl_framebuffer_ext, GL_RENDERBUFFER_EXT, depth); GL_DEPTH_ATTACHMENT_EXT,
4 Again, to render to this texture you call glbindframebufferext() and then again with zero when you want to return to the main framebuffer. Changing render targets There are three different ways to switch between framebuffers. The first one is to use several different FBOs, one for each combination of logical buffers that you plan on using in you application. To change render targets you simply call glbindframebufferext() with the FBO containing the setup you wish to render to. The initialization code would look something like this: GLuint fbo[2], color[2]; // Create two FBOs glgenframebuffersext(2, fbo); // Create two color buffers glgentextures(2, color); glbindtexture(gl_texture_2d, color[0]); glbindtexture(gl_texture_2d, color[1]); // Attach the color buffers to the FBOs glbindframebufferext(gl_framebuffer_ext, fbo[0]); GL_TEXTURE_2D, color[0], 0); glbindframebufferext(gl_framebuffer_ext, fbo[1]); GL_TEXTURE_2D, color[1], 0); Then the rendering code would be as follows: // Render to color0 glbindframebufferext(gl_framebuffer_ext, fbo[0]); // Render to color1 glbindframebufferext(gl_framebuffer_ext, fbo[1]); // Return to rendering to main framebuffer glbindframebufferext(gl_framebuffer_ext, 0); Another way is to use a single FBO and alter the attachments. The setup could looks like this:
5 GLuint fbo, color[2]; // Create an FBO glgenframebuffersext(1, &fbo); // Create two color buffers glgentextures(2, color); glbindtexture(gl_texture_2d, color[0]); glbindtexture(gl_texture_2d, color[1]); And then the rendering code would be as follows: // Render to color0 glbindframebufferext(gl_framebuffer_ext, fbo[0]); GL_TEXTURE_2D, color[0], 0); // Render to color1 GL_TEXTURE_2D, color[1], 0); // Return to rendering to main framebuffer glbindframebufferext(gl_framebuffer_ext, 0); The third way is to use a single FBO, but instead of altering attachments you call gldrawbuffer() or gldrawbuffers() to change which color attachment(s) the rendering goes to. To set it up:
6 GLuint fbo, color[2]; // Create an FBO glgenframebuffersext(1, &fbo); // Create two color buffers glgentextures(2, color); glbindtexture(gl_texture_2d, color[0]); glbindtexture(gl_texture_2d, color[1]); // Attach the color buffers to the FBO glbindframebufferext(gl_framebuffer_ext, fbo); GL_TEXTURE_2D, color[0], 0); glframebuffertexture2dext(gl_framebuffer_ext, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, color[1], 0); And for rendering: // Render to color0 glbindframebufferext(gl_framebuffer_ext, fbo); gldrawbuffer(gl_ COLOR_ATTACHMENT0_EXT); // Render to color1 gldrawbuffer(gl_ COLOR_ATTACHMENT1_EXT); // Return to rendering to main framebuffer glbindframebufferext(gl_framebuffer_ext, 0); Which method to use is mostly a personal preference or depends on what s most convenient in your case. The first method makes things easy in the rendering code, but the setup code is larger. The second method is the most general and most similar to the Direct3D model. The last method will likely have the least driver overhead (though this may change between drivers), but is also the most limited. You can only switch between color render targets this way. To change depth and stencil buffer you ll have to change the attachments. Render to cubemaps and volumes The most common render-to-texture operation is rendering to a regular 2D texture. Also fairly common is rendering to a cubemap. New in GL_EXT_framebuffer_object is rendering to a volume texture, something that could not be done with PBuffers.
7 Rendering into a cubemap is not that different from rendering to a 2D texture. You create an FBO as usual and a texture object. Then you size the six faces: // Create a cubemap color buffer glgentextures(1, &color); glbindtexture(gl_texture_cube_map, color); for (int face = 0; face < 6; face++){ glteximage2d(gl_texture_cube_map_positive_x + face, 0, GL_RGBA8, width, height, 0, } A cubemap is naturally rendered to face by face. To render to a particular face you attach that face to the FBO, for instance: GL_TEXTURE_CUBE_MAP_POSITIVE_X, color, 0); For volume rendering the procedure is about the same: // Create a volume color buffer glgentextures(1, &color); glbindtexture(gl_texture_3d, color); glteximage3d(gl_texture_3d, 0, GL_RGBA8, width, height, depth, 0, GL_UNSIGNED_BYTE, NULL); GL_RGBA, Rendering to a volume is not surprisingly done slice by slice. There s an extra parameter in the glframebuffertexture3dext() call that selects what slice in the volume to render to: glframebuffertexture3dext(gl_framebuffer_ext, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_3D, color, 0, zoffset); Render to depth Unlike with PBuffers it is possible to create an FBO with just a depth attachment and no color buffers. After rendering, the depth buffer can be used as texture directly (though the driver may have to do a copy on some hardware). This is useful for techniques such as shadow mapping. Creating a texture for depth rendering is similar to creating a color texture; we just need to choose a depth format:
8 // Create depth texture glgentextures(1, &depth); glbindtexture(gl_texture_2d, depth); glteximage2d(gl_texture_2d, 0, GL_DEPTH_COMPONENT16, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL); This will be our depth buffer, but it is a texture and not a renderbuffer, so to attach it to the FBO we call glframebuffertexture2dext(), but hook it up to the depth attachment point: // Bind the FBO and attach depth texture to it glbindframebufferext(gl_framebuffer_ext, fbo); glframebuffertexture2dext(gl_framebuffer_ext, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depth, 0); By default the draw-buffer and read-buffer for an FBO is GL_COLOR_ATTACHMENT0_EXT, meaning that the driver will expect there to be a color buffer attached to render to. Since we don t have a color attachment the framebuffer will be considered incomplete. Consequently, we must inform the driver that we do not wish to render to the color buffer. We do this with a call to set the draw-buffer and readbuffer to GL_NONE: gldrawbuffer(gl_none); glreadbuffer(gl_none); Note that this is a per-fbo state, so if you re using separate FBOs for each render-to-texture setup, you can make these calls once at setup and forget it. If you re using a global FBO and altering attachments you need to restore the draw-buffer and read-buffer states for regular color rendering: gldrawbuffer(gl_color_attachment0_ext); glreadbuffer(gl_color_attachment0_ext); Mipmap generation For the best quality it is often desirable to have rendered textures mipmapped. Normally one would like the mipmap sublevels to be generated by down-sampling the base level. The GL_SGIS_generate_mipmap extension was usually used with PBuffers to generate the sublevel, and it s still valid to use it with FBOs. However, GL_EXT_framebuffer_object also adds a new glgeneratemipmapext() function for this purpose which allows more fine-grained control over when mipmap generation occurs. With this function the application can manually generate the mipmaps when it so desires, which is done like so:
9 glbindtexture(gl_texture_2d, color); glgeneratemipmapext(gl_texture_2d); This function may be applied to textures used as render targets or any regular texture; thus glgeneratemipmapext() can fully replace GL_SGIS_generate_mipmap. Multiple render targets Using multiple render targets with FBOs is a piece of cake. What we need to do is simply attach all the color buffers to the FBO s different color attachments points. Then the draw buffers need to be set. // Attach color buffers for MRT GL_TEXTURE_2D, color[0], 0); glframebuffertexture2dext(gl_framebuffer_ext, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, color[1], 0); glframebuffertexture2dext(gl_framebuffer_ext, GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_2D, color[2], 0); glframebuffertexture2dext(gl_framebuffer_ext, GL_COLOR_ATTACHMENT3_EXT, GL_TEXTURE_2D, color[3], 0); // Setup draw buffers GLuint drawbuffers[4] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_COLOR_ATTACHMENT3_EXT, }; gldrawbuffers(4, drawbuffers); Note that even though GL_EXT_framebuffer_object provides an interface for MRT it may not be supported on all implementations. You should check if GL_ARB_draw_buffers or OpenGL 2.0 is present, and you must call glgetintegerv() with GL_MAX_DRAW_BUFFERS to see how many drawbuffers the implementation supports. Some hardware and/or drivers may only support a single color buffer. Additional restrictions apply, too, such as all draw-buffers must have the same size and internal format. The latter restriction is expected to be alleviated in an additional extension. Porting from PBuffers To context-hell and back When porting existing code using PBuffers to FBOs it s easy to forget the fundamental differences in behavior between the two. This will more than likely cause a good deal of headaches in anything but trivial applications. Chances are that the change also exposes bugs you ve [un-]luckily been dodging all the time.
10 As in real life, removing barriers is certainly a good thing, but undoubtedly unwanted elements will flow over the borders too, in both directions. That s certainly the case when breaking the walls to the PBuffers protected little world inside their own GL-contexts. Undesirable GL-states will surely flow in and out of your render-to-texture code. Whether intentional or not, applications built around PBuffers are likely to set global states and expecting them to live the entire frame, or even the entire lifespan of the application. An application may for instance set the projection matrix in the beginning of each frame and be happy with that. When rendering to the PBuffer it has its own projection matrix, so if it changed as part of the render-to-texture operation it only affected the current PBuffer, and the main context had its matrix unaffected. When changing this to FBOs it obviously causes problems. Fixing the code to restore the projection matrix is generally not a problem, but finding out that this is the reason why the rendering totally broke down can be quite tricky. Similarly, when rendering to the texture the application could easily set a bunch of states, and never care about restoring any of them when it s done since they only affect that particular context. When changing to FBOs those states will of course survive over to the rendering passes that follow. One of the first issues you ll likely bump into when bringing up your first FBO in your application is that things look stretched, are packed in the corner of the render target or nothing shows up at all, in particular with very large or small textures. With PBuffers having their own context they also have their own viewport state. So when switching to a PBuffer, the viewport would automatically change that in the PBuffer s context, which defaults to the exact size of the PBuffer. Not so with FBOs though since they don t have a context of their own. Instead, the viewport is still that of the main framebuffer so unless the render target is the exact size of the main framebuffer you have to call glviewport() to set the viewport to the size of the render target, and then back to the size of the main framebuffer again when you re done. There are of course loads of states that could cause problems, but some common ones to look for are: The projection and modelview matrices Blending mode/op/factors Depth test Color and depth masks Vertex array enables, and Cull face Other things like clip planes and scissor rectangles can also cause problems. Good practices Check the framebuffer status The first release of this extension contains no mechanism to enumerate supported formats and framebuffer configurations. This is likely to be solved in a future extension, but for now it s up to the application to check whether a particular framebuffer configuration is complete, that is, valid for rendering to, and if needed try other formats until it succeeds or there are no suitable formats left to try. This can be done with the glcheckframebufferstatusext() function. It is highly
11 recommended to call this function before rendering after the FBO has been set up. It is also very helpful for debugging to check the error codes returned for FBO configuration problems. For instance in the render-to-depth case discussed above, had the draw-buffer and read-buffer not been set to GL_NONE, glcheckframebufferstatusext() would return the GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT error, hinting where the problem lies. The possible return values are as follows: GL_FRAMEBUFFER_COMPLETE_EXT The framebuffer is complete and valid for rendering. GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT One or more attachment points are not framebuffer attachment complete. This could mean there s no texture attached or the format isn t renderable. For color textures this means the base format must be RGB or RGBA and for depth textures it must be a DEPTH_COMPONENT format. Other causes of this error are that the width or height is zero or the z-offset is out of range in case of render to volume. GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT There are no attachments. GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT An object has been attached to more than one attachment point. GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT Attachments are of different size. All attachments must have the same width and height. GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT The color attachments have different format. All color attachments must have the same format. GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT An attachment point referenced by gldrawbuffers() doesn t have an attachment. GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT The attachment point referenced by glreadbuffers() doesn t have an attachment. GL_FRAMEBUFFER_UNSUPPORTED_EXT This particular FBO configuration is not supported by the implementation. All errors are universal and will fail on all implementations, except GL_FRAMEBUFFER_UNSUPPORTED_EXT which is implementation specific. This error can be caused by limitations in the underlying hardware or other restrictions of the implementation. Finally, glcheckframebufferstatusext() may also return zero if the function itself generates an error.
12 Note that it s legitimate to straddle through incomplete configuration states while setting up the FBO. No attention has to be taken to attach and detach in a particular order to always have complete configurations on the way from one setup to another. The framebuffer completeness will only be validated on draw calls and when glcheckframebufferstatusext() is called. Calling glcheckframebufferstatusext()does not generate an error when the framebuffer is incomplete, but returns the status so that the application can take proper action. Only if a draw call is issued when the framebuffer is in an incomplete state will an error (GL_INVALID_FRAMEBUFFER_OPERATION_EXT) be issued. Use properly specified textures Textures intended for rendering to should be properly setup at an early stage. If you plan on using mipmapping on a render target it s best to allocate all mipmap levels at once at creation time, rather than relying on glgeneratemipmapext() to create them for you. Otherwise the driver may have to reallocate the texture and possibly copy over the base level contents to a new location. Also be sure to correctly set the desired minify filter of all textures to be used as render targets before attaching to a framebuffer object. Failing to do so may have the driver allocating mipmaps for render targets that don t need them. Don t mix and match For best performance it s recommended that you keep your regular textures and textures used as a render targets separate. Don t modify your render targets by issuing calls such as gltex{sub}image2d or glcopytex{sub}image2d. Doing so may incur heavy penalties for reallocation, memory copying and data conversion. This is because render targets and textures have different requirements from the hardware s point of view and may not support the same set of formats and memory layouts. If you need to update a subsection of a render target, use rendering commands such as gldrawpixels() instead. Conclusion GL_EXT_framebuffer_object is an easy to use extension that solves all the major problems of PBuffers. It is intended to be a full replacement solution for off-screen rendering. However, in order to shorten the time-to-market of this extension not all features were included. Things not included are support for multisampling, accumulation buffers and a way to communicate what formats and configurations the implementation supports. Other features such as render-to-vertex-array are also being considered. Additional extensions targeting some or all of these issues are expected to follow. Once these issues are settled and enough feedback from developers and implementers has been assembled it is expected that this extension, possibly including additional extensions built on top of it, will receive the ARB s blessing. For now this should give a good starting point for writing good render-to-texture applications with a minimum amount of hassle.
CS 179 GPU Programming
CS179: GPU Programming Lecture 7: Render to Texture Lecture originally by Luke Durant, Russell McClellan, Tamas Szalay 1 Today: Render to Texture Render to texture in OpenGL Framebuffers and renderbuffers
More informationMULTI-PASS VS SINGLE-PASS CUBEMAP
Sogang University Computer Graphics Lab. MULTI-PASS VS SINGLE-PASS CUBEMAP 2008.4 1 Contents Purpose Multi-Pass Cubemap Single-Pass Cubemap Reflection Mapping Test Result Conclusion 2 Purpose Implement
More informationComputer Graphics. Bing-Yu Chen National Taiwan University
Computer Graphics Bing-Yu Chen National Taiwan University Introduction to OpenGL General OpenGL Introduction An Example OpenGL Program Drawing with OpenGL Transformations Animation and Depth Buffering
More informationTexturing. Slides done bytomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology
Texturing Slides done bytomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology 1 Texturing: Glue n-dimensional images onto geometrical objects l Purpose:
More informationPoint-Based rendering on GPU hardware. Advanced Computer Graphics 2008
Point-Based rendering on GPU hardware Advanced Computer Graphics 2008 Outline Why use the GPU? Splat rasterization Image-aligned squares Perspective correct rasterization Splat shading Flat shading Gouroud
More informationOpenGL Über Buffers Extension
1 of 70 OpenGL Über Buffers Extension Revision 0.29 Author Rob Mace Copyright 2002, 2003 ATI Technologies Inc. All rights reserved. This document is being distributed for the sole purpose of soliciting
More informationE.Order of Operations
Appendix E E.Order of Operations This book describes all the performed between initial specification of vertices and final writing of fragments into the framebuffer. The chapters of this book are arranged
More informationOpenGL ES for iphone Games. Erik M. Buck
OpenGL ES for iphone Games Erik M. Buck Topics The components of a game n Technology: Graphics, sound, input, physics (an engine) n Art: The content n Fun: That certain something (a mystery) 2 What is
More informationTexture Mapping. Mike Bailey.
Texture Mapping 1 Mike Bailey mjb@cs.oregonstate.edu This work is licensed under a Creative Commons Attribution-NonCommercial- NoDerivatives 4.0 International License TextureMapping.pptx The Basic Idea
More informationGeneral Purpose computation on GPUs. Liangjun Zhang 2/23/2005
General Purpose computation on GPUs Liangjun Zhang 2/23/2005 Outline Interpretation of GPGPU GPU Programmable interfaces GPU programming sample: Hello, GPGPU More complex programming GPU essentials, opportunity
More informationDynamic Texturing. Mark Harris NVIDIA Corporation
Dynamic Texturing Mark Harris NVIDIA Corporation What is Dynamic Texturing? The creation of texture maps on the fly for use in real time. A simplified view: Loop: Render an image. Create a texture from
More informationCS452/552; EE465/505. Image Processing Frame Buffer Objects
CS452/552; EE465/505 Image Processing Frame Buffer Objects 3-12 15 Outline! Image Processing: Examples! Render to Texture Read: Angel, Chapter 7, 7.10-7.13 Lab3 new due date: Friday, Mar. 13 th Project#1
More informationOpenGL R ES 1.1 Extension Pack Specification
OpenGL R ES 1.1 Extension Pack Specification Version 1.03 (Annotated) Editor : Aaftab Munshi Copyright (c) 2002-2005 The Khronos Group Inc. All Rights Reserved. This specification is protected by copyright
More informationCS452/552; EE465/505. Shadow Mapping in WebGL
CS452/552; EE465/505 Shadow Mapping in WebGL 4-09 15 Outline! Shadow Mapping in WebGL Switching Shaders Framebuffer Objects (FBO) Read: Angel, Chapter 7: 7.12 Framebuffer Objects WebGL Programming Guide:
More informationProgramming Guide. Aaftab Munshi Dan Ginsburg Dave Shreiner. TT r^addison-wesley
OpenGUES 2.0 Programming Guide Aaftab Munshi Dan Ginsburg Dave Shreiner TT r^addison-wesley Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid
More informationWorking with Metal Overview
Graphics and Games #WWDC14 Working with Metal Overview Session 603 Jeremy Sandmel GPU Software 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission
More informationGrafica Computazionale
Grafica Computazionale lezione36 Informatica e Automazione, "Roma Tre" June 3, 2010 Grafica Computazionale: Lezione 33 Textures Introduction Steps in Texture Mapping A Sample Program Texturing algorithms
More informationPicking (In WebGL) Picking idea
9. Picking IN THIS CHAPTER Selecting objects in a WebGL scene using the mouse Creating and using offscreen framebuffers What renderbuffers are and how they are used by framebuffers Reading pixels from
More informationThe Application Stage. The Game Loop, Resource Management and Renderer Design
1 The Application Stage The Game Loop, Resource Management and Renderer Design Application Stage Responsibilities 2 Set up the rendering pipeline Resource Management 3D meshes Textures etc. Prepare data
More informationComputergraphics Exercise 15/ Shading & Texturing
Computergraphics Exercise 15/16 3. Shading & Texturing Jakob Wagner for internal use only Shaders Vertex Specification define vertex format & data in model space Vertex Processing transform to clip space
More informationReal-Time Rendering (Echtzeitgraphik) Michael Wimmer
Real-Time Rendering (Echtzeitgraphik) Michael Wimmer wimmer@cg.tuwien.ac.at Walking down the graphics pipeline Application Geometry Rasterizer What for? Understanding the rendering pipeline is the key
More informationBuffers. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015
Buffers 1 Objectives Introduce additional WebGL buffers Reading and writing buffers Buffers and Images 2 Buffer Define a buffer by its spatial resolution (n x m) and its depth (or precision) k, the number
More informationMention driver developers in the room. Because of time this will be fairly high level, feel free to come talk to us afterwards
1 Introduce Mark, Michael Poll: Who is a software developer or works for a software company? Who s in management? Who knows what the OpenGL ARB standards body is? Mention driver developers in the room.
More informationKenneth Dyke Sr. Engineer, Graphics and Compute Architecture
Kenneth Dyke Sr. Engineer, Graphics and Compute Architecture 2 Supporting multiple GPUs in your application Finding all renderers and devices Responding to renderer changes Making use of multiple GPUs
More informationGeForce3 OpenGL Performance. John Spitzer
GeForce3 OpenGL Performance John Spitzer GeForce3 OpenGL Performance John Spitzer Manager, OpenGL Applications Engineering jspitzer@nvidia.com Possible Performance Bottlenecks They mirror the OpenGL pipeline
More informationCIS 665 GPU Programming and Architecture
CIS 665 GPU Programming and Architecture Homework #3 Due: June 6/09/09 : 23:59:59PM EST 1) Benchmarking your GPU (25 points) Background: GPUBench is a benchmark suite designed to analyze the performance
More informationDefinition. Blending & Compositing. Front & Back Buffers. Left & Right Buffers. Blending combines geometric objects. e.g.
Blending & Compositing COMP 3003 Autumn 2005 Definition Blending combines geometric objects e.g. transparency Compositing combines entire images multi-pass textures accumulating results Both depend on
More informationDiscussion 3. PPM loading Texture rendering in OpenGL
Discussion 3 PPM loading Texture rendering in OpenGL PPM Loading - Portable PixMap format 1. 2. Code for loadppm(): http://ivl.calit2.net/wiki/images/0/09/loadppm.txt ppm file format: Header: 1. P6: byte
More informationCould you make the XNA functions yourself?
1 Could you make the XNA functions yourself? For the second and especially the third assignment, you need to globally understand what s going on inside the graphics hardware. You will write shaders, which
More information三維繪圖程式設計 3D Graphics Programming Design 第七章基礎材質張貼技術嘉大資工系盧天麒
三維繪圖程式設計 3D Graphics Programming Design 第七章基礎材質張貼技術嘉大資工系盧天麒 1 In this chapter, you will learn The basics of texture mapping Texture coordinates Texture objects and texture binding Texture specification
More informationComputergrafik. Matthias Zwicker. Herbst 2010
Computergrafik Matthias Zwicker Universität Bern Herbst 2010 Today Bump mapping Shadows Shadow mapping Shadow mapping in OpenGL Bump mapping Surface detail is often the result of small perturbations in
More informationOpenGL & Visualization
OpenGL & Visualization Martin Ilčík Institute of Computer Graphics and Algorithms Vienna University of Technology Motivation What is OpenGL How to use OpenGL Slices with OpenGL GPU raycasting Martin Ilčík
More informationProgrammer s Guide. Quadro FX SDI. January 24, 2008 PG _v01
Programmer s Guide Quadro FX SDI January 24, 2008 PG-03776-001_v01 Document Change History Version Date Responsible Reason for Change 01 January 24, 2008 TT, SM Initial Release January 24, 2008 PG-03776-001_v01
More informationTexture Mapping 1/34
Texture Mapping 1/34 Texture Mapping Offsets the modeling assumption that the BRDF doesn t change in u and v coordinates along the object s surface Store a reflectance as an image called a texture Map
More informationCIS 665 GPU Programming and Architecture
CIS 665 GPU Programming and Architecture Homework #3 Due: February 2/11/07 : 23:59:59PM EST 1) Benchmarking your GPU (25 points) Background: GPUBench is a benchmark suite designed to analyze the performance
More informationOpenGL Status - November 2013 G-Truc Creation
OpenGL Status - November 2013 G-Truc Creation Vendor NVIDIA AMD Intel Windows Apple Release date 02/10/2013 08/11/2013 30/08/2013 22/10/2013 Drivers version 331.10 beta 13.11 beta 9.2 10.18.10.3325 MacOS
More informationLighting and Texturing
Lighting and Texturing Michael Tao Michael Tao Lighting and Texturing 1 / 1 Fixed Function OpenGL Lighting Need to enable lighting Need to configure lights Need to configure triangle material properties
More informationMixing graphics and compute with multiple GPUs
Mixing graphics and compute with multiple GPUs genda Compute and Graphics Interoperability Interoperability at a system level pplication design considerations Putting Graphics & Compute together Compute
More informationRationale for Non-Programmable Additions to OpenGL 2.0
Rationale for Non-Programmable Additions to OpenGL 2.0 NVIDIA Corporation March 23, 2004 This white paper provides a rationale for a set of functional additions to the 2.0 revision of the OpenGL graphics
More informationOpenGL SUPERBIBLE. Fifth Edition. Comprehensive Tutorial and Reference. Richard S. Wright, Jr. Nicholas Haemel Graham Sellers Benjamin Lipchak
OpenGL SUPERBIBLE Fifth Edition Comprehensive Tutorial and Reference Richard S. Wright, Jr. Nicholas Haemel Graham Sellers Benjamin Lipchak AAddison-Wesley Upper Saddle River, NJ Boston Indianapolis San
More informationCS4620/5620: Lecture 14 Pipeline
CS4620/5620: Lecture 14 Pipeline 1 Rasterizing triangles Summary 1! evaluation of linear functions on pixel grid 2! functions defined by parameter values at vertices 3! using extra parameters to determine
More informationVolume Shadows Tutorial Nuclear / the Lab
Volume Shadows Tutorial Nuclear / the Lab Introduction As you probably know the most popular rendering technique, when speed is more important than quality (i.e. realtime rendering), is polygon rasterization.
More informationWhat Now? What Next? Integrating with SDI
What Now? What Next? Integrating with SDI Thomas J, True Applied Engineering, NVIDIA Agenda Introduction Hardware Architecture Software Architecture Device Control Data Transfer Advanced Topics More Information
More informationLecture 07: Buffers and Textures
Lecture 07: Buffers and Textures CSE 40166 Computer Graphics Peter Bui University of Notre Dame, IN, USA October 26, 2010 OpenGL Pipeline Today s Focus Pixel Buffers: read and write image data to and from
More informationCSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science
CSC 307 1.0 Graphics Programming Department of Statistics and Computer Science Graphics Programming Texture Mapping 2 Texture Poly. Per Vertex Mapping CPU DL Pixel Texture Raster Frag FB Apply a 1D, 2D,
More informationVGP353 Week 2. Agenda: Assignment #1 due Introduce shadow maps. Differences / similarities with shadow textures Added benefits Potential problems
VGP353 Week 2 Agenda: Assignment #1 due Introduce shadow maps Differences / similarities with shadow textures Added benefits Potential problems Shadow Textures Shadow textures have a number of faults:
More informationGPU Memory Model. Adapted from:
GPU Memory Model Adapted from: Aaron Lefohn University of California, Davis With updates from slides by Suresh Venkatasubramanian, University of Pennsylvania Updates performed by Gary J. Katz, University
More informationImaging and Raster Primitives
Realtime 3D Computer Graphics & Virtual Reality Bitmaps and Textures Imaging and Raster Primitives Vicki Shreiner Imaging and Raster Primitives Describe OpenGL s raster primitives: bitmaps and image rectangles
More informationTexturing. Slides done by Tomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology
Texturing Slides done by Tomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology 1 Texturing: Glue n-dimensional images onto geometrical objects l Purpose:
More informationDiscrete Techniques. 11 th Week, Define a buffer by its spatial resolution (n m) and its depth (or precision) k, the number of
Discrete Techniques 11 th Week, 2010 Buffer Define a buffer by its spatial resolution (n m) and its depth (or precision) k, the number of bits/pixel Pixel OpenGL Frame Buffer OpenGL Buffers Color buffers
More informationCS 432 Interactive Computer Graphics
CS 432 Interactive Computer Graphics Lecture 7 Part 2 Texture Mapping in OpenGL Matt Burlick - Drexel University - CS 432 1 Topics Texture Mapping in OpenGL Matt Burlick - Drexel University - CS 432 2
More informationGrafica Computazionale: Lezione 30. Grafica Computazionale. Hiding complexity... ;) Introduction to OpenGL. lezione30 Introduction to OpenGL
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
More informationGraphics. Texture Mapping 고려대학교컴퓨터그래픽스연구실.
Graphics Texture Mapping 고려대학교컴퓨터그래픽스연구실 3D Rendering Pipeline 3D Primitives 3D Modeling Coordinates Model Transformation 3D World Coordinates Lighting 3D World Coordinates Viewing Transformation 3D Viewing
More informationCopyright Khronos Group 2012 Page 1. Teaching GL. Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012
Copyright Khronos Group 2012 Page 1 Teaching GL Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012 Copyright Khronos Group 2012 Page 2 Agenda Overview of OpenGL family of APIs Comparison
More informationTexture Mapping 1/34
Texture Mapping 1/34 Texture Mapping Offsets the modeling assumption that the BRDF doesn t change in u and v coordinates along the object s surface Store a reflectance as an image called a texture Map
More informationCISC 3620 Lecture 7 Lighting and shading. Topics: Exam results Buffers Texture mapping intro Texture mapping basics WebGL texture mapping
CISC 3620 Lecture 7 Lighting and shading Topics: Exam results Buffers Texture mapping intro Texture mapping basics WebGL texture mapping Exam results Grade distribution 12 Min: 26 10 Mean: 74 8 Median:
More informationCS 130 Final. Fall 2015
CS 130 Final Fall 2015 Name Student ID Signature You may not ask any questions during the test. If you believe that there is something wrong with a question, write down what you think the question is trying
More informationSuperbuffers Workgroup Update. Barthold Lichtenbelt
Superbuffers Workgroup Update Barthold Lichtenbelt 1 EXT_framebuffer_object update Specification stable since September 2005 Version #118 posted to Registry April 2006 - Lay groundwork for R, RG rendering
More informationSUMMARY. CS380: Introduction to Computer Graphics Texture Mapping Chapter 15. Min H. Kim KAIST School of Computing 18/05/03.
CS380: Introduction to Computer Graphics Texture Mapping Chapter 15 Min H. Kim KAIST School of Computing Materials SUMMARY 2 1 Light blob from PVC plastic Recall: Given any vector w (not necessarily of
More informationRendering Objects. Need to transform all geometry then
Intro to OpenGL Rendering Objects Object has internal geometry (Model) Object relative to other objects (World) Object relative to camera (View) Object relative to screen (Projection) Need to transform
More informationPixels and Buffers. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science
Pixels and Buffers CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science 1 Objectives Introduce additional OpenGL buffers Learn to read from / write to buffers Introduce
More informationCSCI 4620/8626. The 2D Viewing Pipeline
CSCI 4620/8626 Computer Graphics Two-Dimensional Viewing (Chapter 8) Last update: 2016-03-3 The 2D Viewing Pipeline Given a 2D scene, we select the part of it that we wish to see (render, display) using
More informationTexture Mapping. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science
Texture Mapping CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science 1 Objectives Introduce Mapping Methods - Texture Mapping - Environment Mapping - Bump Mapping Consider
More informationOverview. By end of the week:
Overview By end of the week: - Know the basics of git - Make sure we can all compile and run a C++/ OpenGL program - Understand the OpenGL rendering pipeline - Understand how matrices are used for geometric
More informationDEFERRED RENDERING STEFAN MÜLLER ARISONA, ETH ZURICH SMA/
DEFERRED RENDERING STEFAN MÜLLER ARISONA, ETH ZURICH SMA/2013-11-04 DEFERRED RENDERING? CONTENTS 1. The traditional approach: Forward rendering 2. Deferred rendering (DR) overview 3. Example uses of DR:
More informationOptimizing DirectX Graphics. Richard Huddy European Developer Relations Manager
Optimizing DirectX Graphics Richard Huddy European Developer Relations Manager Some early observations Bear in mind that graphics performance problems are both commoner and rarer than you d think The most
More informationWorld Coordinate System
World Coordinate System Application Model Application Program Graphics System Workstation Normally, the User or Object Coordinate System. World Coordinate Window: A subset of the world coordinate system,
More informationNormalized Device Coordinate System (NDC) World Coordinate System. Example Coordinate Systems. Device Coordinate System
World Coordinate System Normalized Device Coordinate System (NDC) Model Program Graphics System Workstation Model Program Graphics System Workstation Normally, the User or Object Coordinate System. World
More informationCS335 Graphics and Multimedia. Slides adopted from OpenGL Tutorial
CS335 Graphics and Multimedia Slides adopted from OpenGL Tutorial Texture Poly. Per Vertex Mapping CPU DL Texture Raster Frag FB Pixel Apply a 1D, 2D, or 3D image to geometric primitives Uses of Texturing
More informationOptimizing for DirectX Graphics. Richard Huddy European Developer Relations Manager
Optimizing for DirectX Graphics Richard Huddy European Developer Relations Manager Also on today from ATI... Start & End Time: 12:00pm 1:00pm Title: Precomputed Radiance Transfer and Spherical Harmonic
More informationGraphics Performance Optimisation. John Spitzer Director of European Developer Technology
Graphics Performance Optimisation John Spitzer Director of European Developer Technology Overview Understand the stages of the graphics pipeline Cherchez la bottleneck Once found, either eliminate or balance
More informationIntroduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL Ed Angel The Mandelbrot Set Fractals Fractal (fractional geometry) objects generate some of the most complex and beautiful graphics - The mathematics describing
More informationProject 1, 467. (Note: This is not a graphics class. It is ok if your rendering has some flaws, like those gaps in the teapot image above ;-)
Project 1, 467 Purpose: The purpose of this project is to learn everything you need to know for the next 9 weeks about graphics hardware. What: Write a 3D graphics hardware simulator in your language of
More informationApplying Textures. Lecture 27. Robb T. Koether. Hampden-Sydney College. Fri, Nov 3, 2017
Applying Textures Lecture 27 Robb T. Koether Hampden-Sydney College Fri, Nov 3, 2017 Robb T. Koether (Hampden-Sydney College) Applying Textures Fri, Nov 3, 2017 1 / 24 Outline 1 Applying Textures 2 Photographs
More informationGPU Memory Model Overview
GPU Memory Model Overview John Owens University of California, Davis Department of Electrical and Computer Engineering Institute for Data Analysis and Visualization SciDAC Institute for Ultrascale Visualization
More informationOpenGL Performances and Flexibility. Visual Computing Laboratory ISTI CNR, Italy
OpenGL Performances and Flexibility Visual Computing Laboratory ISTI CNR, Italy The Abstract Graphics Pipeline Application 1. The application specifies vertices & connectivity. Vertex Processing 2. The
More informationTechnical Report. SLI Best Practices
Technical Report SLI Best Practices Abstract This paper describes techniques that can be used to perform application-side detection of SLI-configured systems, as well as ensure maximum performance scaling
More informationRasterization Overview
Rendering Overview The process of generating an image given a virtual camera objects light sources Various techniques rasterization (topic of this course) raytracing (topic of the course Advanced Computer
More informationCS195V Week 6. Image Samplers and Atomic Operations
CS195V Week 6 Image Samplers and Atomic Operations Administrata Warp is due today! NBody should go out soon Due in three weeks instead of two Slightly larger in scope First week and a half we be spent
More informationMidterm Exam Fundamentals of Computer Graphics (COMP 557) Thurs. Feb. 19, 2015 Professor Michael Langer
Midterm Exam Fundamentals of Computer Graphics (COMP 557) Thurs. Feb. 19, 2015 Professor Michael Langer The exam consists of 10 questions. There are 2 points per question for a total of 20 points. You
More informationPipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11
Pipeline Operations CS 4620 Lecture 11 1 Pipeline you are here APPLICATION COMMAND STREAM 3D transformations; shading VERTEX PROCESSING TRANSFORMED GEOMETRY conversion of primitives to pixels RASTERIZATION
More informationTriangle Fast Scan-Conversion Algorithm Report
Triangle Fast Scan-Conversion Algorithm Report Jian Cui jcui@gmu.edu Jim X. Chen jchen@cs.gmu.edu Xiaorong Zhou xzhou@gmu.edu ABSTRACT To date, very little has been done to analyze the very importance
More informationUV Mapping to avoid texture flaws and enable proper shading
UV Mapping to avoid texture flaws and enable proper shading Foreword: Throughout this tutorial I am going to be using Maya s built in UV Mapping utility, which I am going to base my projections on individual
More informationLecture 19: OpenGL Texture Mapping. CITS3003 Graphics & Animation
Lecture 19: OpenGL Texture Mapping CITS3003 Graphics & Animation E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 Objectives Introduce the OpenGL texture functions and options
More informationOpenGL Essentials Training
OpenGL Essentials Training 3-day session Overview Understanding principles of 3D programming Understanding drawing Primitives Understanding transformation matrix and Coloring Understanding Blending and
More informationCMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker
CMSC427 Advanced shading getting global illumination by local methods Credit: slides Prof. Zwicker Topics Shadows Environment maps Reflection mapping Irradiance environment maps Ambient occlusion Reflection
More informationCopyright Khronos Group, Page Graphic Remedy. All Rights Reserved
Avi Shapira Graphic Remedy Copyright Khronos Group, 2009 - Page 1 2004 2009 Graphic Remedy. All Rights Reserved Debugging and profiling 3D applications are both hard and time consuming tasks Companies
More informationSoft shadows. Steve Marschner Cornell University CS 569 Spring 2008, 21 February
Soft shadows Steve Marschner Cornell University CS 569 Spring 2008, 21 February Soft shadows are what we normally see in the real world. If you are near a bare halogen bulb, a stage spotlight, or other
More informationCT5510: Computer Graphics. Texture Mapping
CT5510: Computer Graphics Texture Mapping BOCHANG MOON Texture Mapping Simulate spatially varying surface properties Phong illumination model is coupled with a material (e.g., color) Add small polygons
More informationDeferred Rendering Due: Wednesday November 15 at 10pm
CMSC 23700 Autumn 2017 Introduction to Computer Graphics Project 4 November 2, 2017 Deferred Rendering Due: Wednesday November 15 at 10pm 1 Summary This assignment uses the same application architecture
More informationFog example. Fog is atmospheric effect. Better realism, helps determine distances
Fog example Fog is atmospheric effect Better realism, helps determine distances Fog Fog was part of OpenGL fixed function pipeline Programming fixed function fog Parameters: Choose fog color, fog model
More informationMotivation Hardware Overview Programming model. GPU computing. Part 1: General introduction. Ch. Hoelbling. Wuppertal University
Part 1: General introduction Ch. Hoelbling Wuppertal University Lattice Practices 2011 Outline 1 Motivation 2 Hardware Overview History Present Capabilities 3 Programming model Past: OpenGL Present: CUDA
More informationShadow Rendering. CS7GV3 Real-time Rendering
Shadow Rendering CS7GV3 Real-time Rendering Global Illumination The incoming radiance L i (p,l) at some point p is the outgoing L o (r(p,l)-l) from another point A Recursive Term r(r(p,l), l ) r(r(r(p,l),
More informationIntroduction to OpenGL
OpenGL is an alternative to Direct3D for 3D graphics rendering Originally developed by Silicon Graphics Inc (SGI), turned over to multi-vendor group (OpenGL Architecture Review Board) in 1992 Unlike DirectX,
More informationOpenGL. Toolkits.
http://www.opengl.org OpenGL Open Graphics Library Graphics API Delivered with UNIX, Win9x/2000/Me/Nt/Xp, Mac OS Direct3D (DirectX) is only Windows Utilizes the window system and event handling of the
More informationTSBK03 Screen-Space Ambient Occlusion
TSBK03 Screen-Space Ambient Occlusion Joakim Gebart, Jimmy Liikala December 15, 2013 Contents 1 Abstract 1 2 History 2 2.1 Crysis method..................................... 2 3 Chosen method 2 3.1 Algorithm
More informationTechnical Report. SLI Best Practices
Technical Report SLI Best Practices Abstract This paper describes techniques that can be used to perform application-side detection of SLI-configured systems, as well as ensure maximum performance scaling
More informationMost device that are used to produce images are. dots (pixels) to display the image. This includes CRT monitors, LCDs, laser and dot-matrix
Scan Conversion of Lines Raster devices Most device that are used to produce images are raster devices, that is, use rectangular arrays of dots (pixels) to display the image. This includes CRT monitors,
More informationIntroduction. What s New in This Edition
Introduction Welcome to the fourth edition of the OpenGL SuperBible. For more than ten years, we have striven to provide the world s best introduction to not only OpenGL, but 3D graphics programming in
More informationProjection Matrix Tricks. Eric Lengyel
Projection Matrix Tricks Eric Lengyel Outline Projection Matrix Internals Infinite Projection Matrix Depth Modification Oblique Near Clipping Plane Slides available at http://www.terathon.com www.terathon.com/
More information