Steiner- Wallner- Podaras

Similar documents
CS452/552; EE465/505. Texture Mapping in WebGL

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

Discussion 3. PPM loading Texture rendering in OpenGL

CISC 3620 Lecture 7 Lighting and shading. Topics: Exam results Buffers Texture mapping intro Texture mapping basics WebGL texture mapping

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

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

Lecture 19: OpenGL Texture Mapping. CITS3003 Graphics & Animation

Graphics. Texture Mapping 고려대학교컴퓨터그래픽스연구실.

CS 432 Interactive Computer Graphics

CT5510: Computer Graphics. Texture Mapping

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

Texture Mapping. Computer Graphics, 2015 Lecture 9. Johan Nysjö Centre for Image analysis Uppsala University

-=Catmull's Texturing=1974. Part I of Texturing

CS212. OpenGL Texture Mapping and Related

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

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

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

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

Lighting and Texturing

三維繪圖程式設計 3D Graphics Programming Design 第七章基礎材質張貼技術嘉大資工系盧天麒

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

Mipmaps. Lecture 23 Subsection Fri, Oct 30, Hampden-Sydney College. Mipmaps. Robb T. Koether. Discrete Sampling.

Texture Mapping CSCI 4229/5229 Computer Graphics Fall 2016

Mipmaps. Lecture 35. Robb T. Koether. Hampden-Sydney College. Wed, Nov 18, 2015

ก ก ก.

CS4621/5621 Fall Basics of OpenGL/GLSL Textures Basics

Texture Mapping. Texture Mapping. Map textures to surfaces. Trompe L Oeil ( Deceive the Eye ) The texture. Texture map

CS452/552; EE465/505. Image Processing Frame Buffer Objects

Practical Texturing (WebGL) CS559 Fall 2016 Lecture 20 November 7th 2016

Lecture 22 Sections 8.8, 8.9, Wed, Oct 28, 2009

OpenGL Texture Mapping. Objectives Introduce the OpenGL texture functions and options

Texture Mapping. Mike Bailey.

Textures. Texture Mapping. Bitmap Textures. Basic Texture Techniques

Computergraphics Exercise 15/ Shading & Texturing

Stored Texture Shaders

Objectives. Texture Mapping and NURBS Week 7. The Limits of Geometric Modeling. Modeling an Orange. Three Types of Mapping. Modeling an Orange (2)

OUTLINE. Implementing Texturing What Can Go Wrong and How to Fix It Mipmapping Filtering Perspective Correction

Grafica Computazionale

Preparing for Texture Access. Stored Texture Shaders. Accessing Texture Maps. Vertex Shader Texture Access

Introduction to Computer Graphics with WebGL

Lecture 5 3D graphics part 3

INF3320 Computer Graphics and Discrete Geometry

Cap. 3 Textures. Mestrado em Engenharia Informática (6931) 1º ano, 1º semestre

Methodology for Lecture

Texture mapping. Computer Graphics CSE 167 Lecture 9

Magnification and Minification

Lecture 07: Buffers and Textures

General Purpose computation on GPUs. Liangjun Zhang 2/23/2005

Computer Graphics Texture Mapping

CS179: GPU Programming

Applying Textures. Lecture 27. Robb T. Koether. Hampden-Sydney College. Fri, Nov 3, 2017

To Do. Review of Last Demo. Methodology for Lecture. Geometry Basic Setup. Outline. Foundations of Computer Graphics (Fall 2012)

CS GPU and GPGPU Programming Lecture 12: GPU Texturing 1. Markus Hadwiger, KAUST

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

INF3320 Computer Graphics and Discrete Geometry

CS GPU and GPGPU Programming Lecture 16+17: GPU Texturing 1+2. Markus Hadwiger, KAUST

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

Computer Graphics Texture Mapping

Overview. By end of the week:

Lecture 5. Scan Conversion Textures hw2

CMSC 425: Lecture 12 Texture Mapping Thursday, Mar 14, 2013

SUMMARY. CS380: Introduction to Computer Graphics Texture Mapping Chapter 15. Min H. Kim KAIST School of Computing 18/05/03.

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

Chapter 6 Texture Mapping

WebGL. Creating Interactive Content with WebGL. Media #WWDC14. Session 509 Dean Jackson and Brady Eidson WebKit Engineers

+ = Texturing: Glue n-dimensional images onto geometrical objects. Texturing. Texture magnification. Texture coordinates. Bilinear interpolation

Texture Mapping and Sampling

Image I/O and OpenGL Textures

CS335 Graphics and Multimedia. Slides adopted from OpenGL Tutorial

CPSC 436D Video Game Programming

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

Assignment #5: Scalar Field Visualization 3D: Direct Volume Rendering

1)Write a shader program that renders a regular pentagon with textured image like the one shown below.

Shading/Texturing. Dr. Scott Schaefer

9.Texture Mapping. Chapter 9. Chapter Objectives

Picking (In WebGL) Picking idea

PROFESSIONAL. WebGL Programming DEVELOPING 3D GRAPHICS FOR THE WEB. Andreas Anyuru WILEY. John Wiley & Sons, Ltd.

Computer Graphics. Three-Dimensional Graphics VI. Guoying Zhao 1 / 73

Texture. No Textures

Chapter 9 Texture Mapping An Overview and an Example Steps in Texture Mapping A Sample Program Specifying the Texture Texture Proxy Replacing All or

PFX Language Format. Specification

CS193P - Lecture 19. iphone Application Development. OpenGL ES

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

CS452/552; EE465/505. Shadow Mapping in WebGL

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

Texture Mapping 1/34

CSE 167: Lecture #17: Volume Rendering. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Computational Strategies

Copyright Khronos Group 2012 Page 1. Teaching GL. Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012

