AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex...
Transcript of AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex...
![Page 1: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/1.jpg)
AMCS / CS 247 – Scientific VisualizationLecture 12: Volume Visualization, Pt. 2
Markus Hadwiger, KAUST
![Page 2: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/2.jpg)
2
Reading Assignment #6 (until Oct. 22)
Read (required):• Real-Time Volume Graphics, Chapter 1
(Theoretical Background and Basic Approaches),from beginning to 1.4.4 (inclusive)
• Real-Time Volume Graphics, Chapter 3.2.3 (Compositing)
• Data Visualization book, Chapter 5 until 5.2 (inclusive)
![Page 3: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/3.jpg)
3
Reading Assignment #7 (until Oct. 29)
Read (required):• Real-Time Volume Graphics, Chapters 5.3, 5.4, 5.5, 5.6
• Real-Time Volume Graphics, Chapter 7(GPU-Based Ray Casting)
• Real-Time Volume Graphics, Chapter 4 (Transfer Functions)until Sec. 4.4 (inclusive)
![Page 4: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/4.jpg)
4
Programming Assignments Schedule (updated)
Assignment 3:• Volume ray-casting due: Oct 30
Assignment 4:• Flow vis 1 (hedgehog plots, streamlines, pathlines) due: Nov 20
Assignment 5:• Flow vis 2 (LIC with color coding) due: Dec 4
![Page 5: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/5.jpg)
GPU‐Based Ray‐Casting
5
![Page 6: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/6.jpg)
• “Natural” volume rendering method
• Image-order approach– Most common CPU approach– Well-supported by current GPUs!
• Standard optimizations– Early ray termination– Empty space skipping
(empty space leaping)
• Many possibilities– Adaptive sampling– Realistic lighting
6
Ray-Casting
![Page 7: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/7.jpg)
Why Ray-Casting on GPUs?
Most GPU rendering is object-order (rasterization)
Image-order is more “CPU-like”• Recent fragment shader advances
• Simpler to implement
• Very flexible (e.g., adaptive sampling)
• Correct perspective projection
• Can be implementedin a single rendering pass!
• Native 32-bit float compositing
7
![Page 8: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/8.jpg)
Recent GPU Ray-Casting Approaches
Regular grids• [Krüger and Westermann, 2003], [Röttger et al., 2003]
• [Green, 2004] (in NVIDIA SDK)
• [Stegmaier et al., 2005]
• [Scharsach et al., 2006]
• [Gobbetti et al., 2008]
Unstructured (tetrahedral, ...) grids• [Weiler et al., 2002, 2003, 2004]
• [Bernardon et al., 2004]
• [Callahan et al., 2006]
• [Muigg et al., 2007]
8
![Page 9: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/9.jpg)
Single-Pass Ray Casting
• Enabled by conditional loops in fragment shaders(Shader Model 3.0 and higher / NVIDIA CUDA)
• Substitute multiple passes and early-z testing by single loop and early loop exit
• Volume rendering examplein NVIDIA CUDA SDK
9
![Page 10: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/10.jpg)
Implementation
Ray setup
Loop over ray
Resample scalar value
Classification
Shading
Compositing
Markus Hadwiger, KAUST 10
![Page 11: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/11.jpg)
Implementation
Ray setup
Loop over ray
Resample scalar value
Classification
Shading
Compositing
Markus Hadwiger, KAUST 11
![Page 12: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/12.jpg)
Ray Setup
Two main approaches:• Procedural ray/box intersection
[Röttger et al., 2003], [Green, 2004]
• Rasterize bounding box[Krüger and Westermann, 2003]
Some possibilities• Ray start position and exit check
• Ray start position and exit position
• Ray start position and direction vector
12
![Page 13: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/13.jpg)
Procedural Ray Setup/Termination
• Everything handled in the fragment shader / CUDA kernel
• Procedural ray / bounding box intersection
• Ray is given by camera positionand volume entry position
• Exit criterion needed
• Pro: simple and self-contained
• Con: full computational loadper-pixel/fragment
13
![Page 14: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/14.jpg)
Rasterization-Based Ray Setup
• Fragment == ray
• Need ray start pos, direction vector
• Rasterize bounding box
• Identical for orthogonal and perspective projection!
- =
14
![Page 15: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/15.jpg)
Implementation
Ray setup
Loop over ray
Resample scalar value
Classification
Shading
Compositing
Markus Hadwiger, KAUST 15
![Page 16: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/16.jpg)
Classification – Transfer Functions
During Classification the user defines the “look“ of the data.• Which parts are transparent?
• Which parts have what color?
![Page 17: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/17.jpg)
Classification – Transfer Functions
During Classification the user defines the “look“ of the data.• Which parts are transparent?
• Which parts have what color?
The user defines a transfer function.
Emission RGB
Absorption Ascalar S Transfer
Function
![Page 18: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/18.jpg)
Transfer Function Application
texture = scalar field
transferfunction texture = [Emission RGB, Absorption A]
scalar value S
S
RGBA
T(S)resampling
![Page 19: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/19.jpg)
Applying Transfer Function: Cg Example
// Cg fragment program for post-classification
// using 3D textures
float4 main (float3 texUV : TEXCOORD0,
uniform sampler3D volume_texture,
uniform sampler1D transfer_function) : COLOR
{
float index = tex3D(volume_texture, texUV);
float4 result = tex1D(transfer_function, index);
return result;
}
![Page 20: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/20.jpg)
Windowing Transfer Function
Map input scalar range to output intensity range• Select scalar range of interest
• Adjust contrast
Markus Hadwiger, KAUST 20
![Page 21: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/21.jpg)
Implementation
Ray setup
Loop over ray
Resample scalar value
Classification
Shading
Compositing
Markus Hadwiger, KAUST 21
![Page 22: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/22.jpg)
Illumination Model
E.g. Phong: Sum of
V … View vector
L … Light vector (e.g., headlight model L=V)
R … Reflection vector of L at the surface
N … Surface normal
22
![Page 23: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/23.jpg)
xy y
x
Convolution with Continuous Filters
Mixture of function and derivative reconstruction kernels
Apply three filter kernels for three gradient components
2D example with Gaussian kernels
![Page 24: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/24.jpg)
Gradient Reconstruction
Central differences• Cheap and quality often sufficient (2+2+2 neighbors in 3D)
Discrete convolution filters on grid• Image processing filters; e.g. Sobel (3x3x3 neighbors)
Continuous convolution filters• Derived continuous reconstruction filters
• E.g., the cubic B-spline and its derivatives(4x4x4 neighbors)
![Page 25: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/25.jpg)
On-the-fly Gradient Estimation
![Page 26: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/26.jpg)
Pre-compute gradients at grid points with any method
Store normalized gradient directions in RGB texture
Sample gradient texture in fragment shader: interpolation
Re-normalize after fetch!
nX
nY
nZ
RGB
Pre-Computed Gradients
RGB gradient texture lerp of texture filter renormalize!
![Page 27: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/27.jpg)
On-The-Fly Gradients
Reduce texture memory consumption!
Central differences before and after linear interpolationof values at grid points yield the same results
Caveat: texture filter precision
Filter kernel methods are expensive, but:
Tri-cubic B-spline kernels can be used in real-time(e.g., GPU Gems 2 Chapter “Fast Third-Order Filtering”)
![Page 28: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/28.jpg)
Implementation
Ray setup
Loop over ray
Resample scalar value
Classification
Shading
Compositing
Markus Hadwiger, KAUST 28
![Page 29: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/29.jpg)
Fragment Shader
• Rasterize front facesof volume bounding box
• Texcoords are volumeposition in [0,1]
• Subtract camera position
• Repeatedly check forexit of bounding box
![Page 30: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/30.jpg)
CUDA Kernel
• Image-based raysetup
– Ray start image– Direction image
• Ray-cast loop– Sample volume– Accumulate
color and opacity
• Terminate
• Store output
30
![Page 31: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/31.jpg)
GPU PROGRAMMING
Markus Hadwiger, KAUST 31
![Page 32: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/32.jpg)
32
What‘s in a GPU?
Lots of floating point processing power• Stream processing cores
different names:stream processors,CUDA cores, ...
• Was vector processing, now scalar cores!
Still lots of fixed graphics functionality• Attribute interpolation (per-vertex -> per-fragment)
• Rasterization (turning triangles into fragments/pixels)
• Texture sampling and filtering
• Depth buffering (per-pixel visibility)
• Blending/compositing (semi-transparent geometry, ...)
• Frame buffers
![Page 33: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/33.jpg)
What can the hardware do?
RasterizationDecomposition into fragmentsInterpolation of colorTexturing
Interpolation/Filtering Fragment Shading
Fragment OperationsDepth Test (Z-Test)Alpha Blending (Compositing)
![Page 34: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/34.jpg)
Pixels
Graphics Pipeline
Vertices Primitives Fragments
GeometryProcessing
FragmentOperations
Scene Description Raster Image
Rasterization
![Page 35: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/35.jpg)
Geometry Processing
Per-VertexLightingClipping,
Perspect.DividePrimitiveAssemblyTransformation
Multiplication withModelview and
Projection Matrix
Per-VertexLocal Illumination
(Blinn/Phong)
GeometricPrimitives
(Points, LinesTriangles)
Primitives
Clip SpaceTo
Screen Space
Vertices
GeometryProcessing Rasterization Fragment
Operations
![Page 36: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/36.jpg)
GeometryProcessing Rasterization Fragment
OperationsFragment
Operations
TextureFetchTexture
ApplicationPolygon
Rasterization
PrimitiveVertices
Decompositionof primitives
into fragments
Interpolation oftexture coordinates
Filtering oftexture color
Primitives Fragments
Rasterization
Combination ofprimary color with
texture color
![Page 37: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/37.jpg)
Combination ofprimary color with
texture color
Fragment Operations
StencilTestAlpha
BlendingDepthTest
AlphaTest
Discard allfragments within
a certain alpha range
Discard afragment ifthe stencil buffer is set
Discard alloccludedfragments
GeometryProcessing Rasterization Fragment
Operations
![Page 38: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/38.jpg)
Pixels
Graphics Hardware
Vertices Primitives Fragments
GeometryProcessing
FragmentOperations
Scene Description Raster Image
RasterizationVertexShader
FragmentShader
Programmable Pipeline
![Page 39: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/39.jpg)
39
Direct3D 10 Pipeline
New geometry shader stage:• Vertex -> geometry -> pixel shaders
• Stream output after geometry shader
Courtesy David Blythe, Microsoft
![Page 40: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/40.jpg)
Programmable Processing Stages
GLSL 1.50 (OpenGL 3.2)• Vertex shaders (run on vertex processors)
• Geometry shaders (run on geometry processors)
• Fragment shaders (run on fragment processors)
From the language / API perspective it is useful to consider separate types of processors, even when all of these shaders are in reality executed on identical processing cores on current GPUs!
40
![Page 41: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/41.jpg)
Vertex Shader (1)
Process vertices and their attributes• Position
• Color, texture coordinate(s), ...
41
GLSL 1.20
![Page 42: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/42.jpg)
Vertex Shader (2)
“Pass-through“ example• Pass through per-vertex color
• Transform vertex position with OpenGL Model-View-Projection matrix
42
![Page 43: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/43.jpg)
Geometry Shader (1)
Process whole primitives• Emit vertices
• Emit primitive(s)
43GL_EXT_geometry_shader4
![Page 44: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/44.jpg)
Geometry Shader (2)
“Pass-through“ example• Pass through (emit) all vertices
• Pass through (emit) one primitive
44
![Page 45: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/45.jpg)
Fragment Shader (1)
Process fragments• Write one or more output fragments
• Use input color, texture coordinates, ...
• Compute shading, sample textures, ...
• Optionally discard fragment
• MRT: multiple render targets
45
GLSL 1.20
![Page 46: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/46.jpg)
Fragment Shader (2)
“Pass-through“ example• Pass through interpolated color as fragment color
46
![Page 47: AMCS / CS 247 – Scientific Visualization Lecture 12 ... · GLSL 1.50 (OpenGL 3.2) • Vertex shaders (run on vertex processors) • Geometry shaders (run on geometry processors)](https://reader030.fdocuments.in/reader030/viewer/2022040909/5e8117d8744d655fe0257d9f/html5/thumbnails/47.jpg)
Thank you.
Thanks for material• Helwig Hauser
• Eduard Gröller
• Daniel Weiskopf
• Torsten Möller
• Ronny Peikert
• Philipp Muigg
• Christof Rezk-Salama