Abstergo Posted October 9, 2019 Share Posted October 9, 2019 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? Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted October 12, 2019 Solution Share Posted October 12, 2019 You are using (0,0,-1) for your normals. Try using (0,1,0). Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Abstergo Posted October 12, 2019 Author Share Posted October 12, 2019 Thanks Josh, that did the trick. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.