Vertex & Pixel Shaders

11
Vertex & Pixel Shaders CPS124 – Computer Graphics Ferdinand Schober

description

Vertex & Pixel Shaders. CPS124 – Computer Graphics. Ferdinand Schober. Shader History I. 1995/1996: 3dfx Voodoo 1 first mass market GPU, hw accelerated rasterization GLIDE API, 16bit buffers, texturing & shading Quake using OpenGL! - PowerPoint PPT Presentation

Transcript of Vertex & Pixel Shaders

Page 1: Vertex & Pixel Shaders

Vertex & Pixel ShadersCPS124 – Computer Graphics

Ferdinand Schober

Page 2: Vertex & Pixel Shaders

Shader History I• 1995/1996: 3dfx Voodoo 1

first mass market GPU, hw accelerated rasterizationGLIDE API, 16bit buffers, texturing & shadingQuake using OpenGL!

• 1998: 3dfx Voodoo 2 / BansheeAGP port, but no AGP texturingtwo texture units for single-pass multitexturing

• 1999: Nvidia Geforce 256 / Matrox G400fixed function graphics pipeline (T&L)first hardware OpenGL supportDDR memory introductionbump mapping

Page 3: Vertex & Pixel Shaders

Shader History II• 2000: 3dfx Voodoo 3 / Nvidia Geforce 2

multi-texturing unit, “Year of Nvidia”,per pixel shading, hardware transform +clipping + shading, full screen antialiasing

• 2001: Nvidia Geforce 3programmable T&L

• 2002: Nvidia Geforce 4Ti / DirectX 9.0first full hardware/software shader support

• 2003: Nvidia Geforce FX / ATI Radeon 9800XT256-bit memory port, displacement mapping,128-bit color precision, Ultra Shadow,AGP 8x

Page 4: Vertex & Pixel Shaders

Current Graphic Cards• Geforce FX 5950 Ultra

– Graphics Core/Interface: 256-bit – Fill Rate: 3.8 billion texels/sec. – Vertices/sec.: 356 million – Textures per Pixel: 16– Pixel Shaders (2.0)/Vertex Shaders– Supports OpenGL 1.5 / DX9.0– UltraShadow, CineFX 2.0

Geforce FX Demo

Page 5: Vertex & Pixel Shaders

Current Graphic Cards II• ATI Radeon 9800XT

– Graphics Core/Interface: 256-bit – Fill Rate: 3.3 gpixels/sec. – Vertices/sec.: 412 million – 2x/4x/6x full screen antialiasing– Pixel Shaders (2.0)/Vertex Shaders– Supports OpenGL 1.5 / DX9.0– SmartShader, Truform 2.0– Videoshader

ATI Radeon 9800XT Demo

Page 6: Vertex & Pixel Shaders

Pixel vs. Vertex Shaders• Definition (wikipedia):

“3D hardware previously used fixed-function pipelines in which, for example, one was stuck with the lighting model chosen by the hardware vendor. Graphics hardware was able to do transformation and lighting (T&L for short) on the card, but it was not flexible. A vertex shader sidesteps the T&L stage in the pipeline and lets the user add on to it.

Pixel shaders operate after the geometry pipeline and before final rasterization. They operate in parallel with multitexturing to produce a final pixel color and z-value for the final, rasterization step in the graphics pipeline (where alpha blending and depth testing occur).”

Page 7: Vertex & Pixel Shaders

Shader Languages• Different Standards:

Nvidia: Cg ATI: HSLS (DirectX 9)OpenGL: GL2 Provide high level language for assembler-based shading code. Use optimized (JIT) compilers to transform to highly efficient machine code.

Winner yet undecided.

Example Shaders

Page 8: Vertex & Pixel Shaders

Small Example (Cg)• Why Cg?

– Open source compiler– Works with OpenGL & DirectX– C-like language– can be used for multiple GPUs/Platforms

Page 9: Vertex & Pixel Shaders

Small Example (Cg) II

void simpleTransform(float4 objectPosition : POSITION, float4 color : COLOR,float4 decalCoord : TEXCOORD0, float4 lightMapCoord : TEXCOORD1,out float4 clipPosition : POSITION, out float4 oColor : COLOR,out float4 oDecalCoord : TEXCOORD0, out float4 oLightMapCoord : TEXCOORD1,uniform float brightness, uniform float4x4 modelViewProjection)

{clipPosition = mul(modelViewProjection, objectPosition);oColor = brightness * color;oDecalCoord = decalCoord;oLightMapCoord = lightMapCoord;

}

The program transforms an object-space position for a vertex by a 4x4 matrix containing the concatenation of the modeling, viewing, and projection transforms. The resulting vector is output as the clip-space position of the vertex. The per-vertex color is scaled by a floating-point parameter prior to output. Also, two texture coordinate sets are passed through unperturbed.

vs.1.1mov oT0, v7mov oT1, v8dp4 oPos.x, c1, v0dp4 oPos.y, c2, v0dp4 oPos.z, c3, v0dp4 oPos.w, c4, v0mul oD0, c0.x, v5

Page 10: Vertex & Pixel Shaders

Eye Candy• And now some shader eye candy:

•Radeon vertex shading/bump mapping demo•HSLS demo•Dynamic Fur

•Radeon 9700 demos

More in cutting-edge games lecture…

Page 11: Vertex & Pixel Shaders

Vertex & Pixel Shaders

しゅう えん

終演The End