Я пытаюсь реализовать модель фонг молнии в этот фреймворк cpp.
Диффузия работает отлично, но зеркальное отражение, кажется, освещает углы сферы … я не совсем уверен, почему, потому что формаляр кажется правильным. У кого-нибудь есть идея?
На самом деле вывод:
Мой код выглядит так:
Material *material = obj->material; //the hit objects material
Point hit = ray.at(min_t); //the hit point
Vector N = obj->normal(hit); //the normal at hit point
Vector V = -ray.D; //the view vector
Color color = material->color;
double colorFactor = material->ka;
for( size_t i = 0; i < numLights ; ++i)
{
Vector lightsVector = hit - lights[i]->position;
lightsVector.normalize();
Vector vectorReflection = (2*(N.dot(lightsVector))*N) - lightsVector;
vectorReflection.normalize();
double diffusion = std::max<double>(0.0,-material->kd*(lightsVector.dot(N)));
double specular = material->ks*pow(std::max<double>(0.0,vectorReflection.dot(V.normalized())),material->n);
std::cout << specular << std::endl;
colorFactor += diffusion + specular;
}
color *=colorFactor;
Я очень благодарен за любой намек, который вы можете дать мне …
Задача ещё не решена.
Других решений пока нет …