OpenGL ARB Vertex Program

0
0
1566 days ago, 552 views
PowerPoint PPT Presentation

Presentation Transcript

Slide 1

OpenGL ARB Vertex Program Cass Everitt cass@nvidia.com

Slide 2

Overview ARB Vertex Programming Overview Loading Vertex Programs Register Set Variables and Variable "Official" Assembly Instruction Set Example Programs Wrap-Up

Slide 3

ARB Vertex Programming Overview Traditional Graphics Pipeline change, lighting setup rasterizer surface bring, piece shading Each unit has particular capacity (as a rule with configurable "modes" of operation) casing cradle operations

Slide 4

ARB Vertex Programming Overview Vertex Programming offers programmable T&L unit User-characterized Vertex Processing change, lighting setup rasterizer surface get, section shading Gives the developer add up to control of vertex preparing. outline cushion operations

Slide 5

What is Vertex Programming? Finish control of change and lighting HW Complex vertex operations quickened in HW Custom vertex lighting Custom cleaning and mixing Custom surface facilitate era Custom surface network operations Custom vertex calculations of your decision Offloading vertex calculations authorizes CPU

Slide 6

What is Vertex Programming? Vertex Program Assembly dialect interface to T&L unit GPU direction set to play out all vertex math Input: self-assertive vertex characteristics Output: a changed vertex qualities homogeneous clasp space position (required) hues (front/back, essential/optional) mist coord surface directions point measure

Slide 7

What is Vertex Programming? Vertex Program Does not produce or pulverize vertexes 1 vertex in and 1 vertex out No topological data gave No edge, confront, nor neighboring vertex information Dynamically loadable Exposed through NV_vertex_program and EXT_vertex_shader expansions and now ARB_vertex_program

Slide 8

What is ARB_vertex_program? ARB_vertex_program is like NV_vertex_program with the expansion of: factors nearby parameters access to GL express some additional guidelines usage particular asset limits

Slide 9

What is Vertex Programming? change, lighting Vertex Program setup rasterizer glEnable( GL_VERTEX_PROGRAM_ARB ); surface get, piece shading Switch from routine T&L model to Programmable mode outline support operations

Slide 10

Specifically, what gets circumvent? Modelview and projection vertex changes Vertex weighting/mixing Normal change, rescaling, standardization Color material Per-vertex lighting Texture organize era and surface lattice changes Per-vertex point size and haze facilitate calculations User-cut planes

Slide 11

What does NOT get avoided? Evaluators Clipping to the view frustum Perspective gap Viewport change Depth go change Front and back shading determination (for two-sided) Clamping of essential and auxiliary hues to [0,1] Primitive get together, setup, rasterization, mixing

Slide 12

Program Environment Parameters Program Local Parameters Lx4 registers (L  96) Vertex Programming Conceptual Overview Vertex Attributes Nx4 registers (N  16) Ex4 registers (E  96) Vertex Program Address Variables Temporary Variables M directions (M  128) Ax4 factors (A  1) Tx4 factors (T  12) Vertex Result Registers Rx4 registers (R  8)

Slide 13

Creating a Vertex Program Programs are varieties of GLubytes ("strings") Created/oversaw like surface items idea of a program protest glGenProgramsARB( sizei n, uint *ids ) glBindProgramARB( enum target, uint id ) glProgramStringARB( enum target, enum format, sizei len, const ubyte *program )

Slide 14

Creating a Vertex Program Gluint progid;/Generate a program question handle. glGenProgramsARB( 1, &progid );/Make the "present" program question progid. glBindProgramARB( GL_VERTEX_PROGRAM_ARB, progid );/Specify the program for the present protest. glProgramStringARB( GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(myString), myString );/Check for blunders and notices...

Slide 15

Creating a Vertex Program/Check for blunders and notices... on the off chance that ( GL_INVALID_OPERATION == glGetError() ) {/Find the blunder position GLint errPos; glGetIntergv( GL_PROGRAM_ERROR_POSITION_ARB, &errPos );/Print usage subordinate program/mistakes and notices string. Glubyte *errString; glGetString( GL_PROGRAM_ERROR_STRING_ARB, &errString ); fprintf( stderr, "mistake at position: %d\n%s\n", errPos, errString ); }

Slide 16

Creating a Vertex Program When completed with a program question, erase it/Delete the program protest. glDeleteProgramsARB( 1, &progid );

Slide 17

Specifying Program Parameters Three sorts Vertex Attributes – specifiable per-vertex Program Local Parameters Program Environment Parameters Program Parameters modifiable outside of a Begin/End square

Slide 18

