Tuesday, November 20, 2012

Project5

Part1 Globe:

Implemented

  • Bump mapped terrain
  •     float center = texture2D( u_Bump, v_Texcoord + vec2( -u_time*0.8, 0.0 ));
        float right = texture2D( u_Bump, v_Texcoord+ vec2( -u_time*0.8, 0.0 ) + vec2(1.0/1000.0, 0.0) );
        float top = texture2D( u_Bump, v_Texcoord + vec2( -u_time*0.8, 0.0 )+ vec2(0.0, 1.0/500.0) );

        vec3 perturbedNorm = normalize( vec3(center - right, center - top, 0 .2) );
        vec3 bumpNorm = normalize(eastNorthUpToEyeCoordinates(v_positionMC, normal)* perturbedNorm);

        float BumpDiffuse = max( dot(u_CameraSpaceDirLight, bumpNorm), 0.0 );
  • Rim lighting to simulate atmosphere
    float rimFactor = dot(v_Normal, v_Position) + 1;
  • Nighttime lights on the dark side of the globe
  • Specular mapping
  • Moving clouds(from west to east)
  • Orbiting Moon with texture mapping



Part2 SSAO(Screen Space Ambient Occlusion):
gatherOcclusion:
        float distance =  length( occluder_position - pt_position );
        float overhead = dot( pt_normal, normalize( occluder_position - pt_position ) );
        float planar = 1.0 - abs( dot( pt_normal, occluder_normal ) );
        return planar*max( 0.0, overhead )*( 1.0/(1.0 + distance) ) ;

regularSample:
        vec2 occludePos = texcoord + vec2( i, j )*REGULAR_SAMPLE_STEP;
        vec3 occPos = samplePos(occludePos);
        vec3 occNorm = normalize( sampleNrm(occludePos) );
        accumOcclusion += gatherOcclusion( normalize(normal), position, occNorm, occPos ) ;


Part3 Vertex Pulsing
float displacement = scaleFactor * (0.5 * sin(Position.y * u_frequency * u_time) + 1);
vec3 newPosition = Position + displacement * Normal;

Friday, November 9, 2012

Image Processing/ Vertex Shading

Video


Pat1
Original picture:





Fetures implemeted:
  •  Image negative: vec3(1.0) - rgb

  •  Gaussian blur: GaussianBlurMatrix = 1/16[[1 2 1][2 4 2][1 2 1]]

  •  Grayscale: vec3 w = vec3(0.2125, 0.7154, 0.0721); luminace = dot(rgb, W);

  •  Edge Detection: Sobel-horizontal = [[-1 -2 -1][0 0 0 ][1 2 1]]; Sobel-vertical = [[-1 0 1][-2 0 2 ][-1 0 1]].

  • Toon shading


Optional features:
  • Pixelate: define the pixel size(by using the picture size); Get the new coordinates by6 multiply the pixel size with the pixel index. Pixel indices are calculated by dived the original texture coordinates by pixel size.

  • Brightness: u = (rgb.r + rgb.g + rgb.b)/3;

  • Contrast: (m-a)/(n-a) vs m/n

  • Night Vision: Only multiplied by green color;



Part2:
Sea wave:
float s = sin(pos.x*2PI + time);
        float t = cos(pos.y*2PI + time);
        height = sin(sqrt(s^2 + t^2 ))/sqrt(s^2 +t^2 );



Tuesday, November 6, 2012

Raterizer -- some triangles are missing



Optional feature I chose are:
  • backface culling
  • interactive camera
The rasterization doesn't looks right, some faces are missing:




Back-face culling



Video: