270 likes | 285 Views
This text provides an introduction to different image formats, including JPEG, PNG, GIF, and others. It also explains the concept of a graphics rendering pipeline and its stages.
E N D
Week 1 - Wednesday COMP 4290
Last time • What did we talk about last time? • Introduction to the course • Colors • RGB • CMYK • HSL and HSV
Real world image formats • We will be thinking of images as linear buffers of data (which will usually store R,G,B and sometimes A values for each pixel) • Bitmaps (.bmp files) are almost that simple • Most common image formats (.jpg, .png, and .gif files) are more complex • They use different forms of compression to keep the image size small • Otherwise, an 800 x 600 image is 3 bytes per pixel x 800 x 600 = 1,440,000 bytes > 1 MB
JPEG or JPG images • Stands for Joint Photographic Experts Group • Good for images without too much high contrast (sharp edges) • Photographs are often stored as JPEGs • Uses crazy math (discrete cosine transform) to reduce the amount of data needed • Lossy compression
PNG images • Good for images with low numbers of colors and high contrast differences • Has built-in compression sort of like zip files • Similar to the older GIF (.gif) images • GIFs are unpopular now because they only support 256 colors • GIFs also suffered from legal battles over the algorithm used for compression • Lossless compression
Others • Tagged image file format (.tiff or .tif) images are another standard sometimes used in computer graphics or for scanned images • The TIFF standard is really crazy, supporting layers, LZW style compressions, JPEG style compression • DirectDraw surface container (.dds) files were designed for DirectX, allowing for the S3 Texture Compression algorithm • The pixel data is easily to decompress in hardware • TARGA (.tga) files have a very simple structure and are still used for some textures
Student Lecture: Graphics Rendering Pipeline and Application Stage
Rendering • What do we have? • Virtual camera (viewpoint) • 3D objects • Light sources • Shading • Textures • What do we want? • 2D image
Pipelines • The idea of a pipeline is to divide a task into independent steps, each of which can be performed by dedicated hardware • Example RISC pipeline: • Instruction fetch • Decode • Execute • Memory Access • Writeback
Pipeline performance • If you have an n stage pipeline, what's the maximum speedup you can get? • Consider a TV show with the following pipeline • Write • Rewrite • Film • Edit • Assume each step takes 1 week • How much total time does it take to produce a 13 episode season? • What if there was no pipelining? • Note that a pipeline's speed is limited by its slowest stage, the bottleneck
Graphics rendering pipeline • For API design, practical top-down problem solving, and hardware design, and efficiency, rendering is described as a pipeline • This pipeline contains three conceptual stages:
Architecture • These conceptual stages may or may not be running at the same time • Each conceptual stage may contain its own internal pipelines or parallel execution
Speed • A critical concern of real time rendering is the rendering speed, determined by the slowest stage in the pipeline • We can measure speed in frames per second (fps), common for average performance over time • We can also measure speed in Hertz (Hz), common for hardware
Rendering speed example • Output device has a maximum update frequency of 60 Hz (very common for LCDs) • The bottleneck rendering stage is 62.5 ms • What's our rendering speed? • 1/0.0625 = 16 fps • 60/1 = 60 fps • 60/2 = 30 fps • 60/3 = 20 fps • 60/4 = 15 fps • 60/5 = 12 fps
Application stage • The application stage is the stage completely controlled by the programmer • As the application develops, many changes of implementation may be done to improve performance • The output of the application stage are rendering primitives • Points • Lines • Triangles
Important jobs of the application stage • Reading input • Managing non-graphical output • Texture animation • Animation via transforms • Collision detection • Updating the state of the world in general
Acceleration • The Application Stage also handles a lot of acceleration • Most of this acceleration is telling the renderer what NOT to render • Acceleration algorithms • Hierarchical view frustum culling • BSP trees • Quadtrees • Octrees
Hierarchical view frustum culling • An application can remove those objects that are not in the cone of visibility • Hierarchies of objects can be used to make these calculations easier
BSP Trees • Splitting planes are made through polygons to repeatedly subdivide the polygons in a scene in half • Often, BSP Trees are calculated a single time for complex, static scenes
Quadtrees and Octrees • Like BSP's, the space can be repeatedly subdivided as long as it contains a number of objects above a certain threshold • Octrees divide the space in three dimensions while quadtrees only focus on two
Next time… • C# and MonoGame overview
Reminders • No required reading ahead of time • But, checking out MonoGame is not a bad idea • To run it on your own machine, you'll need Visual Studio 2015 Community • Freely available • Alternatively, you can talk to Professor Stucki about getting the Enterprise edition, but those features won't be useful for this class