Presentation is loading. Please wait.

Presentation is loading. Please wait.

GAM531 DPS931 – Week 10 Meshes and Buffers. Breaking Down An Image Actors Actors = Mesh + Material Mesh = Shape of the object.

Similar presentations


Presentation on theme: "GAM531 DPS931 – Week 10 Meshes and Buffers. Breaking Down An Image Actors Actors = Mesh + Material Mesh = Shape of the object."— Presentation transcript:

1 GAM531 DPS931 – Week 10 Meshes and Buffers

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

3 Breaking Down an Actor Mesh + Advanced Material Wireframe Mesh

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

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

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

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

8 Triangle Face Culling No CullingBack Face CullingAll 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 Index Buffer Triangle 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 ] ] Index Buffer [ 0, 1, 2, 0, 1, 4 ] Vertex Buffer [ [ 0, 10, 0 ], [ 7, -7, 0 ], [ -7, -7, 0 ], [ 7, -7, -7 ] ]

11 Primitive Types

12 Programming Buffers 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(*(const VertexFormat *)&v); 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));

13 Writing to Buffers //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); //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);

14 Binding Buffers //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); //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);

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


Download ppt "GAM531 DPS931 – Week 10 Meshes and Buffers. Breaking Down An Image Actors Actors = Mesh + Material Mesh = Shape of the object."

Similar presentations


Ads by Google