MULTI-PASS VS SINGLE-PASS CUBEMAP

Similar documents
Tutorial on GPU Programming. Joong-Youn Lee Supercomputing Center, KISTI

Texture Mapping. Mike Bailey.

Lecture 07: Buffers and Textures

General Purpose computation on GPUs. Liangjun Zhang 2/23/2005

Lecture 19: OpenGL Texture Mapping. CITS3003 Graphics & Animation

OpenCL / OpenGL Texture Interoperability: An Image Blurring Case Study

Framebuffer Objects. Emil Persson ATI Technologies, Inc.

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

Textures. Texture Mapping. Bitmap Textures. Basic Texture Techniques

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

CS335 Graphics and Multimedia. Slides adopted from OpenGL Tutorial

Lighting and Texturing

Grafica Computazionale

Graphics. Texture Mapping 고려대학교컴퓨터그래픽스연구실.

CS 432 Interactive Computer Graphics

CS4621/5621 Fall Basics of OpenGL/GLSL Textures Basics

Assignment #5: Scalar Field Visualization 3D: Direct Volume Rendering

Basics of GPU-Based Programming

Computer Graphics. Bing-Yu Chen National Taiwan University

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

Texturing. Slides done bytomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

CS452/552; EE465/505. Texture Mapping in WebGL

Mali & OpenGL ES 3.0. Dave Shreiner Jon Kirkham ARM. Game Developers Conference 27 March 2013

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

CISC 3620 Lecture 7 Lighting and shading. Topics: Exam results Buffers Texture mapping intro Texture mapping basics WebGL texture mapping

CS212. OpenGL Texture Mapping and Related

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

Rendering Objects. Need to transform all geometry then

CIS 665 GPU Programming and Architecture

Objectives. Texture Mapping and NURBS Week 7. The Limits of Geometric Modeling. Modeling an Orange. Three Types of Mapping. Modeling an Orange (2)

Discussion 3. PPM loading Texture rendering in OpenGL

Motivation Hardware Overview Programming model. GPU computing. Part 1: General introduction. Ch. Hoelbling. Wuppertal University

arxiv:hep-lat/ v1 21 Nov 2006

GeForce3 OpenGL Performance. John Spitzer

Starting out with OpenGL ES 3.0. Jon Kirkham, Senior Software Engineer, ARM

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

三維繪圖程式設計 3D Graphics Programming Design 第七章基礎材質張貼技術嘉大資工系盧天麒

CT5510: Computer Graphics. Texture Mapping

OpenGL & Visualization

Exploiting the Shader Model 4.0 Architecture

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

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

GpuPy: Accelerating NumPy With a GPU

Texture Mapping CSCI 4229/5229 Computer Graphics Fall 2016

Getting fancy with texture mapping (Part 2) CS559 Spring Apr 2017

SUMMARY. CS380: Introduction to Computer Graphics Texture Mapping Chapter 15. Min H. Kim KAIST School of Computing 18/05/03.

Introduction to Computer Graphics with WebGL

CIS 665 GPU Programming and Architecture

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

Shadow Rendering. CS7GV3 Real-time Rendering

ก ก ก.

Texture Mapping and Sampling

CS193P - Lecture 19. iphone Application Development. OpenGL ES

COMP371 COMPUTER GRAPHICS

GPU Memory Model Overview

-=Catmull's Texturing=1974. Part I of Texturing

Do you wish you could hear the audio and read the transcription of this session?

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

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

Page 6 PROCESSOR PROCESSOR FRAGMENT FRAGMENT. texy[1] texx. texy[1] texx. texy[0] texy[0]

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

Computergraphics Exercise 15/ Shading & Texturing

Coding OpenGL ES 3.0 for Better Graphics Quality

CS179: GPU Programming

Lecture 22 Sections 8.8, 8.9, Wed, Oct 28, 2009

Graphics Processing Unit Architecture (GPU Arch)

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

Graphics Performance Optimisation. John Spitzer Director of European Developer Technology

Computer graphics 2: Graduate seminar in computational aesthetics

CSE 167: Introduction to Computer Graphics Lecture #8: Textures. Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2016

Rasterization Overview

CENG 477 Introduction to Computer Graphics. Graphics Hardware and OpenGL

