This commit is contained in:
Branimir Karadžić 2016-07-24 15:50:42 -07:00
parent f56cf4c88e
commit 5b3c9609cb

View File

@ -66,6 +66,16 @@
#define SHADOW_MAP_DIM 512
#define LIGHT_DIST 10.0f
static const char * m_meshPaths[MESH_COUNT] =
{
"meshes/cube.bin",
"meshes/orb.bin",
"meshes/column.bin",
"meshes/bunny.bin",
"meshes/tree.bin",
"meshes/hollowcube.bin"
};
// Vertex decl for our screen space quad (used in deferred rendering)
struct PosTexCoord0Vertex
{
@ -318,9 +328,11 @@ class ExampleReflectiveShadowMap : public entry::AppI
int shutdown() BX_OVERRIDE
{
for (uint32_t i = 0; i < MESH_COUNT; i++) {
for (uint32_t i = 0; i < MESH_COUNT; i++)
{
meshUnload(m_meshes[i]);
}
meshUnload(m_ground);
meshUnload(m_lightSphere);
@ -553,8 +565,10 @@ class ExampleReflectiveShadowMap : public entry::AppI
return false;
}
void drawAllModels(uint8_t _pass, bgfx::ProgramHandle _program) {
for (const Model & m : m_models) {
void drawAllModels(uint8_t _pass, bgfx::ProgramHandle _program)
{
for (const Model & m : m_models)
{
// Set up transform matrix for each model
float scale = m_meshScale[m.mesh];
float mtx[16];
@ -576,7 +590,7 @@ class ExampleReflectiveShadowMap : public entry::AppI
}
// Draw ground
const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
const float white[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
bgfx::setUniform(u_tint, white);
float mtxScale[16];
float scale = 10.0;
@ -596,7 +610,8 @@ class ExampleReflectiveShadowMap : public entry::AppI
meshSubmit(m_ground, _pass, _program, mtx);
}
void updateLightDir () {
void updateLightDir()
{
float el = m_lightElevation * (bx::pi/180.0f);
float az = m_lightAzimuth * (bx::pi/180.0f);
m_lightDir[0] = cos(el)*cos(az);
@ -653,7 +668,8 @@ class ExampleReflectiveShadowMap : public entry::AppI
// UI
bool m_cameraSpin = false;
struct Model {
struct Model
{
uint32_t mesh; // Index of mesh in m_meshes
float color[4];
float position[3];
@ -661,15 +677,6 @@ class ExampleReflectiveShadowMap : public entry::AppI
Model m_models[MODEL_COUNT];
const char * m_meshPaths[MESH_COUNT] = {
"meshes/cube.bin"
,"meshes/orb.bin"
,"meshes/column.bin"
,"meshes/bunny.bin"
,"meshes/tree.bin"
,"meshes/hollowcube.bin"
};
// Light position;
float m_lightDir[4];
float m_lightElevation = 35.0f;