Stripes, Rings, and Dots!

Similar documents
Introduction to Shaders for Visualization. The Basic Computer Graphics Pipeline

Bump Mapping. Mike Bailey. What is Bump-Mapping?

GLSL Geometry Shaders

Bump Mapping. Mike Bailey. Oregon State University. What is Bump-Mapping?

Introduction to the OpenGL Shading Language (GLSL)

The Transition from RenderMan to the OpenGL Shading Language (GLSL)

The Basic Computer Graphics Pipeline, OpenGL-style. Introduction to the OpenGL Shading Language (GLSL)

GPU Programming EE Final Examination

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

A Tessellated Parametric Triangular Bézier Patch

Stored Texture Shaders

Using Shaders for Lighting

Multipass Rendering: Rendering to a Texture

The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)!

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

Tessellation Shaders

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

Multipass Rendering: Rendering to a Texture

Lecture 09: Shaders (Part 1)

Programming shaders & GPUs Christian Miller CS Fall 2011

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

GPU Programming EE Final Examination

Programmable Graphics Hardware

GPU Programming EE Final Examination

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

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

Computer Graphics with OpenGL ES (J. Han) Chapter 6 Fragment shader

12.2 Programmable Graphics Hardware

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

Using Shaders for Lighting

Lab 9 - Metal and Glass

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Technical Game Development II. Reference: Rost, OpenGL Shading Language, 2nd Ed., AW, 2006 The Orange Book Also take CS 4731 Computer Graphics

Tuesday, 23 March OpenGL Shading Language

GLSL. OpenGL Shading Language. OpenGL 1.5 Logical Diagram. OpenGL 2.0 Logical Diagram

Technical Game Development II. Reference: Rost, OpenGL Shading Language, 2nd Ed., AW, 2006 The Orange Book Also take CS 4731 Computer Graphics

Waves, Displacement, Reflections. Arun Rao CS 594

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

OpenGL Programmable Shaders

GPU Programming EE Final Examination

Supplement to Lecture 22

Course 17: State-of-the-Art in Hardware Rendering. The OpenGL Shading Language Randi Rost 3Dlabs, Inc.

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

Yazhuo Liu Homework 3

Programming with OpenGL Part 3: Shaders. Ed Angel Professor of Emeritus of Computer Science University of New Mexico

Technical Game Development II. Reference: Rost, OpenGL Shading Language, 2nd Ed., AW, 2006 The Orange Book IMGD 4000 (D 10) 1

GLSL v1.20. Scott MacHaffie Schrödinger, Inc.

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

Vertex & Fragment shaders

Lecture 11 Shaders and WebGL. October 8, 2015

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

Lighting and Shading II. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Artistic Rendering with Graphics Shaders

Programmable GPUs Outline

± (1./ResS, 1./ResT) Using Fragment Shaders to Manipulate Images. Image Basics. Image Negative. t = 1.

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

Using Fragment Shaders to Manipulate Images

Using Fragment Shaders to Manipulate Images. Mike Bailey. Oregon State University. Image Basics. s = 0.

Computer Graphics Lighting

Computer Graphics Lighting. Why Do We Care About Lighting?

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

GPU Programming EE Final Examination

Using GPU Shaders for Visualization, II

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

Accelerating the Hyperbolic Display of Complex 2D Scenes Using the GPU

Sign up for crits! Announcments

The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)!

OpenGL shaders and programming models that provide object persistence

GLM. Mike Bailey. What is GLM?

Objectives. Open GL Shading Language (GLSL)

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

2D graphics with WebGL

Today. Rendering - III. Outline. Texturing: The 10,000m View. Texture Coordinates. Specifying Texture Coordinates in GL

CMPS160 Shader-based OpenGL Programming

SHADER PROGRAMMING. Based on Jian Huang s lecture on Shader Programming

CS559 Computer Graphics Fall 2015

Shadows. Prof. George Wolberg Dept. of Computer Science City College of New York

A Review of OpenGL Compute Shaders

OPENGL RENDERING PIPELINE

GLSL Language Details

1 of 5 9/10/ :11 PM

Design Focus. GLSL Language Details. Additions from C++ Additions for Graphics

v t t Modeling the World as a Mesh of Springs i-1 i+1 i-1 i+1 +y, +F Weight +y i-1 +y i +y 1 +y i+1 +y 2 x x

Computer Graphics (CS 543) Lecture 8a: Per-Vertex lighting, Shading and Per-Fragment lighting

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

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

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

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

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

Introduction to the OpenGL Shading Language

CS 432 Interactive Computer Graphics

EDAF80 Introduction to Computer Graphics. Seminar 3. Shaders. Michael Doggett. Slides by Carl Johan Gribel,

Modeling the World as a Mesh of Springs

Programming with OpenGL Shaders I. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

Renaissance: a functional shading language. Chad Anthony Austin. A thesis submitted to the graduate faculty

Lessons Learned from HW4. Shading. Objectives. Why we need shading. Shading. Scattering

GPU Programming EE Midterm Examination

Introduction to Shaders.

CS 4600 Fall Utah School of Computing

Programmable Graphics Hardware

Transcription:

