Point-Based rendering on GPU hardware. Advanced Computer Graphics 2008

Similar documents
Point-Based Rendering

High-Quality Surface Splatting on Today s GPUs

Point Sample Rendering

Real-Time 2D to 2D+Depth Video Conversion. OzViz David McKinnon QUT

CS 130 Final. Fall 2015

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Pipeline Operations. CS 4620 Lecture 14

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

Adaptive Point Cloud Rendering

Shaders (some slides taken from David M. course)

CS4620/5620: Lecture 14 Pipeline

OpenGL. Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University

Pipeline Operations. CS 4620 Lecture 10

Deferred Splatting. Gaël GUENNEBAUD Loïc BARTHE Mathias PAULIN IRIT UPS CNRS TOULOUSE FRANCE.

CS 464 Review. Review of Computer Graphics for Final Exam

- Rasterization. Geometry. Scan Conversion. Rasterization

Normalized Device Coordinate System (NDC) World Coordinate System. Example Coordinate Systems. Device Coordinate System

Computer Graphics. Texture Filtering & Sampling Theory. Hendrik Lensch. Computer Graphics WS07/08 Texturing

World Coordinate System

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

3D Rasterization II COS 426

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

INF3320 Computer Graphics and Discrete Geometry

CS 130 Exam I. Fall 2015

Deferred Rendering Due: Wednesday November 15 at 10pm

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

1.2.3 The Graphics Hardware Pipeline

CHAPTER 1 Graphics Systems and Models 3

CSL 859: Advanced Computer Graphics. Dept of Computer Sc. & Engg. IIT Delhi

Spring 2009 Prof. Hyesoon Kim

Rasterization Overview

Framebuffer Objects. Emil Persson ATI Technologies, Inc.

Module 13C: Using The 3D Graphics APIs OpenGL ES

INF3320 Computer Graphics and Discrete Geometry

Hardware Accelerated Volume Visualization. Leonid I. Dimitrov & Milos Sramek GMI Austrian Academy of Sciences

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

CS451Real-time Rendering Pipeline

Computergraphics Exercise 15/ Shading & Texturing

Direct Rendering. Direct Rendering Goals

TSBK03 Screen-Space Ambient Occlusion

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

Definition. Blending & Compositing. Front & Back Buffers. Left & Right Buffers. Blending combines geometric objects. e.g.

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

Basics of GPU-Based Programming

E.Order of Operations

UberFlow: A GPU-Based Particle Engine

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

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

The Rasterizer Stage. Texturing, Lighting, Testing and Blending

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Advanced Rendering Techniques

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

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

Supplement to Lecture 22

CS 498 VR. Lecture 19-4/9/18. go.illinois.edu/vrlect19

INF3320 Computer Graphics and Discrete Geometry

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

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

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

Graphics Hardware and Display Devices

Volume Graphics Introduction

For each question, indicate whether the statement is true or false by circling T or F, respectively.

Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL

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

Shadows. COMP 575/770 Spring 2013

Applications of Explicit Early-Z Z Culling. Jason Mitchell ATI Research

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

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

Could you make the XNA functions yourself?

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

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

INF3320 Computer Graphics and Discrete Geometry

Cg 2.0. Mark Kilgard

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

Interactive Methods in Scientific Visualization

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

Spring 2012 Final. CS184 - Foundations of Computer Graphics. University of California at Berkeley

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

Computer Graphics. Lecture 02 Graphics Pipeline. Edirlei Soares de Lima.

Rendering Objects. Need to transform all geometry then

CS 179 GPU Programming

Efficient and Scalable Shading for Many Lights

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

The Application Stage. The Game Loop, Resource Management and Renderer Design

Computer Graphics (CS 543) Lecture 10: Normal Maps, Parametrization, Tone Mapping

Point based Rendering

OpenGL Performances and Flexibility. Visual Computing Laboratory ISTI CNR, Italy

Sampling, Aliasing, & Mipmaps

The Graphics Pipeline

Programmable Graphics Hardware

GUERRILLA DEVELOP CONFERENCE JULY 07 BRIGHTON

Lecture 2. Shaders, GLSL and GPGPU

