1 / 15

GAM531 DPS931 – Week 10

GAM531 DPS931 – Week 10. Meshes and Buffers. Breaking Down An Image. Actors. Actors = Mesh + Material. Mesh = Shape of the object. Breaking Down an Actor. Wireframe Mesh. Mesh + Advanced Material. Breaking Down A Mesh. Vertices. Triangle Face. X Y Z -10 10 -10

Download Presentation

GAM531 DPS931 – Week 10

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GAM531DPS931 – Week 10 Meshes and Buffers

  2. Breaking Down An Image Actors Actors = Mesh + Material Mesh = Shape of the object

  3. Breaking Down an Actor Wireframe Mesh Mesh + Advanced Material

  4. Breaking Down A Mesh Vertices Triangle Face X Y Z -10 10 -10 10 10 -10 10 -10 -10

  5. What Is A Vertex? Class Vertex { [ 0, 10, 0 ] Vector<> pos; Vector<> normal; Vector<float,2> uv; float weight; intboneID; }; [ -7, -7, 0 ] [ 7, -7, 0 ]

  6. How Do Vertices Make A Mesh Vertex Buffer Triangle Triangle Vertex Vertex Vertex Vertex Vertex Vertex [ [ 0, 10, 0 ], [ 7, -7, 0 ], [ -7, -7, 0 ], [ 0, 10, 0 ], [ 7, -7, 0 ], [ 7, -7, -7 ] ]

  7. How Do Vertices Make Triangles? [ 0, 10, 0 ] Winding Order Clock-Wise (Front) Vs Counter Clock-Wise (Back) [ -7, -7, 0 ] [ 7, -7, 0 ]

  8. Triangle Face Culling No Culling Back Face Culling All Face Culling

  9. Vertex Buffer Optimizations [ [ 0, 10, 0 ], [ 7, -7, 0 ], [ -7, -7, 0 ], [ 0, 10, 0 ], [ 7, -7, 0 ], [ 7, -7, -7 ] ] Vertex 1 Vertex 2 Vertex 3 Vertex 1 Vertex 2 Vertex 4 Vertex Buffer Vertex Vertex Vertex Vertex Index Buffer Triangle Triangle Index Index Index Index Index Index

  10. Index Buffer Vertex Buffer (No Index Buffer) [ [ 0, 10, 0 ], [ 7, -7, 0 ], [ -7, -7, 0 ], [ 0, 10, 0 ], [ 7, -7, 0 ], [ 7, -7, -7 ] ] Vertex Buffer[ [ 0, 10, 0 ], [ 7, -7, 0 ], [ -7, -7, 0 ], [ 7, -7, -7 ] ] Index Buffer [ 0, 1, 2, 0, 1, 4 ]

  11. Primitive Types

  12. Programming Buffers D3D11_BUFFER_DESC bd; ZeroMemory(&bd, sizeof(D3D11_BUFFER_DESC)); bd.Usage= //how it will be used (static vs dynamic) bd.CPUAccessFlags= //cpu access bd.ByteWidth= //Size of the buffer bd.BindFlags= //type of buffer dev->CreateBuffer(&bd, 0, &buffer)); bSize= //Size of buffer glGenVertexArrays(1, &vID); //vertex buffer only glBindVertexArray(vID); //vertex buffer only glGenBuffers(1, &bufferID); glBindBuffer(GL_ARRAY_BUFFER,bufferID); //constructs a vertex definition (vertex buffer only) _initVertex(*(constVertexFormat<RS_GL43>*)&v);

  13. Writing to Buffers //sets the buffer to be written to con->Map(buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sub) //write to the buffer Memcpy(sub.pData, someData, dataSizeInBytes); //unmap buffer Con->unmap(buffer, 0); //set buffer to be written glBindVertexArray(vID); glBindBuffer(GL_ARRAY_BUFFER, bufferID); //write to the buffer glBufferData(GL_ELEMENT_ARRAY_BUFFER, dataSizeInBytes, someData, GL_STATIC_DRAW);//GL_DYNAMIC_DRAW glBindBuffer(GL_ARRAY_BUFFER, 0);

  14. Binding Buffers //set vertex buffer con->IASetVertexBuffers(0,1, &buffer, &vSize, &offset); //set index buffer con->IASetIndexBuffer(buffer, DXGI_FORMAT_R32_UINT, 0); //set uniform con->PSSetConstantBuffers(slot, 1, &buffer); con->VSSetConstantBuffers(slot, 1, &buffer); //set vertex buffer glBindVertexArray(vID); glBindBuffer(GL_ARRAY_BUFFER, bufferID); //don’t forget to bind the vertex attributes... //set index buffer glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferID); //bind uniform glBindBufferBase(GL_UNIFORM_BUFFER, slot, bufferID);

  15. To Do • Continue work on engine enhancement • Read this week’s lab • Read this week’s notes • Re-implement OpenGL Device functions

More Related