static const uint32_t indices[] = {
0, 1, 2, 2, 3, 0
};
static const float3 vertices[] = {
{-10.0f, 0, -10.0f},
{-10.0f, 0, 10.0f},
{ 10.0f, 0, 10.0f},
{ 10.0f, 0, -10.0f}
};
// Create tangent frame for ground plane
short4 tbn = packSnorm16(
mat3f::packTangentFrame(
mat3f{
float3{1.0f, 0.0f, 0.0f}, // tangent
float3{0.0f, 0.0f, 1.0f}, // bitangent
float3{0.0f, 1.0f, 0.0f} // normal
}
).xyzw);
static const short4 normals[] = {tbn, tbn, tbn, tbn};
VertexBuffer* vertexBuffer = VertexBuffer::Builder()
.vertexCount(4)
.bufferCount(2)
.attribute(VertexAttribute::POSITION, 0,
VertexBuffer::AttributeType::FLOAT3)
.attribute(VertexAttribute::TANGENTS, 1,
VertexBuffer::AttributeType::SHORT4)
.normalized(VertexAttribute::TANGENTS)
.build(*engine);
vertexBuffer->setBufferAt(*engine, 0,
VertexBuffer::BufferDescriptor(vertices, sizeof(vertices)));
vertexBuffer->setBufferAt(*engine, 1,
VertexBuffer::BufferDescriptor(normals, sizeof(normals)));
IndexBuffer* indexBuffer = IndexBuffer::Builder()
.indexCount(6)
.build(*engine);
indexBuffer->setBuffer(*engine,
IndexBuffer::BufferDescriptor(indices, sizeof(indices)));