Specifying Vertex Attributes Up to Nx4 per-vertex "non specific" qualities Values determined with (a few) new summons glVertexAttrib4fARB( file, x, y, z, w ) glVertexAttribs4fvARB( record, values ) Some section focuses permit segment shrewd straight re-mapping to [0,1] or [-1,1] glVertexAttrib4 N ubARB( file, x, y, z, w ) glVertexAttrib4 N bvARB( file, values ) like glColor4ub() and glColor4b()

Slide 19

Specifying Vertex Attributes Component-wise direct re-mapping Suffix Data Type Min Value Min Value Maps to b 1-byte integer - 128 - 1.0 s 2-byte integer - 32,768 - 1.0 i 4-byte integer - 2,147,483,648 - 1.0 ub unsigned 1-byte whole number 0 0.0 us unsigned 2-byte whole number 0 0.0 ui unsigned 4-byte number 0 0.0 Suffix Data Type Max Value Max Value Maps to b 1-byte integer 127 1.0 s 2-byte integer 32,767 1.0 i 4-byte integer 2,147,483,647 1.0 ub unsigned 1-byte whole number 255 1.0 us unsigned 2-byte number 65,535 1.0 ui unsigned 4-byte whole number 4,294,967,295 1.0

Slide 20

Specifying Vertex Attributes Vertex Array bolster glVertexAttribPointerARB( uint index, int measure, enum sort, boolean normalize, sizei stride, const void *pointer ) "standardize" hail demonstrates if qualities ought to be straightly remapped

Slide 21

Specifying Vertex Attributes Setting vertex trait 0 incites vertex program execution Setting some other vertex characteristic upgrades the present estimations of the property enlist Conventional properties might be indicated with routine per-vertex calls glColor, glNormal, glWeightARB, and so on. Not strict associating (like NV_vertex_program) More on this later…

Slide 22

Specifying Program Local Parameters Each program protest has a variety of (N  96) four-segment skimming point vectors Store program-particular parameters required by the program Values indicated with new charges glProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, record, x, y, z, w ) glProgramLocalParameter4fvARB( GL_VERTEX_PROGRAM_ARB, list, params ) Correspond to 96+ nearby parameter registers

Slide 23

Specifying Program Environment Parameters Shared exhibit of (N  96) four-segment registers available by any vertex program Store parameters basic to an arrangement of program articles (i.e. Modelview network, MVP lattice) Values determined with new orders glProgramEnvParameter4fARB( GL_VERTEX_PROGRAM_ARB, file, x, y, z, w ) glProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, record, params ) Correspond to 96+ environment registers

Slide 24

Program Environment Parameters The Register Set Vertex Attributes Program Local Parameters vertex.* program.env[0] … program.env[N-1] program.local[0] … program.local[N-1] Vertex Program Address Variables Temporary Variables User characterized User characterized Vertex Result Registers result.*

Slide 25

Program Environment and Program Local Registers Program environment registers access utilizing: program.env[i] i in [0,GL_MAX_PROGRAM_ENV_PARAMETERS_ARB-1] Program nearby registers access utilizing: program.local[i] i in [0,GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB-1]

Slide 26

vertex.position (x,y,z,w) object position vertex.weight (w,w,w,w) vertex weights 0-3 vertex.weight[n] (w,w,w,w) vertex weights n-n+3 vertex.normal (x,y,z,1) normal vertex.color (r,g,b,a) primary color vertex.color.primary (r,g,b,a) primary color vertex.color.secondary (r,g,b,a) secondary color vertex.fogcoord (f,0,0,1) fog organize vertex.texcoord (s,t,r,q) texture arrange, unit 0 vertex.texcoord[n] (s,t,r,q) texture facilitate, unit n vertex.matrixindex (i,i,i,i) vertex grid files 0-3 vertex.matrixindex[n] (i,i,i,i) vertex framework files n-n+3 vertex.attrib[n] (x,y,z,w) generic vertex property n Vertex Attribute Registers Attribute Register Components Underlying State Semantics characterized by program, NOT parameter name

Slide 27

result.position (x,y,z,w) position in clasp facilitates result.color (r,g,b,a) front-confronting, essential shading result.color.primary (r,g,b,a) front-confronting, essential shading result.color.secondary (r,g,b,a) front-confronting, optional shading result.color.front (r,g,b,a) front-confronting, essential shading result.color.front.primary (r,g,b,a) front-confronting, essential shading result.color.front.secondary (r,g,b,a) front-confronting, auxiliary shading result.color.back (r,g,b,a) back-confronting, essential shading result.color.back.primary (r,g,b,a) back-confronting, essential shading result.color.back.secondary (r,g,b,a) back-f

SPONSORS