Real-Time Volume Graphics
[02] GPU Programming
RTVG4Me
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
Eurographics 2006
Graphics Processor
Example
NVidia Geforce6
Host
Vertex Processors
Cull/Clip/Setup
Z-Cull
Rasterization
Fragment Processors
Texture Cache
Fragment Crossbar
Memory Access
Z-Compare and
Blending
Memory
Partition
Memory
Partition
Memory
Partition
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
Memory
Partition
Eurographics 2006
PC Architecture
CPU
6.4 GB/s
System
Memory
up to 8 GB/s
North
Bridge
GPU
6.4 GB/s
South
Bridge
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
Video
Memory
up to
35 GB/s
Eurographics 2006
Graphics Hardware
Scene Description
Raster Image
Geometry
Processing
Vertices
Rasterization
Primitives
Fragment
Operations
Fragments
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
Pixels
Eurographics 2006
What can the hardware do?
Rasterization
Decomposition into fragments
Interpolation of color
Texturing
Interpolation/Filtering
Fragment Shading
Fragment Operations
Depth Test (Z-Test)
Alpha Blending (Compositing)
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
Eurographics 2006
Geometry Processing
Geometry
Processing
Affine
Transform.
Per-Vertex
Lighting
Rasterization
Primitive
Assembly
Fragment
Operations
Projective
Transform.
Per-Vertex
Geometric
Transformation
Multiplication
Primitives
to Canonical
with Transforma-Local Illumination
(Blinn/Phong)
(Points, Lines Viewing Volume
tion Matrix
Triangles)
Vertices
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
Primitives
Eurographics 2006
Geometry Processing
Rasterization
Geometry
Processing
Rasterization
Fragment
Operations
Affine
Polygon Per-VertexTexturePrimitive
Texture
Projective
Transform
Rasterization
.
Lighting FetchAssembly Application
Transform.
Interpolation
Geometric
of
Combination
of
Transformation
Multiplication
Decomposition Per-Vertex
to Canonical
Local Illumination
texture coordinates
Primitivesprimary
color with
with Transformaof primitives
Viewing
Volume
(Blinn/Phong)
Lines texture
color
tion
into
Matrix
fragments
Filtering(Points,
of
Triangles)
texture color
Primitives
Vertices
Fragments
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
Primitive
Eurographics 2006
Rasterization
Fragment Operations
Geometry
Processing
Rasterization
Fragment
Operations
Alpha
Polygon
Stencil Texture Depth
Rasterization
Test
Test Fetch Test
Texture
Alpha
Application
Blending
Discard
Interpolation
a
Discard
of
all Combine
Combination
the fragment
of
Discard
Decomposition
all
fragment
texture
if coordinates
occluded primary
color with
colorthe
with
color
fragments
of primitives
within
texture
already
color
in the
a into
certain
fragments the stencil
Filtering fragments
of
buffer is texture
set
frame buffer
alpha range
color
Primitives
Fragments
Fragments
Fragments
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
Eurographics 2006
Graphics Hardware
Scene Description
Programmable Pipeline
Geometry
Vertex
Processing
Shader
Vertices
Fragment
Rasterization
Shader
Primitives
Fragment
Operations
Fragments
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
Raster Image
Pixels
Eurographics 2006
Vertex Shader
Important Features:
Vertex Shader has information about one single Vertex
only (no topological information)!
For each set of vertex-attributes, the vertex shader
generates
exactly one vertex
The vertex shader cannot create additional vertices!
The vertex shader cannot discard vertices from the stream!
The term „shader“ is somehow misleading, since the vertex
shader can change the geometry!
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
Eurographics 2006
Vertex Shader Instructions
Assembly-Language, such as
ABS
ADD
DP3
DP4
DST
LIT
MUL
MAD
SUB
XPD
absolute value
addition
scalar product (dot product)
scalar product 4-components
distance vector
illumination terms
multiplication
multiply and add
subtraction
cross product
Most commands are vector commands (4
components)
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
Eurographics 2006
High-Level Shading Languages
Who wants to write assembler code?
Stanford Shading Language
Cg (developed by Nvidia) for OpenGL and DirectX
DirectX 9.0 HLSL (DirectX only, Syntax similar to Cg)
GLSL (OpenGL shading language)
Syntax similar to C
plus vector variables und vector instructions:
float4 v1; // same as float v1[4] in C
int3 v2; // same as int v2[3] in C
Swizzling: float4 v3 = v1.xzzy;
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
Eurographics 2006
Programmable Vertex Processor
Begin
Vertex
Vertex
Program
Instructions
InputRegisters
Temporary
Registers
OutputRegisters
copy vertex
attributes to
input registers
Fetch next
instruction
Read inputor temporary
registers
Mapping:
Negation
Swizzling
Execute
command
no
Write to
output or
temp. registers
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
Finished?
yes
Emit Vertex
Eurographics 2006
Fragment Processor
Begin
Fragment
copy fragment
attributes to
Input register
Fragment
Program
Instructions
Fetch next
instruction
Read input
of temporary
registers
InputRegisters
Temporary
Registers
Texture
Memory
Output
Registers
Mapping:
Negation
Swizzling
Calculate texture
address and
sample texture
interpolate
texel color
yes
Texture
Instruction?
no
no
Finished?
execute
instruction
Write to output
or temporary
registers
REAL-TIME VOLUME GRAPHICS
Christof Rezk Salama
Computer Graphics and Multimedia Group, University of Siegen, Germany
yes
Emit Fragment
Eurographics 2006
Phong Shading
Per-Pixel Lighting: Local illumination in a fragement
shader
void main(float4 position : TEXCOORD0,
float3 normal
: TEXCOORD1,
out float4 oColor
uniform
uniform
uniform
uniform
uniform
uniform
uniform
uniform
float3
float3
float3
float3
float3
float3
float3
float
: COLOR,
ambientCol,
lightCol,
lightPos,
eyePos,
Ka,
Kd,
Ks,
shiny)
{
float3 P = position.xyz;
REAL-TIME
float3VOLUME
N = GRAPHICS
normal;
Christof Rezk Salama
float3
V =andnormalize(eyePosition
- P);
Computer
Graphics
Multimedia Group, University of Siegen, Germany
float3 H = normalize(L + V);
Eurographics 2006
© Copyright 2026 Paperzz