Hey gang, I'm running into an issue with lighting an object.
I have a Model I'm using to produce a floor, which currently just places 10 by 10 1x1 Surfaces in a flat grid. I also have a light hanging overhead, a Spotlight angled straight down in the center.
As you can see the light cuts off right down the centerline Z axis of the object, leaving a semicircle illuminated. I initially thought this was tied to specific coordinates, however I get the problem wherever I place the object & light. I've tried a Pointlight, with the same results.
The floor is generated in the Attach method of the Model's actor class. Note it creates and attaches a child Model, because this way it can easily be removed and changed on the fly.
Model* m_terrain;
m_terrain = (Model*)this->entity->FindChild("terrain_model");
if (m_terrain != nullptr) m_terrain->Release();
Texture* t = Texture::Load("Materials/Terrain/terrain_theZone_x2plainmud.tex");
t->SetClampMode(true, true);
Shader* s = Shader::Load("Shaders/Model/diffuse.shader");
Material* m = Material::Create();
m->SetShader(s);
m->SetTexture(t);
m->SetBlendMode(Blend::Solid);
m->SetShadowMode(true);
m_terrain = Model::Create(this->entity);
m_terrain->SetKeyValue("name", "terrain_model");
float x, z;
for (x = 0.0; x < 10.0; x++) {
for (z = 0.0; z < 10.0; z++) {
Surface* sur_face = m_terrain->AddSurface();
sur_face->AddVertex(x, 0.0, z, 0, 0, -1);
sur_face->AddVertex(x + 1.0, 0.0, z, 0, 0, -1);
sur_face->AddVertex(x + 1.0, 0.0, z + 1.0, 0, 0, -1);
sur_face->AddVertex(x, 0.0, z + 1.0, 0, 0, -1);
sur_face->SetVertexTexCoords(0, 0, 0, 0);
sur_face->SetVertexTexCoords(1, 1, 0, 0);
sur_face->SetVertexTexCoords(2, 1, 1, 0);
sur_face->SetVertexTexCoords(3, 0, 1, 0);
sur_face->AddTriangle(2, 1, 0);
sur_face->AddTriangle(0, 3, 2);
sur_face->SetMaterial(m);
sur_face->Update();
}
}
m_terrain->SetPosition(Vec3(0.0),false);
m_terrain->SetShadowMode(Light::Static);
m_terrain->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB);
Anybody got ideas for what I'm doing wrong?