Shengyu's Basic Shading Project

Introduction

This project Demo Link implements the following features:

  • open a window contains an OpenGL rendering area in which a circular shape should be shaded using the Phong Illumination Model for point and directional lights.

  • The circular shape should always occupy most of the window. If the window is resized it should update the display so that the shape still occupies most of the window and is still round. (In this context “most” would mean that the diameter of the circle should be 90% of the smaller of the window’s height or width.)

  • Press arrow keys to move the circular shape, and either ESC key or Q to terminate the program and close the window.

Command Lane Arguments

All the command line arguments are optional. The default values should be a black sphere with no lights. That is the program display a black circular shape on a black(default) background. If material parameters are multiply specified, the last value should be used.

-ka r g b

  • This is the ambient color coefficients of the sphere material. The parameters r g b are numbers between 0 and 1 inclusive.

-kd r g b

  • This is the diffuse color coefficients of the sphere material. The parameters r g b are numbers between 0 and 1 inclusive.

-ks r g b

  • This is the specular color coefficients of the sphere material. The parameters r g b are numbers between 0 and 1 inclusive.

-spu pu

  • This is the power coefficient on the specular term in the u direction for an anisotropic material. It is a number between 0 and max_float.

-spv pv

  • This is the power coefficient on the specular term in the v direction for an anisotropic material. It is a number between 0 and max_float.

-sp p

  • This is the power coefficient on the specular term for an isotropic material. It is a number between 0 and max_float. (i.e. the same as setting pu and pv the the same value.)

-pl x y z r g b

  • This adds a point light to the scene. The x y z values are the location of the light. The r g b values are it’s color. Note that the x y z values are relative to the sphere. That is, the center of the sphere is at the origin and the radius of the sphere defines one unit of length. The Y direction is UP, the X direction is to the right on the screen, and the Z direction is “in your face.” The r g b value are between 0 and max_float, NOT between 0 and 1 (that is, the r g b values encode the brightness of the light).

-dl x y z r g b

  • This adds a directional light to the scene. The x y z values are the direction that the light points in. The r g b values are it’s color. See -pl for coordinate system notes.

-bgbmp fp

  • This tells which .BMP file would be used as the custom background image.

-bgppm fp

  • This tells which .ppm file would be used as the custom background image.

-toon

  • switch to the toon shading

-pixellation

  • apply the pixellation effect on the final image

Specifications:

  • There may be up to 5 point lights and 5 directional lights (10 total) in a scene. Image r g b values of 1.0 should be mapped to a display values of 255.

  • The coordinate system you use in your program should have a unit sphere at the origin and the viewer looking down the Z-axis. The X-axis points to the right of the screen, the Y-axis points up, and the viewer is located infinitely far away in the positive Z direction. You should assume that the vector from eye to the surface will always be -Z.

  • All the background image would automatically fill the screen when the screen has been resized.

Gallery

The shading results generated from my program.

Sample1

assignment1 -ka 0.1745 0.01175 0.01175 -kd 0.61424 0.04136 0.04136 -ks 0.727811 0.626959 0.626959 -sp 76.8 -bgbmp sampleBG2.BMP -dl -0.5 0.1234 -0.42 0.235 0.263 0.5 -pl 1.512 1.123 1.132 0.125 0.643 0.6423 -dl 0.125 0.125 0.125 0.125 0.125 0.125 -dl 0.6423 0.346 0.634 0.124 0.623 0.623 -dl 0.12312 0.512 0.1231 0.1231 0.123 0.5612 -dl 0.125 0.1245 0.321 1 1 1 -pl 1.512 1.3123 1.312 0.123 0.6236 0.623 -pl 1.1236 1.1236 1.6234 0.23460 0.3462 0.2346 -pl 1.2346 1.6342 1.423 0.123 0.632 0.6432 -pl 1.1236 1.6423 1.6423 0.123 0.632 0.6432

Sample2

assignment1 -ka 0.2125 0.1275 0.054 -kd 0.714 0.4284 0.18144 -ks 0.393548 0.271906 0.166721 -sp 25.6 -bgbmp gray.BMP -dl -0.5 0.1234 -0.42 0.235 0.263 0.5 -pl 1.512 1.123 1.132 0.125 0.643 0.6423

Sample3

