This page was last updated: December 1, 2019
Project #1 asked you to create your own object in a Vulkan program.
Project #2 asked you to add lighting to it.
Project #3 asked you to use create a scene with an Index Buffer
Project #4 is asking you to use Instancing to make your scene more complex and interesting
Keep the keyboard keys doing what they used to do.
Feel free to add more keyboard inputs to control more things.
'1', '4', '9' | Change how many instances will be seen |
'i' | Toggle using a vertex buffer only vs. a vertex/index buffer |
'l' (ell) | Toggle lighting on and off |
'm' | Toggle display mode (textures vs. colors) |
'r' | Toggle rotation-animation and using the mouse |
Esc, 'q' | Exit the program |
Feel free to add more keyboard inputs if you want.
**************************************************************
const uint32_t vertexCount = sizeof(VertexData) / sizeof(VertexData[0]);
const uint32_t indexCount = sizeof(JustIndexData) / sizeof(JustIndexData[0]);
//const uint32_t instanceCount = 1;
const uint32_t instanceCount = NUM_INSTANCES;
const uint32_t firstVertex = 0;
const uint32_t firstIndex = 0;
const uint32_t firstInstance = 0;
const uint32_t vertexOffset = 0;
if( UseIndexBuffer )
{
vkCmdDrawIndexed( CommandBuffers[nextImageIndex], indexCount, instanceCount, firstIndex, vertexOffset, firstInstance );
}
else
{
vkCmdDraw( CommandBuffers[nextImageIndex], vertexCount, instanceCount, firstVertex, firstInstance );
}
**************************************************************
int NUMINSTANCES = 16;
float DELTA = 3.0;
float xdelta = DELTA * float( gl_InstanceIndex % 4 );
float ydelta = DELTA * float( gl_InstanceIndex / 4 );
vColor = vec3( 1., float( (1.+gl_InstanceIndex) ) / float( NUMINSTANCES ), 0. );
xdelta -= DELTA * sqrt( float(NUMINSTANCES) ) / 2.;
ydelta -= DELTA * sqrt( float(NUMINSTANCES) ) / 2.;
vec4 vertex = vec4( aVertex.xyz + vec3( xdelta, ydelta, 0. ), 1. );
gl_Position = PVM * vertex;
**************************************************************
Use the Teach system to turn in your:
Feature | Points |
---|---|
Did it | 80 |
Didn't screw anything up in the process | 20 |
Potential Total | 100 |