Program Description


 

Implement the hair simulation and Phong shading with texture mapping.

Due Day


 

2017/1/4 23:59
Please upload your entire files as a zip file to e3.

Please upload entire solution, project, source code, and objects!
And please use your school id as your file name.
For example: 9655862V1.zip

 

Requirement


 

Use line smooth: glEnable(GL_LINE_SMOOTH).
Use blending to render the transparent part of hair.
You need to pay attentilon to your depth buffer.


You should have two shader program in this assignment.
Hair simulation program should have vertex, geometry and fragment shader.
Use geometry shader to implement the hair simulation.
It uses to draw the hair of scalp object.
Phong shading program should have vertex and fragment shader.
It uses to draw the head(sphere object) and implement the Phong shading with head's texture(face.bmp).

UI control:

    • Keyboard : Move the camera and adjust parameters.
      • 'w' : zoom in
      • 'a' : move left (circle the center)
      • 's' : zoom out
      • 'd' : move right (circle the center)
      • 'r' : increase the length of segment 
      • 'f' : decrease the length of segment 
      • 't' : increase the number of segment
      • 'g' : decrease the number of segment
      • 'y' : increase the y of gravity vector
      • 'h' : decrease the y of gravity vector

The meaning of length, segment and gravity vector is in "Implementation Steps".

Implementation Steps


 

Hair simulation program:

Vertex shader:

Send the vertex's normal to geometry shader.

Geometry shader:

For every vertex, use vertex's normal(add gravity) to compute the end point of a segment line.
Repeat this process for the number of segments times to generate hair.
PS: Output primitive type must be line_strip.

 

 Hair_simulation.png

Fragment shader:

Final color is according to the order of segment.
You need to define your hair color first (You can set any color).
The first segment's color(RGB) should be black and the final segment's color(RGB) should be the hair color.
The first segment's alpha(A) should be 1.0 and the final segment's alpha(A) should be 0.0.
You need to interpolate the color and alpha between the first and final segment.

Phong shading program:

Vertex shader:

Sent the vertex's eye space's position, normal and texture coordinate to fragment shader.

Fragment shader:

Compute the ambient, diffuse and specular color and accumulate them as lighting result color.
Use uniform variable to access the texture layer and compute texture color.
Final color = texture color * lighting result color.

You can refer to our GLSL example.

 

Test Scene


Peter (Click to download!)

SegNum15_Len0.5_g-0.1_color0.3_0.3_0.7_1.0.png

Picture 1: number of segment = 15,  length = 0.5f,

gravity vector = (0.0f, -0.1f, 0.0f), hair color = (0.3, 0.3, 0.7, 1.0)

 

SegNum8_Len1_g-0.1_color0.3_0.3_0.7_1.0.png

Picture 2: number of segment = 8,  length = 1.0f,

gravity vector = (0.0f, -0.1f, 0.0f), hair color = (0.3, 0.3, 0.7, 1.0)

 

SegNum15_Len0.5_g0.1_color0.3_0.3_0.7_1.0.png

Picture 3: number of segment = 15,  length = 0.5f,

gravity vector = (0.0f, 0.1f, 0.0f), hair color = (0.3, 0.3, 0.7, 1.0)

 

SegNum15_Len0.2_g-0.1_color0.3_0.3_0.7_1.0.png

Picture 4: number of segment = 15,  length = 0.2f,

gravity vector = (0.0f, -0.1f, 0.0f), hair color = (0.3, 0.3, 0.7, 1.0)

 

Go to top