Textures. Texture coordinates. Introduce one more component to geometry

Similar documents
The Rasterizer Stage. Texturing, Lighting, Testing and Blending

Texture mapping. Computer Graphics CSE 167 Lecture 9


CS 354R: Computer Game Technology

Texture Mapping and Special Effects

Today. Texture mapping in OpenGL. Texture mapping. Basic shaders for texturing. Today. Computergrafik

TEXTURE MAPPING. DVA338 Computer Graphics Thomas Larsson, Afshin Ameri

CS 130 Final. Fall 2015

CSE 167: Introduction to Computer Graphics Lecture #6: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2014

Complex Shading Algorithms

3D Rasterization II COS 426

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Texturing Theory. Overview. All it takes is for the rendered image to look right. -Jim Blinn 11/10/2018

Discrete Techniques. 11 th Week, Define a buffer by its spatial resolution (n m) and its depth (or precision) k, the number of

Programming Graphics Hardware

Mattan Erez. The University of Texas at Austin

CPSC / Texture Mapping

lecture 18 - ray tracing - environment mapping - refraction

CS451Real-time Rendering Pipeline

Pipeline Operations. CS 4620 Lecture 14

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1)

CSE 167: Introduction to Computer Graphics Lecture #8: Textures. Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2016

Evolution of GPUs Chris Seitz

Texturing. Slides done bytomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Spring 2009 Prof. Hyesoon Kim

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

CT5510: Computer Graphics. Texture Mapping

Spring 2011 Prof. Hyesoon Kim

Texture Mapping. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Texture. Texture Mapping. Texture Mapping. CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

Rasterization Overview

CS 450: COMPUTER GRAPHICS TEXTURE MAPPING SPRING 2015 DR. MICHAEL J. REALE

Surface Rendering. Surface Rendering

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

Pipeline Operations. CS 4620 Lecture 10

Modeling the Virtual World

INF3320 Computer Graphics and Discrete Geometry

CS 4620 Program 3: Pipeline

Perspective Projection and Texture Mapping

3D buzzwords. Adding programmability to the pipeline 6/7/16. Bandwidth Gravity of modern computer systems

Chapter IV Fragment Processing and Output Merging. 3D Graphics for Game Programming

Texture and other Mappings

The Rasterization Pipeline

The Graphics Pipeline

Texture Mapping. Michael Kazhdan ( /467) HB Ch. 14.8,14.9 FvDFH Ch. 16.3, , 16.6

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops.

Introduction to Visualization and Computer Graphics

CSE4030 Introduction to Computer Graphics

Texture Mapping II. Light maps Environment Maps Projective Textures Bump Maps Displacement Maps Solid Textures Mipmaps Shadows 1. 7.

Point-Based Rendering

CHAPTER 1 Graphics Systems and Models 3

+ = To Do. Texture Mapping. Adding Visual Detail. Parameterization. Option: Varieties of projections. Computer Graphics. geometry

Texture Mapping and Sampling

+ = To Do. Adding Visual Detail. Texture Mapping. Parameterization. Option: Varieties of projections. Foundations of Computer Graphics (Fall 2012)

Rendering Grass Terrains in Real-Time with Dynamic Lighting. Kévin Boulanger, Sumanta Pattanaik, Kadi Bouatouch August 1st 2006

Computer Graphics. Lecture 9 Environment mapping, Mirroring

Shadow Techniques. Sim Dietrich NVIDIA Corporation

Real - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský

Computer Graphics. Lecture 8 Antialiasing, Texture Mapping

Computer Graphics 7 - Texture mapping, bump mapping and antialiasing

Rendering Objects. Need to transform all geometry then

COMP environment mapping Mar. 12, r = 2n(n v) v

CSE 167: Introduction to Computer Graphics Lecture #7: Textures. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018

Module 13C: Using The 3D Graphics APIs OpenGL ES

Computer Graphics Lecture 11

CS 428: Fall Introduction to. Texture mapping and filtering. Andrew Nealen, Rutgers, /18/2010 1

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

Drawing Fast The Graphics Pipeline

CS 431/636 Advanced Rendering Techniques

CS GPU and GPGPU Programming Lecture 2: Introduction; GPU Architecture 1. Markus Hadwiger, KAUST

Advanced Shading and Texturing

Scanline Rendering 2 1/42

Shadows in the graphics pipeline

Level of Details in Computer Rendering

Texture Mapping 1/34

CS 464 Review. Review of Computer Graphics for Final Exam

Real Time Reflections Han-Wei Shen

Hardware Displacement Mapping

3D Programming. 3D Programming Concepts. Outline. 3D Concepts. 3D Concepts -- Coordinate Systems. 3D Concepts Displaying 3D Models

Computergrafik. Matthias Zwicker. Herbst 2010

