Difference between revisions of "GAM670/DPS905 Weekly Schedule 20121"
(→This Week) |
(→This Week) |
||
Line 253: | Line 253: | ||
Matrix projection; // projection transformation | Matrix projection; // projection transformation | ||
</pre> | </pre> | ||
− | :: APIDisplay.cpp | + | :: APIDisplay.cpp - setup() |
<pre> | <pre> | ||
// points to compiled shader code | // points to compiled shader code | ||
Line 284: | Line 284: | ||
d3dd->SetVertexShader(vertexShader); | d3dd->SetVertexShader(vertexShader); | ||
</pre> | </pre> | ||
+ | :: APIDisplay.cpp - setProjection() | ||
<pre> | <pre> | ||
this->projection = *((Matrix*)projection); | this->projection = *((Matrix*)projection); | ||
</pre> | </pre> | ||
+ | :: APIDisplay.cpp - beginDrawFrame() | ||
<pre> | <pre> | ||
Matrix& v = *((Matrix*)view); | Matrix& v = *((Matrix*)view); | ||
Line 301: | Line 303: | ||
uniformVS->SetInt(d3dd, "noLights", 4); | uniformVS->SetInt(d3dd, "noLights", 4); | ||
</pre> | </pre> | ||
+ | :: APIDisplay.cpp - set() | ||
<pre> | <pre> | ||
uniformVS->SetBool(d3dd, "lighting", b); | uniformVS->SetBool(d3dd, "lighting", b); | ||
</pre> | </pre> | ||
+ | :: APIDisplay.cpp - setWorld() | ||
<pre> | <pre> | ||
uniformVS->SetMatrix(d3dd, "world", (D3DXMATRIX*)world); | uniformVS->SetMatrix(d3dd, "world", (D3DXMATRIX*)world); | ||
</pre> | </pre> | ||
+ | :: APIDisplay.cpp - setReflectivity() | ||
<pre> | <pre> | ||
uniformVS->SetFloatArray(d3dd, "material.ambient", (FLOAT*)&r.ambient, 4); | uniformVS->SetFloatArray(d3dd, "material.ambient", (FLOAT*)&r.ambient, 4); | ||
Line 313: | Line 318: | ||
uniformVS->SetFloat (d3dd, "material.power", (FLOAT)r.power); | uniformVS->SetFloat (d3dd, "material.power", (FLOAT)r.power); | ||
</pre> | </pre> | ||
+ | :: APIDisplay.cpp - release() | ||
<pre> | <pre> | ||
// release the shader COM objects | // release the shader COM objects | ||
Line 324: | Line 330: | ||
} | } | ||
</pre> | </pre> | ||
+ | :: APILight.cpp - setup() | ||
<pre> | <pre> | ||
// Populate the vertex shader constant table | // Populate the vertex shader constant table | ||
Line 363: | Line 370: | ||
rc = true; | rc = true; | ||
</pre> | </pre> | ||
+ | :: APILight.cpp - turnOn() | ||
<pre> | <pre> | ||
char constantLightOn[] = "lightOn[0]"; | char constantLightOn[] = "lightOn[0]"; | ||
Line 374: | Line 382: | ||
uniformVS->SetBool(d3dd, constantLightOn, true); | uniformVS->SetBool(d3dd, constantLightOn, true); | ||
</pre> | </pre> | ||
+ | :: APILight.cpp - update() | ||
<pre> | <pre> | ||
char constantLightOn[] = "lightOn[0]"; | char constantLightOn[] = "lightOn[0]"; | ||
Line 385: | Line 394: | ||
uniformVS->SetBool(d3dd, constantLightOn, true); | uniformVS->SetBool(d3dd, constantLightOn, true); | ||
</pre> | </pre> | ||
+ | :: APILight.cpp - turnOff() | ||
<pre> | <pre> | ||
char constantLightOn[] = "lightOn[0]"; | char constantLightOn[] = "lightOn[0]"; | ||
Line 390: | Line 400: | ||
uniformVS->SetBool(d3dd, constantLightOn, false); | uniformVS->SetBool(d3dd, constantLightOn, false); | ||
</pre> | </pre> | ||
+ | :: APIGraphic.h - class APIXMesh | ||
<pre> | <pre> | ||
D3DXCOLOR* ambient; | D3DXCOLOR* ambient; | ||
Line 396: | Line 407: | ||
FLOAT* power; | FLOAT* power; | ||
</pre> | </pre> | ||
+ | :: APIGraphic.cpp - APIXMesh() | ||
<pre> | <pre> | ||
ambient = nullptr; | ambient = nullptr; | ||
Line 402: | Line 414: | ||
power = nullptr; | power = nullptr; | ||
</pre> | </pre> | ||
+ | :: APIGraphic.cpp - APIXMesh() | ||
<pre> | <pre> | ||
ambient = nullptr; | ambient = nullptr; | ||
Line 408: | Line 421: | ||
power = nullptr; | power = nullptr; | ||
</pre> | </pre> | ||
+ | :: APIGraphic.cpp - operator=() | ||
<pre> | <pre> | ||
if (ambient) | if (ambient) | ||
Line 430: | Line 444: | ||
} | } | ||
</pre> | </pre> | ||
+ | :: APIGraphic.cpp - setup() | ||
<pre> | <pre> | ||
ambient = new D3DXCOLOR[nSubsets]; | ambient = new D3DXCOLOR[nSubsets]; | ||
Line 445: | Line 460: | ||
power[i] = matl[i].MatD3D.Power; // 0 if it shouldn't be shiny | power[i] = matl[i].MatD3D.Power; // 0 if it shouldn't be shiny | ||
</pre> | </pre> | ||
+ | :: APIGraphic.cpp - draw() | ||
<pre> | <pre> | ||
uniformVS->SetFloatArray(d3dd, "material.ambient", (FLOAT*)&ambient[i], 4); | uniformVS->SetFloatArray(d3dd, "material.ambient", (FLOAT*)&ambient[i], 4); | ||
Line 451: | Line 467: | ||
uniformVS->SetFloat(d3dd, "material.power", (FLOAT)power[i]); | uniformVS->SetFloat(d3dd, "material.power", (FLOAT)power[i]); | ||
</pre> | </pre> | ||
+ | :: APIGraphic.cpp - suspend() | ||
<pre> | <pre> | ||
if (ambient) | if (ambient) |
Revision as of 18:57, 14 February 2012
GAM670/DPS905 | Weekly Schedule | Student List | Project Requirements | Teams and their Projects | Student Resources
Contents
GAM670/DPS905 -- Weekly Schedule 20121
Week 1 - Jan 8
This Week
- Assignment Discussion
- Suggested Enhancements
- Review of the Base Code
- Definition of a Framework
- Modularity through stable interfaces
- Re-usability through generic components
- Extensibility through hook methods
- Inversion of control - determines which application methods to invoke in response to external events
- Framework Architecture
- Modelling Layer
- API Translation Layer
- Notable Features of the Base Code
- camera, sound, and light are also derived from the Frame class
- textures attach at the object level
- texture connection is uncoupled from drawing of the graphics primitives
- reference frames are relative
- very simple collision detection
- Definition of a Framework
To Do
- add your name to the student list
- create a team page that includes the semester number 20121
- describe the game that you intend to develop
- list the topics of interest to your team in developing its game
- list the other topics of interest
Resources
Week 2 - Jan 16
This Week
- Relative Reference Frames
- Recursive calls
- Vector Frame::position()
- Matrix Frame::rotation()
- Matrix Frame::world()
- Detaching from and attaching to a parent frame
- Frame::attachTo()
- Recursive calls
- Geometry
- Plane
- normal + constant - examples
- equation of a plane: dot(n, x) + D = 0
- positive side of a plane dot(n, x) + D > 0
- Plane
- Collision Detection
- types of colliders
- spheres
- planes
- axis-aligned bounding boxes
- oriented bounding boxes
- types of colliders
To Do
- Research the feature that you are going to add and prepare a plan of action
- Prepare a team page for your team so that repos can be ordered
- Add a section to your team page to track your project and solicit commentary
Resources
Week 3 - Jan 23
This Week
- Collision Detection (cont'd)
- Shape
- Shape : Frame
- Shape::setRadius()
- Shape::getRadius()
- Shape::setRadius(float r);
- Shape::setRadius(float x, float y, float z);
- Shape::getRadius() const { return radius; }
- Shape::setPlane(Vector n, float d);
- Shape::setAxisAligned(Vector min, Vector max);
- Shape
- Comprehensive Camerawork
- rotation about an axis
- order of rotation matters
- Euler angles
- gimbal lock
- complex numbers
- solution of cubic equations 16th century
- two-dimensional representation
- matrix representation
- quaternions
- extension of complex numbers
- four-dimensional representation
- matrix representation
- geometric algebra (more abstract)
- Visibility Determination
- test a point for presence within a set of planes
- normal calculations - general rotation matrix - vector and angle
- ViewFrustum
- parameter - view * projection
- 6 planes
- near and far planes
- left and right planes
- top and bottom planes
- coding
- constructor
- ViewFrustum::contains()
- Finite Size of Objects
- Expansion of the View Frustum
- Index Buffers
- amount of storage needed for vertex data
- duplication of vertex data
- indexing
- indexed primitives
To Do
Resources
- Wikipedia on Complex Numbers
- Wikipedia on Quaternions
- Wikipedia on quaternions and Spatial Rotations
- Wolfram on Quaternions
- CProgramming.com on Quaternions
- Ogre intro on Quaternions
- collision sample
- indexBuffering sample
Week 4 - Jan 30
This Week
- Meshes
- What is a mesh?
- vertex list -> vertex buffer
- index list -> index buffer
- attribute list -> subset to which primitives belong
- pyramid sample
- Stock Objects
- Sphere
- slices and partitions
- Cylinder
- Torus
- Utah Teapot
- APIGraphic.h and .cpp code
- Sphere
- Custom Mesh
- Create a Mesh
- FVF settings
- DrawSubset
- DrawIndexedPrimitive parameters
- APIGraphic.h code
- X File
- Create Mesh from File
- What is a mesh?
- SkyBox
- definition of a skybox
- attachment to camera
- inverted coordinates
- skybox textures
- Graphic.cpp code
- more complicated forms - skydome
- definition of a skybox
- Billboards
- definition, purpose of a billboard
- types of billboards
- screen-aligned - useful for annotation text, lens flares
- normal is opposite to camera heading
- up is camera->up
- axial - useful for cylindrical symmetry - trees (textured object does not face straight on)
- up is fixed
- normal faces the viewer as much as possible
- view_plane - no distortion - useful for
- normal is fixed (opposite to camera heading)
- up is open to change
- viewpoint - simulates distortion due to perspective projection - useful for clouds
- normal is fixed (difference between viewpoint position and camera heading)
- up is open to change
- screen-aligned - useful for annotation text, lens flares
- Object.h and Object.cpp code
- Texture Filtering
- mip maps
- multum in parvo
- texture creation
- APITexture::SetSamplerState()
- mip maps
- DirectX Errors
- DirectX Utilities - Lookup Tool
- APIDisplay::restore() example
To Do
Resources
- meshes sample
- Rob Whitaker on Skyboxes
- Image Based Rendering - Suman Nadella on Billboarding and Imposters
- DigitalRune
- Wikipedia on Texture Filtering
- D3D 9 tutorial on modeling with an Index list
Week 5 - Feb 6
This Week
- Vertex Declarations
- The Pipeline
- The GPU
- nVidia
- AMD (previously ATI)
- Shader Languages
- what is a shader
- dedicated shaders
- unified shaders
- how does a shader work
- Vertex Shaders
- Pixel Shaders
- effect of skybox and point light on frame rate
To Do
- reorganize framework code so that vertex shader receives product of world, view, and projection matrices
- store viewProjection matrix as an instance variable in Display
- add viewProjection query to Display to extract product of view and projection matrices
- retrieve viewProjection in *::draw() method
- pre-multiply viewProjection by world to obtain composite matrix to pass to vertex shader
- add composite matrix to the constant table in the vertex shader
- reorganize framework code to minimize duplication of heading normalization
- perform normalization of heading in Display::beginDraw()
Week 6 - Feb 13
This Week
- Vertex Shader Programming
- Host
- APIPlatformSettings.h - Vertex Shader Identification
// shader file data #define VERTEX_SHADER_FILE L"vertexShader.hlsl" #define VERTEX_SHADER_ENTRY_POINT "vertexShader"
- APIBase.h - pointers into the shader
static IDirect3DVertexShader9* vertexShader; // vertex shader static ID3DXConstantTable* uniformVS; // for vertex shader
- APIDisplay.h
Matrix projection; // projection transformation
- APIDisplay.cpp - setup()
// points to compiled shader code LPD3DXBUFFER compiledCodeVS = nullptr; // check for minimum vertex shader version required if (caps.VertexShaderVersion < D3DVS_VERSION(2,0)) error(L"Display::09 Device does not support vertex shader 2_0");
// compile the vertex shader source code else if (FAILED(D3DXCompileShaderFromFile(VERTEX_SHADER_FILE, NULL, NULL, VERTEX_SHADER_ENTRY_POINT, D3DXGetVertexShaderProfile(d3dd), D3DXSHADER_DEBUG | D3DXSHADER_SKIPOPTIMIZATION, &compiledCodeVS, NULL, &uniformVS))) { release(); error(L"APIDisplay::13 Unable to compile vertex shader"); } // create the vertex shader object else if (FAILED(d3dd->CreateVertexShader( (DWORD*)compiledCodeVS->GetBufferPointer(), &vertexShader))) { compiledCodeVS->Release(); release(); error(L"APIDisplay::14 Unable to create vertex shader object"); } else { compiledCodeVS->Release();
d3dd->SetVertexShader(vertexShader);
- APIDisplay.cpp - setProjection()
this->projection = *((Matrix*)projection);
- APIDisplay.cpp - beginDrawFrame()
Matrix& v = *((Matrix*)view); Matrix viewProjection = v * projection; uniformVS->SetMatrix(d3dd, "viewProjection", (D3DXMATRIX*)&viewProjection); Vector heading(v.m13, v.m23, v.m33); // Required for specular lighting calculations uniformVS->SetFloatArray(d3dd, "heading", (FLOAT*)&heading, 3);
Colour colour(red, green, blue); uniformVS->SetFloatArray(d3dd, "ambient", (FLOAT*)&colour, 4); uniformVS->SetInt(d3dd, "noLights", 4);
- APIDisplay.cpp - set()
uniformVS->SetBool(d3dd, "lighting", b);
- APIDisplay.cpp - setWorld()
uniformVS->SetMatrix(d3dd, "world", (D3DXMATRIX*)world);
- APIDisplay.cpp - setReflectivity()
uniformVS->SetFloatArray(d3dd, "material.ambient", (FLOAT*)&r.ambient, 4); uniformVS->SetFloatArray(d3dd, "material.diffuse", (FLOAT*)&r.diffuse, 4); uniformVS->SetFloatArray(d3dd, "material.specular", (FLOAT*)&r.specular, 4); uniformVS->SetFloat (d3dd, "material.power", (FLOAT)r.power);
- APIDisplay.cpp - release()
// release the shader COM objects if (uniformVS) { uniformVS->Release(); uniformVS = nullptr; } if (vertexShader) { vertexShader->Release(); vertexShader = nullptr; }
- APILight.cpp - setup()
// Populate the vertex shader constant table // // Light descriptors within the vertex shader char typ[] = "light[0].type"; char amb[] = "light[0].ambient"; char dif[] = "light[0].diffuse"; char spe[] = "light[0].specular"; char pos[] = "light[0].position"; char dir[] = "light[0].direction"; char spt[] = "light[0].spot"; char att[] = "light[0].attenuation"; char ran[] = "light[0].range"; // // Reset index in light descriptor typ[6] = index + '0'; amb[6] = index + '0'; dif[6] = index + '0'; spe[6] = index + '0'; pos[6] = index + '0'; dir[6] = index + '0'; spt[6] = index + '0'; att[6] = index + '0'; ran[6] = index + '0'; // Populate the vertex shader constant table Vector attenuation(attenuation0, attenuation1, attenuation2); Vector spot(cosf(phi/2), cosf(theta/2), falloff); Vector zero; uniformVS->SetInt(d3dd, typ, type); uniformVS->SetFloatArray(d3dd, amb, (FLOAT*)&ambient, 4); uniformVS->SetFloatArray(d3dd, dif, (FLOAT*)&diffuse, 4); uniformVS->SetFloatArray(d3dd, spe, (FLOAT*)&specular, 4); uniformVS->SetFloatArray(d3dd, pos, (FLOAT*)&zero, 3); uniformVS->SetFloatArray(d3dd, dir, (FLOAT*)&zero, 3); uniformVS->SetFloatArray(d3dd, att, (FLOAT*)&attenuation, 3); uniformVS->SetFloatArray(d3dd, spt, (FLOAT*)&spot, 3); uniformVS->SetFloat(d3dd, ran, range); rc = true;
- APILight.cpp - turnOn()
char constantLightOn[] = "lightOn[0]"; constantLightOn[8] = index + '0'; char pos[] = "light[0].position"; char dir[] = "light[0].direction"; pos[6] = index + '0'; dir[6] = index + '0'; uniformVS->SetFloatArray(d3dd, pos, (FLOAT*)&p, 3); uniformVS->SetFloatArray(d3dd, dir, (FLOAT*)&o, 3); uniformVS->SetBool(d3dd, constantLightOn, true);
- APILight.cpp - update()
char constantLightOn[] = "lightOn[0]"; constantLightOn[8] = index + '0'; char pos[] = "light[0].position"; char dir[] = "light[0].direction"; pos[6] = index + '0'; dir[6] = index + '0'; uniformVS->SetFloatArray(d3dd, pos, (FLOAT*)&p, 3); uniformVS->SetFloatArray(d3dd, dir, (FLOAT*)&o, 3); uniformVS->SetBool(d3dd, constantLightOn, true);
- APILight.cpp - turnOff()
char constantLightOn[] = "lightOn[0]"; constantLightOn[8] = index + '0'; uniformVS->SetBool(d3dd, constantLightOn, false);
- APIGraphic.h - class APIXMesh
D3DXCOLOR* ambient; D3DXCOLOR* diffuse; D3DXCOLOR* specular; FLOAT* power;
- APIGraphic.cpp - APIXMesh()
ambient = nullptr; diffuse = nullptr; specular = nullptr; power = nullptr;
- APIGraphic.cpp - APIXMesh()
ambient = nullptr; diffuse = nullptr; specular = nullptr; power = nullptr;
- APIGraphic.cpp - operator=()
if (ambient) delete [] ambient; if (diffuse) delete [] diffuse; if (specular) delete [] specular; if (power) delete [] power; ambient = new D3DXCOLOR[src.nSubsets]; diffuse = new D3DXCOLOR[src.nSubsets]; specular = new D3DXCOLOR[src.nSubsets]; power = new FLOAT[src.nSubsets];
for (unsigned i = 0; i < nSubsets; i++) { ambient[i] = src.ambient[i]; diffuse[i] = src.diffuse[i]; specular[i] = src.specular[i]; power[i] = src.power[i]; }
- APIGraphic.cpp - setup()
ambient = new D3DXCOLOR[nSubsets]; diffuse = new D3DXCOLOR[nSubsets]; specular = new D3DXCOLOR[nSubsets]; power = new FLOAT[nSubsets];
ambient[i].r = matl[i].MatD3D.Diffuse.r * 0.7f; ambient[i].g = matl[i].MatD3D.Diffuse.g * 0.7f; ambient[i].b = matl[i].MatD3D.Diffuse.b * 0.7f; ambient[i].a = matl[i].MatD3D.Diffuse.a; diffuse[i] = matl[i].MatD3D.Diffuse; // reflected from lights specular[i] = matl[i].MatD3D.Specular; // shine from lights power[i] = matl[i].MatD3D.Power; // 0 if it shouldn't be shiny
- APIGraphic.cpp - draw()
uniformVS->SetFloatArray(d3dd, "material.ambient", (FLOAT*)&ambient[i], 4); uniformVS->SetFloatArray(d3dd, "material.diffuse", (FLOAT*)&diffuse[i], 4); uniformVS->SetFloatArray(d3dd, "material.specular", (FLOAT*)&specular[i], 4); uniformVS->SetFloat(d3dd, "material.power", (FLOAT)power[i]);
- APIGraphic.cpp - suspend()
if (ambient) delete [] ambient; if (diffuse) delete [] diffuse; if (specular) delete [] specular; if (power) delete [] power;
- Device
- Fragment Shader
- Host
- Device