# CS 184: COMPUTER GRAPHICS

PREVIOUS < - - - - > CS 184 HOME < - - - - > CURRENT < - - - - > NEXT

# Lecture #27 -- Th: 12/07, 2004

## Review of Color Spaces

Discussion of worksheet with questions from previous Final Exams.
3D Color Spaces -- Color Mixing

## Transparency

[see textbook: Ed2: Ch 9.7;  Ed3: Ch 7.9]
Definitions:
Transparency measures what fraction of light passes through a surface or body;
that fraction is indicated by the transmission coefficient kt.
Opacity (a) indicates what fraction is held back; a=1 means: completely opaque.
kt+a=1
There are many ways to implement partially transparent/opaque objects:

### Ray tracing

This is a natural way to deal with a (partially) transparent object T; for instance:
At the surface of object T, we split the ray into a primary ray that returns the color of object T with some weighted percentage,
and into a secondary ray that passes through the medium and returns information "from behind" with the complementary percentage.
This information could be further attenuated or discolored, dpending on the thickness of the body T.

### Alpha channel

OpenGl offers another mechanism: alpha blending.
A fourth channel a is established -- in addition to R, G, B.
Thus for each surface, vertex, or pixel we can define four values: (RGBa).
If a-blending is enabled, the fourth parameter a determines how the the RGB values are written into the frame buffer:
typically the result is a linear combination (or blend) of the contents already in memory and the new information being added.

Filtered Transparency:
Assume that in the frame buffer we have a pixel (Fr, Fg, Fb, Fa),
and we want to place a new pixel with opacity a in front of it (Nr, Ng, Nb, Na):
We can achieve the desired result with: ( a*Nr + kt*Fr,   a*Ng + kt*Fg,   a*Nb + kt*Fb,   a*Nar + kt*Fa  );
this corrsponds to placing a filter of opacity a in front of an already rendered scene.
For this blending function to work, the transparent polygons have to be rendered after the opaque objects.
For multiple filter polygons, the effect is calculated recursively back-to-front.
Alpha Blending in OpenGL

Interpolated Transparency:
In a different situation, we might want to form a composite image from m candidate images (e.g. in Image-based Rendering);
In this case, the compositing function might look like: (  sum(Nri)/m,  sum(Ngi)/m,  sum(Nbi)/m,  sum(Nai)/m, )
OpenGL provides many different blending functions to take care of many commonly occuring situations.

### Screen-door transparency

Interpolated transparency can be realized by rendering only a subset of the pixels associated with the image of the transparent object;
in the other pixels, the object behind the "screen-door" object is rendered.
(the low-order bits in the pixel address determine to which subset a pixel belongs.)
This technique is limited to a very small number of overlapping transparent media,
and it can produce some undesirable Moire effects.
Screen-Door Transparency in OpenGL

### Statistical sampling

Monte Carlo ray-tracing or photon mapping deal with partial transparency in a statistical manner.
Depending on the ratio kt/a, a different fraction of the photons are terminated in the foreground or in the background.
Multisampling in OpenGL

End of technical material for Final Exam.
Next time: Review of key rendering paradigms. Trends and Challenges in Computer Graphics.
==> Celebration!

Example

## Where to go from here ... ?

Follow-on courses:
Undergraduate courses: CS 160 (User Interfaces, HCI);
Graduate courses:  CS294-7, "The Art of Animation", Prof. Barsky, Spring 2005;
(offered every couple of years): CS283 (Graphics), CS284 (Splines), CS285 (Procedural Modeling), 280 (Vision);

HKN SURVEY

Study: 2ndEd: Ch 9.7
Study: 3rdEd: Ch 7.9

## ASG#10  Final Project

Project Due Date is Monday, December 13, 7:59pm.