Buffers. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Lecture 2. Shaders, GLSL and GPGPU

Graphics Performance Optimisation. John Spitzer Director of European Developer Technology

Adaptive Point Cloud Rendering

Chapter 2 A top-down approach - How to make shaded images?

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Computer Graphics 10 - Shadows

Overview. Goals. MipMapping. P5 MipMap Texturing. What are MipMaps. MipMapping in OpenGL. Generating MipMaps Filtering.

Mattan Erez. The University of Texas at Austin

Topics and things to know about them:

OpenGL SUPERBIBLE. Fifth Edition. Comprehensive Tutorial and Reference. Richard S. Wright, Jr. Nicholas Haemel Graham Sellers Benjamin Lipchak

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

Graphics and Interaction Rendering pipeline & object modelling

CS GAME PROGRAMMING Question bank

CIS 536/636 Introduction to Computer Graphics. Kansas State University. CIS 536/636 Introduction to Computer Graphics

CSE 167: Lecture 11: Textures 2. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Graphics Processing Unit Architecture (GPU Arch)

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

Transcription:

Texturing & Blending Prof. Aaron Lanterman (Based on slides by Prof. Hsien-Hsin Sean Lee) School of Electrical and Computer Engineering Georgia Institute of Technology Textures Rendering tiny triangles is slow Players won t even look at some certain details Sky, clouds, walls, terrain, wood patterns, etc. Simple way to add details and enhance realism Use 2D images to map polygons Images are composed of 2D texels 2 Texture coordinates Introduce one more component to geometry Position coordinates Normal vector Color (may not need now) Texture coordinates Texture coordinate conventions Direct3D/XNA texture convention (u, v) coordinates for each vertex (0,0) = upper left corner (1,1) = lower right corner OpenGL/Unity texture convention (s, t)/(u, v) coordinates for each vertex (0,0) = lower left corner (1,1) = upper right corner 3 4 1

Texture mapping example (1) (0,0) (1,0) v7 v8 Texture mapping example (2) Texture 1 Texture 2 (0,0) (1,0) (0,0) v7 v8 v0 v1 v0 v1 (0,1) (1,1) Direct3D/XNA convention u v (0,1) (1,1) (1,1) {v1.x, v1.y, v1.z,, 1, 0}, {v2.x, v2.y, v2.z,, 1, 1}, {v0.x, v0.y, v0.z,, 0, 0}, {v3.x, v3.y, v3.z,, 0, 1}, v3 v2 v3 v2 5 6 Perspective correct texture mapping Repeated textures (0,0) (1,0) v1 v2 (0,1) (1,1) u v From http://en.wikipedia.org/wiki/texture_mapping {v1.x, v1.y, v1.z,, 0, 0}, {v2.x, v2.y, v2.z,, 5, 0}, {v0.x, v0.y, v0.z,, 5, 3}, {v3.x, v3.y, v3.z,, 0, 3}, v3 v0 7 8 2

Repeated brick texture Magnification u v {v1.x, v1.y, v1.z,, 0, 0}, {v2.x, v2.y, v2.z,, 6, 0}, {v0.x, v0.y, v0.z,, 6, 6}, {v3.x, v3.y, v3.z,, 0, 6}, Texels Texel and pixel mapping is rarely 1-to-1 Mapped triangle is very close to the camera One texel maps to multiple pixels 9 10 Nearest point sampling (for magnification) Averaging (for magnification) R=247 G=237 B=141 R=255 G=204 B=102 Texels R=253 G=230 B=145 Texels R=102 G=102 B=51 R=214 G=193 B=110 Choose the texel nearest the pixel s center Average the 2x2 texels surrounding a given pixel 11 12 3

Bilinear filtering (for magnification) Minification x 1-x * (1-x) * (1-y) 1-y + * (1-x) * y y + + * x * (1-y) * x * y Color? Final Color : pixel enclosed by 4 texels Or take the weighted values for the 2x2 texels surrounding a given pixel Texels Texel and pixel mapping is rarely 1-to-1 Multiple texels map to one pixel 13 14 Nearest point sampling (for minification) Averaging (for minification) R=234 G=189 B=0 R=252 G=219 B=96 R=0 G=0 B=0 R=135 G=119 B=23 R=155 G=132 B=30 Choose the texel nearest the pixel s center Average for the 2x2 texels corresponding to a given pixel 15 16 4

