CSCE 441 Lecture 32

From Notes
Jump to navigation Jump to search

« previous | Wednesday, April 9, 2014 | next »


Subdivision Surfaces

  1. Assume surface is made of quads
  2. Any number of quads may touch a single vertex
  3. Linear subdivision and averaging


Polygon linear subdivision:

  • midpoints of quad edges
  • midpoint (centroid) of quad
  • connect centroid to edge midpoints

Polygon averaging

  • Find centroids of each quad
  • move vertices of polygon to average of centroids of adjacent polygons


The resulting surface is C2-smooth except for points that did not have 4 quads touching it


def getVert(i1, i2):
    if orderless key (i1, i2) not in hash            # i.e. (i1,i2) == (i2,i1)
        add midpoint of V[i1], V[i2] to newV
        hash[(i1,i2)] = index of new point
    return hash[(i1,i2)]

def linearSub(F,V):
    newV = V
    newF = []

    for face in F:
        for j in range(4):
            midpointIndices[j] = getVert(face[j], face[j+1])
        add centroid (average of midpointIndices) to newV and store index in c
        for j in range(4):
            add face (face[j], midpointIndices[j], c, midpointIndices[j-1]) to newF

    return (newF, newV)

def average(F, V):
    newV = zeroes(len(V))
    valence = array of 0 whose size is number of vertices
    newF = F
    for face in F:
        cent = centroid for face
        newV[face] += cent
        valence[face] += 1
    for i in range(newV):
        newV[i] = nevV[i] / valence[i]

    return (newF, newV)


Shadows

(in the context of real-time rendering)

Give us clues about depth and make scenes more realistic

Overview

  • Simple/Planar shadows
  • Shadow Maps
  • Shadow Volumes


Simple/Planar Shadows

  • Projection of an object onto planar surface
  • Build projection matrix from light to plane
  • Draw object in black using projection matrix

Fast, simple, but only works on planes and does not allow self-shadowing


Shadow Maps

Render scene from light's perspective

The map is the z-buffer from the light's rendering.

Render scene from viewer's perspective

For each pixel, transform to world space, and compare distance to value in shadow map.

  • Pick a point visible to the user.
  • Compare distance to light with value in z-buffer. If equal, not in shadow; if greater, in shadow.