Tutorial on GPU Programming #2. Joong-Youn Lee Supercomputing Center, KISTI

[175 points] The purpose of this assignment is to give you practice with shaders in OpenGL.

Advanced Rendering & Shading

Spring 2011 Prof. Hyesoon Kim

Rasterization. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 16

Introduction to the OpenGL Shading Language

Graphics Processing Unit Architecture (GPU Arch)

Transcription:

Point-Based rendering on GPU hardware Advanced Computer Graphics 2008

Outline Why use the GPU? Splat rasterization Image-aligned squares Perspective correct rasterization Splat shading Flat shading Gouroud shading Deferred shading Anti-aliasing 2

Why use the GPU? Much faster (billions of splats per second) High data-parallelism Hardware support for point primitives CPU can do something else in the meantime 3

Splat rasterization Determine which pixels are covered by the projected splat 4

Splat rasterization Surfel layout in memory struct Surfel { float pos[3]; float color[4]; float uvec[3]; float vvec[3]; }; POSITION TEXCOORD0 TEXCOORD1 TEXCOORD2 Pass point attributes to shader in texture coordinates Draw array at once using gldrawarrays() Calling glvertex and gltexcoord billions of times would saturate the CPU Point data can be stored in GPU memory 5

Vertex program Point size determined by vertex program glenable(gl_vertex_program_point_size); Conservative approximation of screen-space size of splat Project ellipse radius to near plane Then multiply by viewport height to get pixel size s s 6

Vertex program void main(float4 pvec : POSITION, float4 color : TEXCOORD0, float3 uvec : TEXCOORD1, float3 vvec : TEXCOORD2, uniform float4x4 ModelViewProj, uniform float2 wsize, uniform float near, uniform float top, uniform float bottom, { out float4 pout out float psize out float4 cout ) : POSITION, : PSIZE, : TEXCOORD0 pout = mul(modelviewproj, pvec); float radius = sqrt(max(dot(uvec, uvec), dot(vvec, vvec))); psize = 2.0 * radius * (-near / peye.z) * (wsize.y / (top bottom)); } cout = float4(color.xyz, 1.0); 7

Image-aligned squares Simplest technique Just render GL_POINTS glenable(gl_vertex_program_point_size); glclientactivetexture(gl_texture0); gltexcoordpointer(4, GL_FLOAT, sizeof(surfel), &pts[0].color); glenableclientstate (GL_TEXTURE_COORD_ARRAY);... glvertexpointer(3, GL_FLOAT, sizeof(surfel), &pts[0].pos); glenableclientstate(gl_vertex_array); gldrawarrays(gl_points, 0, numpoints); glclientactivetexture(gl_texture0); gldisableclientstate(gl_texture_coord_array);... gldisableclientstate(gl_vertex_array); 8

Image-aligned squares Simplest technique Just render GL_POINTS glenable(gl_vertex_program_point_size); glclientactivetexture(gl_texture0); gltexcoordpointer(4, GL_FLOAT, sizeof(surfel), &pts[0].color); glenableclientstate (GL_TEXTURE_COORD_ARRAY);... glvertexpointer(3, GL_FLOAT, sizeof(surfel), &pts[0].pos); glenableclientstate(gl_vertex_array); gldrawarrays(gl_points, 0, numpoints); glclientactivetexture(gl_texture0); gldisableclientstate(gl_texture_coord_array);... gldisableclientstate(gl_vertex_array); 9

Image-aligned squares Simplest technique Just render GL_POINTS glenable(gl_vertex_program_point_size); glclientactivetexture(gl_texture0); gltexcoordpointer(4, GL_FLOAT, sizeof(surfel), &pts[0].color); glenableclientstate (GL_TEXTURE_COORD_ARRAY);... glvertexpointer(3, GL_FLOAT, sizeof(surfel), &pts[0].pos); glenableclientstate(gl_vertex_array); gldrawarrays(gl_points, 0, numpoints); glclientactivetexture(gl_texture0); gldisableclientstate(gl_texture_coord_array);... gldisableclientstate(gl_vertex_array); 10

Image-aligned squares Results Depth artifacts, no blending, blocky contours 11

