Download presentation

Presentation is loading. Please wait.

Published byKatherine McDermott Modified over 4 years ago

1
**Fragment level programmability in OpenGL Evan Hart ehart@ati.com**

ARB Fragment Program Fragment level programmability in OpenGL Evan Hart

2
Plan of Action What is it How does it work What is it good for

3
**Introduction to ARB FP New standardized programming model**

What it replaces What it does not replace

4
**Standardized Fragment Programmability**

ARB standard for fragment-level programmability Derived from ARB_vertex_program Point out standardization and and level of HW supported

5
**Replaces Multitexture Pipe**

Texture blending Color Sum Fog Subsumes texture enables texture target priorities Discuss standard GL texture ops

6
**Fragment Processing Pipe**

setup rasterizer User-defined Fragment Processing Texture Fetch and Application Color Sum Fog frame-buffer ops

7
**Preserves Backend Operations**

Coverage application Alpha Test Stencil and depth test Blending

8
**Programming Model ASM based similar to ARB_vertex_program**

Rich SIMD instruction set Requires resource management Texture accesses Interpolators Temporaries Constants

9
**Similar to ARB_vertex_program**

Assembly syntax Same basic grammar rules Ops are upper case Statements terminated by semicolons Comments begin with #

10
**Fragment Program Machine**

Program Environment Parameters Program Local Parameters Attributes Fragment Program Address Variables Temporary Variables Result Registers

11
**Large Instruction Set Three basic categories Component swizzling**

Scalar (single value) operations Vector operations Texture operations Component swizzling Component masking

12
**Scalar Instructions COS – cosine EX2 – base 2 exponential**

LG2 – base 2 logarithm RCP – reciprocal RSQ – reciprocal square root SIN – sine SCS – sine and cosine POW – power

13
**New Scalar Instructions**

COS – cosine SIN – sine SCS – sine and cosine

14
**Removed Scalar Instructions**

EXP – Partial Precision EX2 LOG – Partial Precision LG2

15
Vector Instructions Standard Arithmetic Special purpose vector

16
**Standard Arithmetic Ops**

ABS – absolute value FLR – floor FRC – fraction component SUB – subtract XPD – cross product CMP – compare LRP – linearly interpolate MAD – multiply accumulate MOV – move ADD – add DP3 – three component dot product DP4 – four component dot product

17
**Special Vector Ops LIT – compute lighting**

DPH – homogeneous dot product DST – compute distance vector

18
New Instructions LRP – Linearly Interpolate CMP - Compare

19
Texture Instructions TEX TXP TXB KIL

20
**Standard Texture Fetch**

TEX <dest>, <src>, texture[n], <type>; Does not divide by q

21
**Extended Texture Fetches**

TXP Same syntax as TEX Divides first three components by the fourth TXB Adds the fourth component to the computed LOD

22
**Killing pixels KIL instruction**

Terminates shader program if any component is less than 0

23
**Resource Categories in ARB FP**

Temporaries Textures Attributes Parameters Instructions Texture Instructions Arithmetic Instructions

24
**Identifying Limits Standard Resource limits Texture Indirections**

Number of temps etc Texture Indirections

25
**Using Fragment Program**

API Simple shaders Complex shaders

26
Simple API Loading programs Setting Parameters Making active

27
**Shared API glGenProgramsARB( num, id );**

glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, id ); glProgramStringARB( GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, length, string );

28
Simple shaders Pre-programmable functionality Texture * color

29
**Simple Shader Example !!ARBfp1.0 TEMP temp; #temporary**

ATTRIB tex0 = fragment.texcoord[0]; ATTRIB col0 = fragment.color; PARAM pink = { 1.0, 0.4, 0.4, 1.0}; OUTPUT out = result.color; TEX temp, tex0, texture[0], 2D; #Fetch texture MOV out, temp; #replace #MUL out, col0, temp; #modulate #MUL out, temp, pink; #modulate with constant color

30
Complex Shaders Lighting Procedural

31
**Phong Lighting #compute half angle vector ADD spec.rgb, view, lVec;**

DP3 spec.a, spec, spec; RSQ spec.a, spec.a; MUL spec.rgb, spec, spec.a; #compute specular intensisty DP3_SAT spec.a, spec, tmp; LG2 spec.a, spec.a; MUL spec.a, spec.a, const.w; EX2 spec.a, spec.a; #compute diffuse illum DP3_SAT dif, tmp, lVec; ADD_SAT dif.rgb, dif, const;

32
**Procedural Bricks #Apply the stagger MUL r2.w, r0.y, half;**

FRC r2.w, r2.w; SGE r2.w, half, r2.w; MAD r0.x, r2.w, half, r0.x; #determine whether it is brick or mortar FRC r0.xy, r0; SGE r2.xy, freq, r0; SUB r3.xy, 1.0, freq; SGE r0.xy, r3, r0; SUB r0.xy, r2, r0; MUL r0.w, r0.x, r0.y;

33
**Caveats Remember the difference between**

{3.0} 3.0 Ensure Continuity at Boundaries Needed to compute LOD Programs under limits may not load

34
**Wrap up Fragment Program is the Standard for Fragment Programmability**

Assembly Language Shaders Enhances Pixel Level Effects

35
Questions?

Similar presentations

OK

Shading Languages & HW Giovanni Civati Dept. of Information Tecnology University of Milan, Italy Milan, 26 th May 2004.

Shading Languages & HW Giovanni Civati Dept. of Information Tecnology University of Milan, Italy Milan, 26 th May 2004.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To ensure the functioning of the site, we use **cookies**. We share information about your activities on the site with our partners and Google partners: social networks and companies engaged in advertising and web analytics. For more information, see the Privacy Policy and Google Privacy & Terms.
Your consent to our cookies if you continue to use this website.

Ads by Google

Ppt on blood stain pattern analysis expiration pattern Store design and display ppt online Ppt on communication in india Ppt on no plastic bags Ppt on chapter 3 atoms and molecules youtube Ppt on operating system deadlock Ppt on marie curie facts Ppt on rf remote control robot Ppt on nature and human ads Ppt on abo blood grouping