- Surface Rendering -

Similar documents
Lecture 09: Shaders (Part 1)

Supplement to Lecture 22

Lecture 31 Sections 9.1, 9.2, 9.3. Mon, Nov 23, 2009

Objectives. Open GL Shading Language (GLSL)

An Introduction to 3D Computer Graphics, Stereoscopic Image, and Animation in OpenGL and C/C++ Fore June

The GLSL API. Mike Bailey. Oregon State University. Geometry Shader. Program. The GLSL Shader-creation Process. create. compile. Vertex.

Programming shaders & GPUs Christian Miller CS Fall 2011

Objectives. Coupling GLSL to Applications Example applications

GLSL II. Objectives. Coupling GLSL to Applications Example applications

GLSL: Creating GLSL Programs - Overview

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 3: Shaders

EECS 487: Interactive Computer Graphics

Computer Graphics (CS 543) Lecture 3b: Shader Setup & GLSL Introduction

CS475/CS675 - Computer Graphics. OpenGL Drawing

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

Philip Calderon CSE 520 Lab 3 Color Shader

Information Coding / Computer Graphics, ISY, LiTH GLSL. OpenGL Shading Language. Language with syntax similar to C

Computer Graphics (CS 4731) & 2D Graphics Systems

Shaders CSCI 4229/5229 Computer Graphics Fall 2017

Some advantages come from the limited environment! No classes. Stranight ans simple code. Remarkably. Avoids most of the bad things with C/C++.

Programming with OpenGL Part 5: More GLSL. Ed Angel Professor Emeritus of Computer Science University of New Mexico

Programmable shader. Hanyang University

CSE 4431/ M Advanced Topics in 3D Computer Graphics. TA: Margarita Vinnikov

Erik Anchondo cse 520 lab 4

2a. The triangles scale increases (expands) when the 'e' key is pressed and decreases (contracts) when the 'c' key is pressed.

Shaders CSCI 4239/5239 Advanced Computer Graphics Spring 2014

COMP371 COMPUTER GRAPHICS

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

3D Game Programming Programmable Pipelines. Ming-Te Chi Department of Computer Science, National Chengchi University

CMPS160 Shader-based OpenGL Programming. All slides originally from Prabath Gunawardane, et al. unless noted otherwise

Advanced Graphics. The Shader knows. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people

CS 380 Introduction to Computer Graphics. LAB (1) : OpenGL Tutorial Reference : Foundations of 3D Computer Graphics, Steven J.

OpenGL pipeline Evolution and OpenGL Shading Language (GLSL) Part 2/3 Vertex and Fragment Shaders

Objectives. Programming with OpenGL Part 5: More GLSL. Program Object. Reading a Shader. Shader Reader. Linking Shaders with Application

Today s Agenda. Shaders fundamentals. Programming with shader-based OpenGL

Programmable Graphics Hardware

An Introduction to 3D Computer Graphics, Stereoscopic Image, and Animation in OpenGL and C/C++ Fore June

CMPS160 Shader-based OpenGL Programming

Shader Programs. Lecture 30 Subsections 2.8.2, Robb T. Koether. Hampden-Sydney College. Wed, Nov 16, 2011

Programmable Shading. University of Texas at Austin CS354 - Computer Graphics

1. Write a shader program that animates the morphing of Figure 'A' to Figure 'B' and back.

Tutorial 1: Your First Triangle!

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

OpenGL Programmable Shaders

GLSL Programming. Nicolas Holzschuch

OpenGL. Shading Language. Third Edition

Programmable Graphics Hardware

Graphics Programming. Computer Graphics, VT 2016 Lecture 2, Chapter 2. Fredrik Nysjö Centre for Image analysis Uppsala University

OpenGL shaders and programming models that provide object persistence

INTRODUCTION TO OPENGL PIPELINE

CMSC427 Fall 2017 OpenGL Notes A: Starting with JOGL and OpenGL Objectives of notes Readings Computer Graphics Programming in OpenGL with Java

CMSC427 OpenGL and JOGL

12.2 Programmable Graphics Hardware

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people

C Programming Language

Cg 2.0. Mark Kilgard

Programmable Graphics Hardware

Mali Offline Compiler User Guide

Practical 1: OpenTK Tutorial

CSI 402 Lecture 2 Working with Files (Text and Binary)

Lecture 5 Vertex and Fragment Shaders-1. CITS3003 Graphics & Animation

Developer Tools. Robert Strzodka. caesar research center Bonn, Germany

Programmable GPUs. Real Time Graphics 11/13/2013. Nalu 2004 (NVIDIA Corporation) GeForce 6. Virtua Fighter 1995 (SEGA Corporation) NV1

CSI 402 Lecture 2 (More on Files) 2 1 / 20

GLSL 1: Basics. J.Tumblin-Modified SLIDES from:

fopen() fclose() fgetc() fputc() fread() fwrite()

Tutorial 04. Harshavardhan Kode. September 14, 2015

CSI 402 Systems Programming LECTURE 4 FILES AND FILE OPERATIONS

Intro to GPU Programming (OpenGL Shading Language) Cliff Lindsay Ph.D. Student CS WPI

CPSC 436D Video Game Programming

Shading System Immediate-Mode API v2.2

Information Coding / Computer Graphics, ISY, LiTH GLSL. OpenGL Shading Language. Language with syntax similar to C

1) Here is the various stages of the tetrahedron:

System Software Experiment 1 Lecture 7

OpenGL and GLUT. COMP413 Computer Graphics. School of Computer Sci. & Eng. Kyungpook National University, Korea. Spring Semester, 2016

