3D Objects in WebGL Loading 3D model files. Announcement Midterm exam on 12/2 –No Internet connection. –Example code and exam questions will be on USB.

Slides:



Advertisements
Similar presentations
Bump Mapping CSE 781 Roger Crawfis.
Advertisements

An introduction to WebGL Viktor Kovács. Content A little 3D modeling. What is WebGL? Introducing Three.js. Visualizing GDL objects.
GLSL I May 28, 2007 (Adapted from Ed Angel’s lecture slides)
GLSL I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico.
Mohan Sridharan Based on slides created by Edward Angel GLSL I 1 CS4395: Computer Graphics.
GAM532 DPS932 – Week 1 Rendering Pipeline and Shaders.
What is ? Open Graphics Library A cross-language, multi-platform API for rendering 2D and 3D computer graphics. The API is used to interact with a Graphics.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
Shading. What is Shading? Assigning of a color to a pixel in the final image. So, everything in shading is about how to select and combine colors to get.
CS 480/680 Computer Graphics Shader Applications Dr. Frederick C Harris, Jr. Fall 2011.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Graphics CSCI 343, Fall 2015 Lecture 4 More on WebGL.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shader Applications Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
1 Graphics CSCI 343, Fall 2015 Lecture 21 Lighting and Shading III.
Bump Map 1. High Field Function: H(u, v) New Normal : N’
Vertex Buffer Objects and Shader Attributes. For Further Reading Angel 7 th Ed: –Most parts of Chapter 2. Beginning WebGL: –Chapter 1: vertex Buffer Objects,
Week 3 Lecture 4: Part 2: GLSL I Based on Interactive Computer Graphics (Angel) - Chapter 9.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Graphics CSCI 343, Fall 2015 Lecture 25 Texture Mapping.
CSCI 440.  So far we have learned how to  build shapes  create movement  change views  add simple lights  But, our objects still look very cartoonish.
Attack of the Clones Image source:
 Learn how you can use the shader through OpenGL ES  Add texture on object and make the object have a different look!!
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
OpenGL Shading Language
Mouse Input. For Further Reading Learning WebGL, Lesson 11: 2.
MP3 Frequently Asked Questions (IN OFFICE HOURS).
Web Audio API Let your WebGL program dance. Announcement Final project proposal due in one week. Choice of demo date? Plan for the 12/23 class. 2.
Programming with OpenGL Part 3: Shaders Ed Angel Professor of Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive.
GLSL I.  Fixed vs. Programmable  HW fixed function pipeline ▪ Faster ▪ Limited  New programmable hardware ▪ Many effects become possible. ▪ Global.
Advanced Texture Mapping Bump Mapping & Environment Mapping (Reflection)
MP3.. Start at the very beginning. Almost. Either start from nothing yourself, or use the empty template for this MP. Run through the provided files are.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 5 Examples 1.
Shaders, part 2 alexandri zavodny.
Reflective Shadow Mapping By: Mitchell Allen.
Introduction to Computer Graphics with WebGL
The Basics: HTML5, Drawing, and Source Code Organization
Tips for Environment Mapping
Let your WebGL program dance
Introduction to Computer Graphics with WebGL
GLSL I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico.
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Day 05 Shader Basics.
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Chapter VI OpenGL ES and Shader
Chapter IX Bump Mapping
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
ICG 2018 Fall Homework1 Guidance
Programming with OpenGL Part 3: Shaders
Advanced Texture Mapping
03 | Creating, Texturing and Moving Objects
Computer Graphics Shading in OpenGL
Textures in WebGL.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science
OpenGL-Rendering Pipeline
CS 480/680 Fall 2011 Dr. Frederick C Harris, Jr. Computer Graphics
Presentation transcript:

3D Objects in WebGL Loading 3D model files

Announcement Midterm exam on 12/2 –No Internet connection. –Example code and exam questions will be on USB disks. –Books and paper references are allowed. –Electronic devices are NOT allowed. –Cheating in exam automatically fails the course. 2

Topics for Midterm Exam on 12/2 How to add user interface elements in HTML and event handlers in JS? How to add new vertex attributes (in both shaders and JS)? How to add new varying parameters? How to pass uniform variables to the shaders? How to make minor change to vertex shaders and fragment shaders? You will be asked to modify existing codes to achieve the goals defined in the problems. 3

Final Projects It is about time to think about your final projects. Themes for this semester: Interactive Art in WebGL –Animating objects with changing colors, positions, shapes, …etc. –Interacts with mouse input or audio input (music). 4

Inspiration three-js-webglhttp://srchea.com/experimenting-with-web-audio-api- three-js-webgl visualization-with-web-audio-canvas-and-the- soundcloud-apihttp:// visualization-with-web-audio-canvas-and-the- soundcloud-api audio-spectrum-visualizer/launchhttps://developer.mozilla.org/en-US/demos/detail/3d- audio-spectrum-visualizer/launch 5

For Further Reading Teapot-streams.js is from shiny-teapot/ shiny-teapot/ Beginning WebGL: –Chapter 8: Meshes (OBJ, JSON) WebGL Programming Guide: –Chapter 10: OBJViewer.js –htt ps://github.com/machinezilla/webgl-programming-guidehtt ps://github.com/machinezilla/webgl-programming-guide 6

Qick Review of the Bump Mapping Lab (last week)

Bump Mapped Cube

Bump Mapped Cube (HTML code)HTML code... void main() {... // Normal variation stored in the texture is within [0,1]. // Convert it to [-1, 1] vec4 texel = texture2D( texture, fTexCoord ) * ; N.xy += texel.xy; N = normalize( N );... gl_FragColor = (ambient + diffuse) * fColor + specular; }

Lab Time! Download cube3_bump_lab.html and.js Task #1: Fix the JS code that is missing the array buffer and vertex attribute for the texture coordinates. Task #2: Modify the normal vector in the fragment shader so the bump map influence the lighting. Task #3: Do you think the shader is 100% correct? If not, then what is wrong? 10

Tangent, Normal, Binormal What does the (dX, dY) in bump map mean? 11

N.xy += texel.xy is correct only if N is along the Z direction. i.e. N=(0,0,1) or (0,0,-1). texel.xy should be applied to the tangent plane spanned by T and B. But where do we get T and B in the shaders? –Needs tangent vector (T) as a new vertex attribute, just like the normal vector (N). 12

Loading 3D Models into WebGL

Many Different Solutions 1.Define the data in JS: –For example: teapot-streams.js in: ogle/shiny-teapot/ 2.Using utilities such as THREE.js: –See Beginning WebGL Chapter 8: Meshes (OBJ, JSON) 14

OBJ Loader WebGL Programming Guide: –Chapter 10: OBJViewer.js –htt ps://github.com/machinezilla/webgl-programming-guidehtt ps://github.com/machinezilla/webgl-programming-guide Example: – de/ch10/OBJViewer.htmlhttp:// /CG/code/WebGL%20Programming%20Gui de/ch10/OBJViewer.html 15

A Simple Example – OBJ Array of vertices Array of polygons Optional: –Normals –Textures –Groups v v v v v v v v # 8 vertices vn vn vn vn vn vn vt 0 0 vt 1 0 vt 0 1 vt 1 1 #4 texture coordinates g default f 1/1/4 3/2/4 4/4/4 2/3/4 f 5/1/3 6/2/3 8/4/3 7/3/3 f 1/1/6 2/2/6 6/4/6 5/3/6 f 2/1/1 4/2/1 8/4/1 6/3/1 f 4/1/5 3/2/5 7/4/5 8/3/5 f 3/1/2 1/2/2 5/4/2 7/3/2 # 6 faces