The GPGPU Programming Model

Imaging and Raster Primitives

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

Texturing. Slides done by Tomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

X. GPU Programming. Jacobs University Visualization and Computer Graphics Lab : Advanced Graphics - Chapter X 1

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

Computational Strategies

Display Lists. Conceptually similar to a graphics file. In client-server environment, display list is placed on server

Best practices for effective OpenGL programming. Dan Omachi OpenGL Development Engineer

Texture Mapping. Texture Mapping. Map textures to surfaces. Trompe L Oeil ( Deceive the Eye ) The texture. Texture map

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

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

Steiner- Wallner- Podaras

The Graphics Pipeline

Graphics Processing Units (GPUs) V1.2 (January 2010) Outline. High-Level Pipeline. 1. GPU Pipeline:

Overview. By end of the week:

Computer Graphics and Visualization. Graphics Systems and Models

GPU Computation Strategies & Tricks. Ian Buck NVIDIA

Building Models. Objectives. Introduce simple data structures for building polygonal models. OpenGL vertex arrays. Vertex lists Edge lists

cs123 Lab 3 OpenGL Part One 1 Introduction 2 OpenGL Basics 2.2 The Rendering Pipeline 2.1 The CPU and the GPU 2.3 Basic Syntax of OpenGL commands

Texture Mapping. Computer Graphics, 2015 Lecture 9. Johan Nysjö Centre for Image analysis Uppsala University

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

Graphics Processing Units (GPUs) V2.2 (January 2013) Jan Kautz, Anthony Steed, Tim Weyrich

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

Efficient and Scalable Shading for Many Lights

Texture Mapping and Special Effects

GPGPU IGAD 2014/2015. Lecture 4. Jacco Bikker

OpenGL Texture Mapping. Objectives Introduce the OpenGL texture functions and options

Transcription:

Sogang University Computer Graphics Lab. MULTI-PASS VS SINGLE-PASS CUBEMAP 2008.4 1

Contents Purpose Multi-Pass Cubemap Single-Pass Cubemap Reflection Mapping Test Result Conclusion 2

Purpose Implement real-time cubemap creation and reflection mapping. Implement multi-pass cubemap using OpenGL fixed pipeline. Implement single-pass cubemap using geometry program. Use framebuffer object and renderbuffer of Nvidia Extension. Use assembly language on Nvidia G8x specification. Compare single-pass cubemap with multi-pass cubemap performance. 3

Multi-Pass Cubemap ( 1/3 ) Rendering function is called six times for making each face of cubemap. Since each face of cubemap is created sequentially, only one depth buffer is required. Use OpenGL fixed pipeline. 1 triangle Fixed Pineline model-view projection for +x +x 2 triangle Fixed Pineline model-view projection for -x -x 3 triangle Fixed Pineline model-view projection for +y +y 4 triangle Fixed Pineline model-view projection for -y -y 5 triangle Fixed Pineline model-view projection for +z +z 6 triangle Fixed Pineline model-view projection for -z -z 4

Multi-Pass Cubemap ( 2/3 ) OpenGL Code ( framebuffer object, cubemap texture initializing ) GLuint six_fb, six_pass_cube_tex; GLuint depth_rb; // framebuffer object, cubemap texture, depth buffer generate glgenframebuffersext( 1, &six_fb ); glgentextures( 1, & six_pass_cube_tex); glgenrenderbuffersext( 1, &depth_rb ); glbindtexture( GL_TEXTURE_CUBE_MAP_ARB, six_pass_cube_tex); gltexparameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); gltexparameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); gltexparameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); gltexparameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); gltexparameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE ); // create texture for each face of cubemap. for ( int i = 0; i < 6; ++i ) { glbindtexture( GL_TEXTURE_CUBE_MAP_ARB, six_pass_cube_tex); glteximage2d( GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + i, 0, GL_RGB, fbwidth, fbheight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL ); } // render buffer creation for depth buffer glbindrenderbufferext( GL_RENDERBUFFER_EXT, depth_rb ); glrenderbufferstorageext( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT32, fbwidth, fbheight ); 5