Mip-mapping (1) Multiple versions are provided for the same texture Different versions have different levels of details E.g., 7 LOD maps: 256x256, 128x128, 64x64, 32x32, 16x16, 8x8, 4x4 Choose the closest maps to render a surface Maps can be automatically generated by 3D API Mip-mapping (2) API or hardware can Choose the right one for the viewer Good performance for far triangles Good LOD for close-by objects Trilinearly interpolate 17 18 Tri-linear filtering using mipmaps Anisotropic filtering R=147 G=114 B=117 R=106 G=80 B=74 Higher Res. Mip Map R=94 G=49 B=48 R=58 G=0 B=0 R=66 G=0 B=0 R=155 G=132 B=30 R=178 G=179 B=90 R=229 G=208 B=119 R=233 G=227 B=143 Lower Res. Mip Map R=199 G=187 B=96 R=147 G=118 B=72 Screen Pixel Bilinear filtering Trilinear filtering Not isotropic Preserves details for oblique viewing angles (non-uniform surface) AF calculates the shape of the surface before mapping The number of pixels sampled depends on the distance and view angles relative to the screen Very expensive Interpolate between mipmaps 16x Anisotropic filtering 64x Anisotropic filtering 19 Source: nvidia 20 5

Color blending and alpha blending Alpha blending (inverse source form) Transparency effect (e.g. water, glasses, etc.) Source blended with destination Several blending methods Additive C = SrcPixel (1,1,1,1) + DstPixel (1,1,1,1) = SrcPixel + DstPixel Subtractive C = SrcPixel (1,1,1,1) DstPixel (1,1,1,1) = SrcPixel DstPixel Multiplicative C = DstPixel SrcPixel Using Alpha value in the (Alpha blending) C = SrcPixel (α, α, α, α) + DstPixel (1-α,1-α,1-α,1-α) And many more in the API No transparency Src=0.5 (triangle) Dest=0.5 (square) Src=0.2 (triangle) Dest=0.8 (square) Src=0.8 (triangle) Dest=0.2 (square) 21 22 Another example w/out transparency Another alpha blending example Src=0.3 (rect) Dest=0.7 (checker) Src=0.5 (orange rect) Dest=0.5 Src=0.6 (triangle) Dest=0.4 23 24 6

6/2/16 Alpha test Multitexturing Map multiple textures to a polygon Texture1 lit Common APIs support 8 textures Performance will be reduced Multiple texturing stages in the pipeline Texture will be calculated by Straightforward texture mapping Multiplication Addition Subtraction if (α op val) reject pixel else accept pixel Operation 1 Texture3 Texture2 Operation 2 Operation 3 Texture: bar.jpg Reject pixels by checking their alpha values Model fences, chicken wires, etc. TextureN Operation N Final Color 25 26 Stenciling Multi-texturing example: light mapping Stencil buffer To reject certain pixels to be displayed To create special effect similar to alpha test Mask out part of the screen Set together with Z-buffer in 3D API Perform prior to Z-buffer test Some crumpled paper texture A spotlight map Different alpha blending 27 if ((stencil ref & mask) op (pixel val & mask)) accept pixel else reject pixel 28 7

Stencil buffer example Mirror effect (1) 1. Render the entire scene as normal (no reflection yet) 2. Clear the entire stencil buffer to 0 (i.e., mirror s fragments) 3. Render the mirror primitives and set the corresponding stencil buffer fragment to 1 4. Render the reflected objects only if stencil test passes (i.e., value==1) Using a reflection matrix for world transformation (Draw the scene as if they are seen in the mirror) Stencil buffer Stencil buffer Reject pixels inside this area This window area is set to be drawn by stencil buffer Clear stencil buffer Set stencil buffer for mirror object Render the reflected objects w/ stencil test From http://www.ziggyware.com/readarticle.php?article_id=116 29 From http://www.ziggyware.com/readarticle.php?article_id=116 30 Mirror effect (2) Can be done in a reverse order 1. Render the reflected image of the scene using a reflection matrix for world transformation (draw the scene as if they are seen in the mirror) 2. Render non-reflected with stencil buffer accept/reject test to prevent the reflected image being drawn over Bump mapping (1) Per-fragment lighting using bump map (normal map) to perturb surface normal No geometry tessellation, avoid geometry complexity Store normal vectors rather than RGB s for bump map Apply per-pixel shading (w/light vector, e.g., Phong shading) Shaded sphere Bump map Bump mapped sphere Source: wikipedia From http://www.ziggyware.com/readarticle.php?article_id=116 31 32 8

6/2/16 Bump mapping (2) Environment mapping (1) Normal map was derived from a height field map Height field stores the elevation for each texel Sample texel s height as well as texels to the right and above Range-compressed Normal Height field Cube Map Textures (in World coordinate) Each face encodes 1/6 of the panoramic environment 33 Environment mapping (2) Source: zabur.smz.sk Source: Game Creators, Ltd. 34 Environment mapping (3) Look up the environment map Add reflection to a fragment s final Norma Incident Ray (-L) l (N) Reflective Ray (R) Function texcube() is provided for sampling the texel in cube map Cube texture map World space Rendered image R = 2*(dot(N, L))*N - L 35 Source: Game Creators, Ltd. 36 9