Shaders. Slide credit to Prof. Zwicker

Practical 1: OpenTK Tutorial

Shaders. Introduction. OpenGL Grows via Extensions. OpenGL Extensions. OpenGL 2.0 Added Shaders. Shaders Enable Many New Effects

OpenGL: What s Coming Down the Graphics Pipeline. Dave Shreiner ARM

COURSE 17: STATE-OF-THE-ART IN SHADING HARDWARE1 CHAPTER 6: THE OPENGL SHADING LANGUAGE 2. Randi J. Rost 3Dlabs, Inc.

OUTLINE. Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system

compatibility mode core mode

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

I think this assignment should have 8 objectives but we should still mark it out of 10. The Mean TA.

Introduction to Shaders.

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

GLSL Overview: Creating a Program

last time put back pipeline figure today will be very codey OpenGL API library of routines to control graphics calls to compile and load shaders

Advanced Graphics. OpenGL and Shaders I. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd

Introductory Seminar

Intermediate Programming, Spring 2017*

BCA611 Video Oyunları için 3B Grafik

3d Programming I. Dr Anton Gerdelan

Lighting and Texturing

CS770/870 Spring 2017 Open GL Shader Language GLSL

CS770/870 Spring 2017 Open GL Shader Language GLSL

CSE 4431/ M Advanced Topics in 3D Computer Graphics. TA: Margarita Vinnikov

An Overview GLUT GLSL GLEW

Shader Programming. Daniel Wesslén, Stefan Seipel, Examples

Transcription:

Programmable Shaders II - Surface Rendering - 12 th Week, 2008 Sun-Jeong Kim Downloading 2

GLEW OpenGL Extension Wrangler Library http://glew.sourceforge.net/ Cross-platform open-source C/C++ extension loading library Windows, Linux, Mac OS, FreeBSD, Irix, and Solaris Support for OpenGL core and extensions 3DFX_*, APPLE_*, ARB_*, ATI_*, EXT_*, MESA_*, NV_*, SGI_*, SUN_*, WIN_* 3 glew.zip C: Program Files Microsoft Visual Studio 8 VC PlatformSDK C: WINDOWS 4

glewinfo.txt 5 visualinfo.txt 6

Linking Shaders to OpenGL OpenGL Extensions ARB_shader_objects ARB_vertex_shader ARB_fragment_shader OpenGL 2.0 Almost identical to using extensions Avoid extension suffixes on function names 7 Container for shaders Program Object Can contain multiple shaders Other GLSL functions GLuint myprogobj; myprogobj = glcreateprogram(); // define shader objects here gluseprogram( g myprogobj ); gllinkprogram( myprogobj ); 8

Reading a Shader Shaders are added to the program object and compiled Usual method of passing a shader is as a nullterminated string using the function glshadersource If the shader is in a file, we can write a reader to convert the file to a string 9 Shader Reader char *ReadTextFile( char *filename ) { FILE *fp; char *content = NULL; int count = 0; if( filename!= NULL ) { fp = fopen( filename, "rt" ); if( fp!= NULL ) { fseek( fp, 0, SEEK_END END ); count = ftell( fp ); rewind( fp ); } if( count > 0 ) { content = (char *)malloc( sizeof(char) * (count+1) ); count = fread( content, sizeof(char), count, fp ); content[count] = '\0'; } fclose(fp); } } return content; 10

Adding Shaders GLuint vshader = glcreateshader( GL_VERTEX_SHADER ); GLuint fshader = glcreateshader( GL_FRAGMENT_SHADER ); char *vsource = ReadTextFile( "simple.vert" ); char *fsource = ReadTextFile( "simple.frag" ); const char *vv = vsource; const char *ff = fsource; glshadersource( vshader, 1, &vv, NULL ); glshadersource( fshader, 1, &ff, NULL ); free( vsource ); free( fsource ); glcompileshader( vshader ); glcompileshader( fshader ); glattachshader( myprogobj, vshader ); glattachshader( myprogobj, fshader ); 11 New Project 12

Header Files & Global Variables 13 Initialization 14

Creating Shaders 15 Reading Shader Files 16

Vertex Shader Fixed functionality 17 Fragment Shader 18

Result Fixed Pipeline 19 Setting Shaders 20

Result Programmable Pipeline 21 Using Shaders 22

Result Using Shaders 23 Specifying Vertex Attributes & Uniform Variables Vertex attributes are named in shaders gl_vertex, gl_color, gl_normal, Linker forms a table Application can get index from table and tie it to an application variable Similar process to uniform variables 24

Flatten Shader (1) 25 Flatten Shader (2) 26

Flatten Shader (3) 27 Flatten Shader (4) 28

Result Flatten Shader (1) 29 Flatten Shader (5) 30

Result Flatten Shader (2) 31 Flatten Shader (6) 32

Result Flatten Shader (3) 33 Flatten Shader (7) 34

Result Flatten Shader (4) 35 Flatten Shader (8) 36

Result Flatten Shader (5) 37 Phong Shading Directional Light (1) 38

Phong Shading Directional Light (2) Add New Item 39 Phong Shading Directional Light (3) 40

Phong Shading Directional Light (4) Add New Item 41 Phong Shading Directional Light (5) 42

Phong Shading Directional Light (6) 43 Result Phong Shading DL 44

Phong Shading Point Light (1) 45 Phong Shading Point Light (2) 46

Phong Shading Point Light (3) 47 Phong Shading Point Light (4) 48

Result Phong Shading PL 49 Exercises Spotlight 를이용한 Phong Shading 을구현하시오. 50