Texture and other Mappings

Best practices for effective OpenGL programming. Dan Omachi OpenGL Development Engineer

Texture Mapping 1/34

Introduction to Computer Graphics with WebGL

CS GPU and GPGPU Programming Lecture 11: GPU Texturing 1. Markus Hadwiger, KAUST

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

Shadow Rendering. CS7GV3 Real-time Rendering

Fog example. Fog is atmospheric effect. Better realism, helps determine distances

Department of Computer Sciences Graphics Spring 2013 (Lecture 19) Bump Maps

Real-time Graphics 3. Lighting, Texturing

Textures. Datorgrafik 2006

Transcription:

Texturing

2

3

Some words on textures Texturing = mapping 2D image to a model (*You will hear more on other texturing- methods in the course.) Not a trivial task! 4

Texturing how it works 5

UV coordinates Enable unambiguous applicaoon of texture to model Are applied for each vertex And interpolated for each fragment Run from 0 1 6

UV coordinates Generate UV s in 3D sowware with the model 7

Problem: ArOfacts We see textured objects from near and far 1 px of model on screen == 1 px of texture OK! 8

Problem: ArOfacts We see textured objects from near and far 1 px of model on screen == 1 px of texture OK! 1 px on screen smaller/bigger OH OH! ArOfacts! Undersampling, texture info is lost 9

SoluOon: Texture filtering More than one texture- pixel can influence the resulong screen- pixel color InterpolaOon (at runome or in preprocess) Magnifica3on Minifica3on 10

MagnificaOon Super sampling of textures Nearest neighbour Bilinear 11

Bilinear interpolaoon 12

Bilinear interpolaoon 13

Bilinear interpolaoon 14

MinificaOon via Mipmpas Idea: Pre- filter image to avoid arofacts Filter and downsample by factor 2 in each step Creates Mip- Map image pyramid from level 0 down to 1x1 image Level 4 Level 3 Level 2 Level 0 Level 1 15

Mipmaps Use suitable level Or: Trilinear interpola3on between two levels Determine two mipmaps that fit Bilinear interpolaoon in each level Now interpolate the two results! 16

Anisotropic Filtering Triliniear filtering not always sufficient: For steep angles 17

Texture wrapping Different wrapping modes can be set for each dimension of the texture GL_REPEAT GL_MIRRORED_REPEAT GL_CLAMP_TO_EDGE repeat mirror clamp edge 18

1. Create Texture Texture creaoon var texture = gl.createtexture(); 2. Ini3alize/Bind Texture gl.bindtexture(gl.texture_2d, texture); (In WebGL: either gl.texture_2d or gl.texture_cube_map) 19

Texture creaoon 3. Set filtering parameters gl.texparameteri( GLenum target, GLenum pname, GLint param ); gl.texparameteri(gl.texture_2d, gl.texture_min_filter, gl.linear_mipmap_linear); 20

Filter parameters gl.texparameteri(glenum target, GLenum pname, GLint param); GL_TEXTURE_MAG_FILTER GL_TEXTURE_MIN_FILTER GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T MagnificaOon filter MinificaOon filter Wrapping mode Wrapping mode 21

Filter parameters gl.texparameteri(glenum target, GLenum pname, GLint param); GL_NEAREST GL_LINEAR GL_NEAREST_MIPMAP_NEAREST GL_LINEAR_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_LINEAR Nearest neighbour Bilinear interpolaoon Best fimng mipmap w nearest neighbour Best fimng mipmap w bilinear interpolaoon Generate values from 2 Mipmaps with nearest neighbour and interpolate the two results Generate values from 2 Mipmaps with bilinear interpolaoon and interpolate the two results ( = trilinear) 22

Texture creaoon Anisotropic filter via Extension gl.getextension('ext_texture_filter_anisotropic') var max = gl.getparameter(ext.max_texture_max_anisotropy_ext); gl.texparameterf(gl.texture_2d, ext.texture_max_anisotropy_ext, max); 23

Texture creaoon 4. Upload image data gl.teximage2d( GLenum target, GLint level, //mipmap level GLenum internalformat, //must match format GLenum format, GLenum type, //type of pixel data HTMLImageElement image ) 24

Texture creaoon 4. Upload image data var image = new Image(); image.onload = function() { gl.bindtexture(gl.texture_2d, texture); //Upload imagedata to bond texture object: gl.teximage2d(gl.texture_2d, 0, gl.rgba, gl.rgba, gl.unsigned_byte, image); } image.src = 'texture.png'; 25

Texture creaoon 5. Create Mipmaps gl.generatemipmap(glenum target); gl.generatemipmap(gl.texture_2d); Restric3ons in WebGL! Texture must be a power of two size! (If not, there s only limited support: no repeaong, no mipmapping ) 26

Texture creaoon 6. Use texture //bind texture gl.bindtexture(gl.texture_2d, my_texture); //set as uniform var samplerlocation = gl.getuniformlocation(program, "texture"); gl.uniform1i(samplerlocation, 0); //TextureUnit0 //Fragmentshader uniform sampler2d texture; gl_fragcolor = texture2d(texture, fragmentuv); 27

Texture Units Allow to use more than one texture Bind each Texture to a TextureUnit 28

Texture Units Tell WebGL which Unit is acove (Default: Unit 0) Upload data to bound unit Set uniforms in shader with index of unit gl.activetexture(gl.texture0); gl.bindtexture(gl.texture_2d, my_1st_texture); glteximage2d( ) //upload data gl.uniform1i(1st_uniform_location, 0); //Unit0 gl.activetexture(gl.texture1); gl.bindtexture(gl.texture_2d, my_2nd_texture); glteximage2d( ) //upload data gl.uniform1i(2nd_uniform_location, 1); //Unit1 29

DEMO 30