Vertex & Pixel Shaders

Download Report

Transcript Vertex & Pixel Shaders

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!
• 1998: 3dfx Voodoo 2 / Banshee
AGP port, but no AGP texturing
two texture units for single-pass
multitexturing
• 1999: Nvidia Geforce 256 / Matrox G400
fixed function graphics pipeline (T&L)
first hardware OpenGL support
DDR memory introduction
bump mapping
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 3
programmable T&L
• 2002: Nvidia Geforce 4Ti / DirectX 9.0
first full hardware/software shader support
• 2003: Nvidia Geforce FX / ATI Radeon 9800XT
256-bit memory port, displacement mapping,
128-bit color precision, Ultra Shadow,
AGP 8x
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
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
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).”
Shader Languages
• Different Standards:
Nvidia: Cg
OpenGL: GL2
ATI: HSLS (DirectX 9)
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
Small Example (Cg)
• Why Cg?
–
–
–
–
Open source compiler
Works with OpenGL & DirectX
C-like language
can be used for multiple GPUs/Platforms
Small Example (Cg) II
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.
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;
}
vs.1.1
mov oT0, v7
mov oT1, v8
dp4 oPos.x, c1, v0
dp4 oPos.y, c2, v0
dp4 oPos.z, c3, v0
dp4 oPos.w, c4, v0
mul oD0, c0.x, v5
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…
Vertex & Pixel Shaders
The End
し
ゅ
う
え
ん
終
演