1 Stripes, Rings, and Dots! Mike Bailey mjb@cs.oregonstate.edu This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License stripesringsanddots.pptx

Cartesian (X) Stripes 2 stripes.glib ##OpenGL GLIB Perspective 90 LookAt 0 0 2 0 0 0 0 1 0 Vertex stripes.vert Fragment stripes.frag Program Stripes \ ua <0 1. 10> \ up <0..25 1.> \ utol <0. 0..5> \ uamp <-5. 0. 5.> \ ufreq <0. 10. 20.> Color 1 0.5 0 Sphere 1 200 200

#version 330 compatibility Cartesian (X) Stripes stripes.vert 3 uniform float uamp; uniform float ufreq; out vec3 vcolor; out float vx, vy; out float vlightintensity; const vec3 LIGHTPOS = vec3( 0., 0., 10. ); void main( ) { vec3 tnorm = normalize( gl_normalmatrix * gl_normal ); vec3 ECposition = ( gl_modelviewmatrix * gl_vertex ).xyz; vlightintensity = abs( dot( normalize(lightpos - ECposition), tnorm ) ); vcolor = gl_color.rgb; vec3 MCposition = gl_vertex.xyz; vx = MCposition.x; vy = MCposition.y; vx = vx + uamp * sin( ufreq * vy ); gl_position = gl_modelviewprojectionmatrix * gl_vertex; }

Cartesian (X) Stripes 4 #version 330 compatibility stripes.frag uniform float ua; uniform float up; uniform float utol; in float vx, vy; in vec3 vcolor; in float vlightintensity; const vec4 WHITE = vec3( 1., 1., 1. ); void main( ) { ); } float f = fract( ua*vx ); float t = smoothstep( 0.5-uP-uTol, 0.5-uP+uTol, f ) - smoothstep( 0.5+uP-uTol, 0.5+uP+uTol, f vec3 rgb = vlightintensity * mix( WHITE, vcolor, t ); gl_fragcolor = ve4( rgb, 1. )p;

Cartesian (X) Stripes 5

Rings 6 ##OpenGL GLIB rings.glib Perspective 90 LookAt 0 0 2 0 0 0 0 1 0 Vertex rings.vert Fragment rings.frag Program Rings \ ua <0 5. 10> \ up <0..25 1.> \ utol <0. 0..5> Color 1 0.5 0 Sphere 1 200 200

#version 330 compatibility uniform float uamp; uniform float ufreq; out vec3 vcolor; out float vx, vy; out float vlightintensity; Rings rings.vert 7 const vec3 LIGHTPOS = vec3( 0., 0., 10. ); void main( ) { vec3 tnorm = normalize( gl_normalmatrix * gl_normal ); vec3 ECposition = ( gl_modelviewmatrix * gl_vertex ).xyz; vlightintensity = abs( dot( normalize(lightpos - ECposition), tnorm ) ); vcolor = gl_color.rgb; vec3 MCposition = gl_vertex.xyz; vx = MCposition.x; vy = MCposition.y; } gl_position = gl_modelviewprojectionmatrix * gl_vertex;

#version 330 compatibility uniform float ua; uniform float up; uniform float utol; in float vx, vy; in vec3 vcolor; in float vlightintensity; const vec3 WHITE = vec3( 1., 1., 1. ); Rings rings.frag 8 void main( ) { } float r = sqrt( vx*vx + vy*vy ); float rfrac = fract( ua*r ); float t = smoothstep( 0.5-uP-uTol, 0.5-uP+uTol, rfrac ) - smoothstep( 0.5+uP-uTol, 0.5+uP+uTol, rfrac ); vec3 rgb = vlightintensity * mix( WHITE, vcolor, t ); gl_fragcolor = vec4( rgb, 1. );

Rings (= Polar Stripes) 9

Circular Dots are a Local Pattern 10 numins, numint t = 1. 0,2 1,2 2,2 3,2 Diam (s,t) s = 0. 0,1 1,1 2,1 3,1 s = 1. u = 0. 0,0 1,0 2,0 3,0 (s c,t c ) t = 0. +

Circular Dots 11 t = 1. 0,2 1,2 2,2 3,2 numins = 2 numint = 1 float R = Diam/2.; int numins = int( s / Diam ); int numint = int( t / Diam ); s c = numins * Diam + R; t c = numint * Diam + R; Diam (s,t) s = 0. 0,1 1,1 2,1 3,1 s = 1. u = 0. 0,0 1,0 2,0 3,0 (s c,t c ) t = 0. +

Circular Dots 12

t = 1. Elliptical Dots numins = 2 numint = 1 float Ar = Ad/2.; float Br = Bd/2.; int numins = int( s / Ad ); int numint = int( t / Bd ); s c = numins *Ad + A r ; t c = numint *Bd + B r ; 13 (s,t) s = 0. s = 1. (s c,t c ) B r A r ss + tt R t = 0. + 1 + 1 Circle Circle Ellipse

Elliptical Dots 14

Elliptical Dots with Tolerance 15

Elliptical Dots with Tolerance 16 1.+uTol 1. 1.-uTol +

Soon we will see how to create elliptical dots with Noise! 17