Perspectively correct rasterization Render object-space elliptical splats With perspectively accurate kernels In fragment shader, raycast against primitive Solve... 12

Raycasting Solve Using Cramer's rule: Only depends on the current pixel, the rest can be precalulated in the vertex shader Discard fragment if 13

Z-Buffer Depth in Z-Buffer must be correct Otherwise, intersecting splats will be rendered incorrectly By default, a GL_POINT has constant depth Interpolate depth value as well in fragment shader DEPTH binding semantic is in clip-space 14

Fragment shader void main( { } float4 col : TEXCOORD0, float3 v1 : TEXCOORD1, float3 v2 : TEXCOORD2, float3 v3 : TEXCOORD3, float depthin : TEXCOORD4, float2 wpos : WPOS, uniform float2 unproj_scale, uniform float2 unproj_offset, uniform float near, uniform float zb_scale, uniform float zb_offset, uniform float epsilon, out float depthout : DEPTH, out float4 colorout : COLOR0 ) float3 q = float3(wpos*unproj_scale - unproj_offset, -near); float dn = dot(q, v3); float u = dot(q, v1)/dn; float v = dot(q, v2)/dn; float radius = u*u + v*v; if(radius > 1.0) discard; float qz = q.z * depthin/dn + epsilon; depthout = zb_scale/qz + zb_offset; colorout = col; 15

Splat shading Flat shading Simplest, lighting is applied per splat, without interpolation 16

Gouraud shading Interpolate shaded color over primitives By rendering splats as a Gaussian kernel and accumulating the result for each pixel colored point primitive ci alpha mask w(x,y) (2D Gaussian) splat primitive ci.w(x,y) Fragment shader computes gaussian from u and v Splat color is returned in rgb like before Weight returned in alpha component 17

Gouraud shading Start with visibility splatting pass Makes sure that only splats within a surface band are blended Render splats, apply an offset to the computed z value Enable z-write, disable color write 18

Gouraud shading Before rendering, set up alpha blending glenable(gl_blend); glblendfuncseparate(gl_src_alpha, GL_ONE, GL_ONE, GL_ONE); Intermediate render target needed with floating point precision 8 bit per component would quickly suffer from clipping and quantization artifacts 19

Frame buffer objects Frame Buffer Objects expose off-screen rendering functionality glgenframebuffersext(1, &fbo); glbindframebufferext(gl_framebuffer_ext, fbo); glframebuffertexture2dext( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, color_tex, 0); glframebufferrenderbufferext( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer); assert(glcheckframebufferstatusext( GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT); 20

Normalization pass Render intermediate texture as full-screen quad Perform normalization of accumulated values, so that weights sum to 1 float4 main( float2 coord : TEXCOORD0, uniform samplerrect input ): COLOR { float4 d = texrect(input, coord); return float4(d.rgb / d.a, 1.0); } Results in a division by zero if no splats overlap a pixel glclearcolor(0, 0, 0, 1e-6) 21

Gouraud shading Gouraud shading is certainly an improvement As lighting is calculated per vertex, result can be blurry Quality of shading depends on point density Only ambient lighting Specular highlight 22

Deferred shading Phong shading First, do visibility splatting pass Splat normal and other surfel attributes, interpolate over surface (in similar way as with color in Gouraud) For this, we need to render to multiple render targets For example: color (float3), normal (float3), depth (float) Shader outputs multiple colors: COLOR0, COLOR1,... Use frame buffer with multiple color attachments Final pass does normalization, deferred shading 23

Deferred shading Multiple render targets glbindframebufferext(gl_framebuffer_ext, fbo); GLenum bufs[2] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT} gldrawbuffers(2, bufs);... (render) 24

Anti-aliasing Built-in FSAA of the GPU can be used Basically redirects rendering to higher-resolution frame-buffer, then down-samples Even this could suffer from aliasing, as it only moves the problem Approximate EWA filter Footprint is computed as maximum, instead of convolution, of projected reconstruction filter and screen-space prefilter A fragment is accepted if it lies in the union of the screen-space prefilter and projected splat New splatting kernel: 25

Anti-aliasing 26