Multi-Pass Cubemap ( 3/3 ) OpenGL Code ( cubemap creation ) // bind frame buffer object glbindframebufferext( GL_FRAMEBUFFER_EXT, six_fb ); // make each face of cubemap for ( int face = 0; face < 6; ++face ) { } glmatrixmode( GL_PROJECTION ); glloadidentity(); // set model-view projection matrix. glmatrixmode( GL_MODELVIEW ); glloadmatrixf( m_cubemapprojectionmatrix[face].matrix ); glframebuffertexture2dext( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + face, six_pass_cube_tex, 0 ); glframebufferrenderbufferext( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb ); gldrawbuffer( GL_COLOR_ATTACHMENT0_EXT );. Draw objects.. glflush(); 6

Single-Pass Cubemap ( 1/5 ) Draw six faces of cubemap at once. Use geometry program. Need six depth buffer. ( EXT_texture_array is used ) triangles Vertex Program only modeling transform Geometry Program veiwing projection for layer0 veiwing projection for layer1 veiwing projection for layer2 veiwing projection for layer3 veiwing projection for layer4 veiwing projection for layer5 +x layer0 -x layer1 +y layer2 -y layer3 +z layer4 -z layer5 7

Single-Pass Cubemap ( 2/5 ) OpenGL Code ( cubemap creation ) glbindtexture( GL_TEXTURE_2D_ARRAY_EXT, depth_buffer_array ); gltexenvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); gltexparameteri( GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); gltexparameteri( GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glteximage3d( GL_TEXTURE_2D_ARRAY_EXT, 0, GL_DEPTH_COMPONENT24, 256, 256, 6, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL ); glbindframebufferext( GL_FRAMEBUFFER_EXT, single_fb ); glframebuffertextureext( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, one_pass_cube_tex_array, 0 ); // depth buffer setting. glframebuffertextureext( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, depth_buffer_array, 0 ); gldrawbuffer( GL_COLOR_ATTACHMENT0_EXT ); glenable( GL_GEOMETRY_PROGRAM_NV ); glenable( GL_VERTEX_PROGRAM_NV ); glbindprogramnv( GL_GEOMETRY_PROGRAM_NV, m_onepassgeometryprogramid ); glbindprogramnv( GL_VERTEX_PROGRAM_NV, m_onepassvertexprogramid ); int index = 0; // set projection matrix for each face of cubemap. for ( int i = 0; i < 6; ++i ) { glprogramlocalparameter4farb( GL_GEOMETRY_PROGRAM_NV, index++, m_cubemapprojectionmatrix[i][0], m_cubemapprojectionmatrix[i][4], m_cubemapprojectionmatrix[i][8], m_cubemapprojectionmatrix[i][12] ); glprogramlocalparameter4farb( GL_GEOMETRY_PROGRAM_NV, index++, m_cubemapprojectionmatrix[i][1], m_cubemapprojectionmatrix[i][5], m_cubemapprojectionmatrix[i][9], m_cubemapprojectionmatrix[i][13] ); glprogramlocalparameter4farb( GL_GEOMETRY_PROGRAM_NV, index++, m_cubemapprojectionmatrix[i][2], m_cubemapprojectionmatrix[i][6], m_cubemapprojectionmatrix[i][10], m_cubemapprojectionmatrix[i][14] ); glprogramlocalparameter4farb( GL_GEOMETRY_PROGRAM_NV, index++, m_cubemapprojectionmatrix[i][3], m_cubemapprojectionmatrix[i][7], m_cubemapprojectionmatrix[i][11], m_cubemapprojectionmatrix[i][15] ); } Draw Object 8

Single-Pass Cubemap ( 3/5 ) Vertex Program - Vertex is passed to geometry program after modeling transform is applied.!!nvvp4.0 # Input Binding # must be setted only model transform matrix without view transform matrix PARAM modelmatrix[] = { state.matrix.modelview.row[0..3] }; # Code DP4.F result.position.x, modelmatrix[0], vertex.position; DP4.F result.position.y, modelmatrix[1], vertex.position; DP4.F result.position.z, modelmatrix[2], vertex.position; DP4.F result.position.w, modelmatrix[3], vertex.position; MOV.F result.texcoord, vertex.texcoord; MOV.F result.color, vertex.color; END 9

Single-Pass Cubemap ( 4/5 ) Geometry Program ( 1/2 ) - Triangle is projected to each face of cubemap. ( 1 Triangle Input 6 Triangle Output ) - Use 0~5 layer for each face of cubemap.!!nvgp4.0 #---------------------------------------------------------------------------# # Option #---------------------------------------------------------------------------# PRIMITIVE_IN TRIANGLES; PRIMITIVE_OUT TRIANGLE_STRIP; VERTICES_OUT 18; #---------------------------------------------------------------------------# # Program Parameter. #---------------------------------------------------------------------------# # view projection matrix for each cube face PARAM vpmatrix[] = { program.local[0..23] }; #---------------------------------------------------------------------------# # Temp #---------------------------------------------------------------------------# INT TEMP ncount; INT TEMP index; INT TEMP nlayer; 10

Single-Pass Cubemap ( 5/5 ) Geometry Program ( 2/2 ) #---------------------------------------------------------------------------# # Code #---------------------------------------------------------------------------# MOV.S nlayer, 0; MOV.S index.x, 0; # six times loop for each cube face REP.S {6}; # projection matrix index for each layer MUL.S index.x, nlayer.x, {4}; # vertex1 projection. DP4.F result.position.x, vpmatrix[index.x + 0], vertex[0].position; DP4.F result.position.y, vpmatrix[index.x + 1], vertex[0].position; DP4.F result.position.z, vpmatrix[index.x + 2], vertex[0].position; DP4.F result.position.w, vpmatrix[index.x + 3], vertex[0].position; MOV.F result.texcoord[0], vertex[0].texcoord[0]; MOV.F result.color, vertex[0].color; MOV.S result.layer.x, nlayer.x; EMIT; # vertex1 projection. DP4.F result.position.x, vpmatrix[index.x + 0], vertex[1].position; DP4.F result.position.y, vpmatrix[index.x + 1], vertex[1].position; DP4.F result.position.z, vpmatrix[index.x + 2], vertex[1].position; DP4.F result.position.w, vpmatrix[index.x + 3], vertex[1].position; MOV.F result.texcoord[0], vertex[1].texcoord[0]; MOV.F result.color, vertex[1].color; MOV.S result.layer.x, nlayer.x; EMIT; DP4.F result.position.x, vpmatrix[index.x + 0], vertex[2].position; DP4.F result.position.y, vpmatrix[index.x + 1], vertex[2].position; DP4.F result.position.z, vpmatrix[index.x + 2], vertex[2].position; DP4.F result.position.w, vpmatrix[index.x + 3], vertex[2].position; MOV.F result.texcoord[0], vertex[2].texcoord[0]; MOV.F result.color, vertex[2].color; MOV.S result.layer.x, nlayer.x; EMIT; ENDPRIM; ADD.S nlayer.x, nlayer.x, {1}; ENDREP; END 11

Reflection Mapping ( 1/3 ) Reflection mapping flow 1. Cubemap creation Multi-pass Multi-Pass Pixed Pipeline ( 6 times ) Single-pass Vertex Program modeling transform Geometry Program view projection transform for each layer cube map Environment 2. Reflection mapping Vertex Program mvp transform send normal & vertex position on eye coordinate Fragment Program object 12

Reflection Mapping ( 2/3 ) Vertex Program - Vertex and normal are passed to fragment program after model-view transform is applied.!!nvvp4.0 # Program Parameter PARAM mvpmatrix[] = { state.matrix.mvp }; PARAM mvmatrix[] = { state.matrix.modelview.row[0..3] }; PARAM mvinvtransmatrix[] = { state.matrix.modelview.invtrans }; # Output Bindings # for vertex normal info ( eye coordinate ) OUTPUT vertexnormaltexure = result.texcoord[6]; # for vertex position info ( eye coodinate ) OUTPUT vertexpositiontexure = result.texcoord[7]; # Code # vertex normal on eye coordinate DP3 vertexnormaltexure.x, mvinvtransmatrix[0], vertex.normal; DP3 vertexnormaltexure.y, mvinvtransmatrix[1], vertex.normal; DP3 vertexnormaltexure.z, mvinvtransmatrix[2], vertex.normal; # vertex position on eye coordinate DP4 vertexpositiontexure.x, mvmatrix[0], vertex.position; DP4 vertexpositiontexure.y, mvmatrix[1], vertex.position; DP4 vertexpositiontexure.z, mvmatrix[2], vertex.position; DP4 vertexpositiontexure.w, mvmatrix[3], vertex.position; # to CC DP4 result.position.x, mvpmatrix[0], vertex.position; DP4 result.position.y, mvpmatrix[1], vertex.position; DP4 result.position.z, mvpmatrix[2], vertex.position; DP4 result.position.w, mvpmatrix[3], vertex.position; MOV result.color, vertex.color; END 13

Reflection Mapping ( 3/3 ) Fragment Program - calculate reflection vector on eye coordinates and use cubemap.!!nvfp4.0 #--------------------------------------------------------------------------------------# # Input Binding #--------------------------------------------------------------------------------------# ATTRIB incolor = fragment.color.primary; # Object color ATTRIB vertexnormal = fragment.texcoord[6]; # Vertex Normal ( eye Coordinates ) ATTRIB vertexposition = fragment.texcoord[7]; # Vertex Position ( eye Coordinates ) #--------------------------------------------------------------------------------------# # Temporary Register #--------------------------------------------------------------------------------------# TEMP nvertexnormal, nvertexposition, texelcolor; TEMP reflectionvec; # CubeMap Color # reflection vector of view vector by vertex normal #--------------------------------------------------------------------------------------# # Code #--------------------------------------------------------------------------------------# NRM nvertexnormal, vertexnormal; NRM nvertexposition, vertexposition; RFL reflectionvec, nvertexnormal, -nvertexposition; TEX texelcolor, reflectionvec, texture, CUBE; # normal # view vector # reflection vector of view vector by vertex normal # get tex color from cube map MOV result.color, texelcolor; END 14

Test Result ( 1/4 ) Result snapshot 15

Test Result ( 2/4 ) Test Environment - When each frame is rendered, cubemap is also re-created. - Since CPU and GPU are running in parallel, CPU time check routine is not correct. - For time checking, Use GPU Time check routine. ( glbeginquery, glendquery ) - Nvidia Geforce 8800 GTX. GLuint query[2]; GLint available = 0; GLuint64EXT timeelapsed = 0; glgenqueries( 1, query ); glbeginquery( GL_TIME_ELAPSED_EXT, query[0] );. Draw Scene.. glendquery( GL_TIME_ELAPSED_EXT ); while (!available) { glgetqueryobjectiv( query[0], GL_QUERY_RESULT_AVAILABLE, &available ); } glgetqueryobjectui64vext( query[0], GL_QUERY_RESULT, &timeelapsed ); 16

Test Result ( 3/4 ) When glvertex function series is used. -CPU GPU data transmission is slow. - Data transmission is bottleneck of whole processing. - This case, single-pass cubemap is more fast. ( single-pass : 1 data transmission + geometry program overhead < multi-pass : 6 data transmission ) When gldrawelements function series is used. -CPU GPU data transmission is fast. - Geometry program is more overhead than data transmission. - This case, multi-pass cubemap is more fast. glvertex gldrawelements Single Pass 30fps 30fps Multi Pass 10fps 50fps Sponza Data ( 60K Vertex ) on WindowXP, Nvidia G880 GTX 17

Test Result ( 4/4 ) Unexpectedly, performance of multi-pass was degraded in window vista. - we guess that there is some bottleneck using gldrawelements in vista. Window XP glvertex gldrawelements Single Pass 30fps 30fps Multi Pass 10fps 50fps Window Vista glvertex gldrawelements Single Pass 30fps 30fps Multi Pass 10fps 29fps Sponza Data ( 60K Vertex ) 18

Conclusion It is known that performance of geometry program is degraded as more vertices are output. [reference] - http://www.gamedev.net/community/forums/topic.asp?topic_id=491090 - http://www.gpgpu.org/forums/viewtopic.php?t=4851&sid=f395110947edbe71c4512b1f68eea063 - http://www.devmaster.net/forums/showthread.php?t=12007 - http://developer.download.nvidia.com/whitepapers/2007/sdk10/cloth.pdf ( 5 page ) Our result is also equal to above facts. In current geometry program, single-pass cubemap is slower than multipass cubemap in general ( gldrawelements function series is used in general ) 19