assignment1 -ka 0.25 0.25 0.25 -kd 0.4 0.4 0.4 -ks 0.774597 0.774597 0.774597 -spu 10 -spv 70 -bgppm samplebg1.ppm -pl 1.512 1.123 1.132 1 1 1 -dl 0.12312 0.512 0.1231 0.1231 0.123 0.5612

Sample4

assignment1 -ka 0 0 0 -kd 0.01 0.01 0.01 -ks 0.5 0.5 0.5 -spu 75 -spv 5 -bgppm samplebg1.ppm -dl -0.5 0.1234 -0.42 0.235 0.263 0.5 -pl 1.512 1.123 1.132 0.125 0.643 0.6423 -dl 0.125 0.125 0.125 0.125 0.125 0.125 -dl 0.6423 0.346 0.634 0.124 0.623 0.623 -dl 0.12312 0.512 0.1231 0.1231 0.123 0.5612 -dl 0.125 0.1245 0.321 1 1 1

Sample5

assignment1 -ka 0 0 0 -kd 0.01 0.01 0.01 -ks 0.5 0.5 0.5 -sp 32 -bgppm samplebg1.ppm -dl -0.5 0.1234 -0.42 0.235 0.263 0.5 -pl 1.512 1.123 1.132 0.125 0.643 0.6423 -dl 0.125 0.125 0.125 0.125 0.125 0.125 -dl 0.6423 0.346 0.634 0.124 0.623 0.623 -dl 0.12312 0.512 0.1231 0.1231 0.123 0.5612 -dl 0.125 0.1245 0.321 1 1 1 -pl 1.2346 1.6342 1.423 0.123 0.632 0.6432 -pl 1.1236 1.6423 1.6423 0.123 0.632 0.6432 -pl 1.512 1.3123 1.312 0.123 0.6236 0.623 -pl 1.1236 1.1236 1.6234 0.23460 0.3462 0.2346

Sample6

-ka 0 0 0 -kd 0.652 0.232 0.612 -sp 30 -ks 0.65 0.30 0.12 -dl -0.5 0.1234 -0.42 0.235 0.263 0.5 -pl 1.512 1.123 1.132 0.125 0.643 0.6423 -dl 0.125 0.125 0.125 0.125 0.125 0.125 -dl 0.6423 0.346 0.634 0.124 0.623 0.623 -dl 0.12312 0.512 0.1231 0.1231 0.123 0.5612 -dl 0.125 0.1245 0.321 1 1 1 -pl 1.512 1.3123 1.312 0.123 0.6236 0.623 -pl 1.1236 1.1236 1.6234 0.23460 0.3462 0.2346 -pl 1.2346 1.6342 1.423 0.123 0.632 0.6432 -pl 1.1236 1.6423 1.6423 0.123 0.632 0.6432 -toon

Sample7

assignment1 -ka 0.1745 0.01175 0.01175 -kd 0.61424 0.04136 0.04136 -ks 0.727811 0.626959 0.626959 -sp 76.8 -bgbmp sampleBG2.BMP -dl -0.5 0.1234 -0.42 0.235 0.263 0.5 -pl 1.512 1.123 1.132 0.125 0.643 0.6423 -dl 0.125 0.125 0.125 0.125 0.125 0.125 -dl 0.6423 0.346 0.634 0.124 0.623 0.623 -dl 0.12312 0.512 0.1231 0.1231 0.123 0.5612 -dl 0.125 0.1245 0.321 1 1 1 -pl 1.512 1.3123 1.312 0.123 0.6236 0.623 -pl 1.1236 1.1236 1.6234 0.23460 0.3462 0.2346 -pl 1.2346 1.6342 1.423 0.123 0.632 0.6432 -pl 1.1236 1.6423 1.6423 0.123 0.632 0.6432 -pixellation

Sample8

assignment1 -ka 0.25 0.25 0.25 -kd 0.4 0.4 0.4 -ks 0.774597 0.774597 0.774597 -spu 10 -spv 70 -bgppm samplebg1.ppm -pl 1.512 1.123 1.132 1 1 1 -dl 0.12312 0.512 0.1231 0.1231 0.123 0.5612 -pixellation

Site by Shengyu Jin using hexo blog framework. Late Updated: May 6, 2020

载入天数...载入时分秒...