Ray tracing on the GPU László Szécsi, TU Budapest.

Slides:



Advertisements
Similar presentations
Approximate Ray-Tracing on the GPU with Distance Impostors László Szirmay-Kalos Barnabás Aszódi István Lazányi Mátyás Premecz TU Budapest, Hungary.
Advertisements

CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Status – Week 257 Victor Moya. Summary GPU interface. GPU interface. GPU state. GPU state. API/Driver State. API/Driver State. Driver/CPU Proxy. Driver/CPU.
Graphics Hardware CMSC 435/634. Transform Shade Clip Project Rasterize Texture Z-buffer Interpolate Vertex Fragment Triangle A Graphics Pipeline.
I3D Fast Non-Linear Projections using Graphics Hardware Jean-Dominique Gascuel, Nicolas Holzschuch, Gabriel Fournier, Bernard Péroche I3D 2008.
CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.
3D Graphics Processor Architecture Victor Moya. PhD Project Research on architecture improvements for future Graphic Processor Units (GPUs). Research.
Shadow Volumes on Programmable Graphics Hardware Speaker: Alvin Date: 2003/11/3 EUROGRAPHICS 2003.
IN4151 Introduction 3D graphics 1 Introduction to 3D computer graphics part 2 Viewing pipeline Multi-processor implementation GPU architecture GPU algorithms.
Status – Week 277 Victor Moya.
GPUGI: Global Illumination Effects on the GPU
Pixel Shader Vertex Shader The Real-time Graphics Pipeline Input Assembler Rasterizer Output Merger.
Game Engine Design ITCS 4010/5010 Spring 2006 Kalpathi Subramanian Department of Computer Science UNC Charlotte.
Some Things Jeremy Sugerman 22 February Jeremy Sugerman, FLASHG 22 February 2005 Topics Quick GPU Topics Conditional Execution GPU Ray Tracing.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
1 Lecture 12 Texture Mapping uploading of the texture to the video memory the application of the texture onto geometry.
Simple Improvements to LI: Shadows Image Based Lighting László Szécsi.
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
GAM532 DPS932 – Week 1 Rendering Pipeline and Shaders.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
Basic Graphics Concepts Day One CSCI 440. Terminology object - the thing being modeled image - view of object(s) on the screen frame buffer - memory that.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Geometric Objects and Transformations. Coordinate systems rial.html.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Chris Kerkhoff Matthew Sullivan 10/16/2009.  Shaders are simple programs that describe the traits of either a vertex or a pixel.  Shaders replace a.
COMP 261 Lecture 16 3D Rendering. input: set of polygons viewing direction direction of light source(s) size of window. output: an image Actions rotate.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
1 Dr. Scott Schaefer Programmable Shaders. 2/30 Graphics Cards Performance Nvidia Geforce 6800 GTX 1  6.4 billion pixels/sec Nvidia Geforce 7900 GTX.
Programming the GPU on Cg Szirmay-Kalos László Web:
CSE 690: GPGPU Lecture 6: Cg Tutorial Klaus Mueller Computer Science, Stony Brook University.
CSE Real Time Rendering Week 2. Graphics Processing 2.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
COMPUTER GRAPHICS CSCI 375. What do I need to know?  Familiarity with  Trigonometry  Analytic geometry  Linear algebra  Data structures  OOP.
Shadow Mapping Chun-Fa Chang National Taiwan Normal University.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Computer Graphics Bing-Yu Chen National Taiwan University.
Fateme Hajikarami Spring  What is GPGPU ? ◦ General-Purpose computing on a Graphics Processing Unit ◦ Using graphic hardware for non-graphic computations.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
Ray Tracing using Programmable Graphics Hardware
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.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS The GPU.
Ray Tracing by GPU Ming Ouhyoung. Outline Introduction Graphics Hardware Streaming Ray Tracing Discussion.
2 3D Viewing Process  3D viewing process MC Model Space Model Transformation Model Transformation WC World Space Viewing Transformation Viewing Transformation.
GLSL I.  Fixed vs. Programmable  HW fixed function pipeline ▪ Faster ▪ Limited  New programmable hardware ▪ Many effects become possible. ▪ Global.
Chapter 1 Graphics Systems and Models Models and Architectures.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
Programmable Shaders Dr. Scott Schaefer.
Reflective Shadow Mapping By: Mitchell Allen.
The Graphic PipeLine
Deferred Lighting.
CS451Real-time Rendering Pipeline
Real-time Computer Graphics Overview
Models and Architectures
Models and Architectures
Models and Architectures
Introduction to Computer Graphics with WebGL
Graphics Processing Unit
Models and Architectures
Models and Architectures
Hw03 : shader.
CS 480/680 Computer Graphics GLSL Overview.
CIS 6930: Chip Multiprocessor: GPU Architecture and Programming
Presentation transcript:

Ray tracing on the GPU László Szécsi, TU Budapest

Ray tracing on the GPU Ray tracing: for each ray do t = infinity for each triangle do tnew = Intersect(triangle, ray) if (tnew < t) t = tnew endfor hit[ray] = ray.o + ray.dir * t endfor Problems: two loops - all elements with all elements t is a global variable Input stream of geometry Textures z-buffer

Ray engine Input texture: rays Combination: a triangle with each ray as many outputs as rays pixels a triangle is a full screen quad, pixel shader intersects a triangle with a ray Input stream: triangles Output texture: hits

Ray engine CPU prog Vertex shader frag shader “Triangles” as full screen quads Ray texture ids Rasterization Interpolation Rays in Texture maps Intersection between one triangle and a ray Triangles as many times as pixels the quad has depth composit Hit t First Hits

CPU: triangles as full screen quads Triangle triang[ntriangles]; void Display( ) {... glBegin( GL_QUADS ); for(int i = 0; i < ntriangles, i++) { glMultiTexCoord2fARB(GL_TEXTURE1_ARB, // TEXCOORD1 triang[i].v1.x, triang[i].v1.y, triang[i].v1.z); glMultiTexCoord2fARB(GL_TEXTURE2_ARB, // TEXCOORD2 triang[i].v2.x, triang[i].v2.y, triang[i].v2.z); glMultiTexCoord2fARB(GL_TEXTURE3_ARB, // TEXCOORD3 triang[i].v3.x, triang[i].v3.y, triang[i].v3.z); glTexCoord2f(0,0); glVertex4f(-1,-1, 0, 1); glTexCoord2f(0,1); glVertex4f(-1, 1, 0, 1); glTexCoord2f(1,1); glVertex4f( 1, 1, 0, 1); glTexCoord2f(1,0); glVertex4f( 1,-1, 0, 1); } glEnd(); }

Vertex shader is just copying void main( in float4 position : POSITION, in float2 rayuv : TEXCOORD0, in float3 r1 : TEXCOORD1, in float3 r2 : TEXCOORD2, in float3 r3 : TEXCOORD3, out float3 hposition : POSITION, out float2 orayuv : TEXCOORD0, out float3 or1 : TEXCOORD1, out float3 or2 : TEXCOORD2, out float3 or3 : TEXCOORD3 ) { or1 = r1; or2 = r2; or3 = r3; orayuv = rayuv; hposition = position; // already in clipping space }

Triangle-ray intersection 1.Plane intersection: p = rayo + raydir · t, t > 0 (p - r1) ·n = 0, normal: n = (r2 - r1) x (r3 - r1) 2. Is the intersection inside the triangle? ((r2 - r1) x (p - r1)) ·n > 0 ((r3 - r2) x (p - r2)) ·n > 0 ((r1 - r3) x (p - r3)) ·n > 0 r1 r2 p r3 (r1 – rayo) · n raydir · n t =

Pixel shader: ray-triangle intersection void main(in float2 rayuv : TEXCOORD0, // ray index in float3 r1 : TEXCOORD1, // vertex 1 in float3 r2 : TEXCOORD2, // vertex 2 in float3 r3 : TEXCOORD3, // vertex 3 of triang out float3 p : COLOR, // hit point to texture out float t : DEPTH, // z buffer finds the min uniform sampler2D rayorgs, // array of rays uniform sampler2D raydirs, uniform float maxdepth) { float3 rayo = tex2D(rayorgs, rayuv); // ray pars float3 raydir = tex2d(raydirs, rayuv); float3 normal = cross(r2 – r1, r3 – r1); t = dot(p1 – rayo, normal) / dot(raydir, normal); p = rayo + raydir * t; if (t < 0 || dot(cross(r2-r1, p-r1), normal) < 0 || dot(cross(r3-r2, p-r2), normal) < 0 || dot(cross(r1-r3, p-r3), normal) < 0) t = 2; // ignore else t /= maxdepth; }

Ray tracing results