Exemplo n.º 1
0
	plane(const cv::Vec3f& point, const cv::Vec3f& normal)
	{
		a = normal[0];
		b = normal[1];
		c = normal[2];
		d = -(point.dot(normal));
	}
Exemplo n.º 2
0
	plane(const cv::Vec3f& point1, const cv::Vec3f& point2, const cv::Vec3f& point3)
	{
		cv::Vec3f v1 = point2 - point1;
		cv::Vec3f v2 = point3 - point1;
		cv::Vec3f normal = (v1.cross(v2));
		normal /= cv::norm(normal, cv::NORM_L2);

		a = normal[0];
		b = normal[1];
		c = normal[2];
		d = -(point1.dot(normal));
	}
Exemplo n.º 3
0
Path Renderer::createPath(const Ray& primaryRay, const Intersectable &scene, const Sample pathSamples[], cv::Vec3f alpha, int pathLength, float russianRoulettePdf, int russianRouletteStartIndex)
{
  Path result;
  HitRecord hit = scene.intersect(primaryRay);
  for(int i = 0; i < pathLength; i++)
  {
    if(!hit.intersects()) return result;


    float pdf;
    cv::Vec3f brdf;
    QVector3D outDirection = hit.getMaterial().outDirection(hit, pathSamples[i], pdf, brdf);
    if(hit.getMaterial().emitsLight())
    {
        result.alphaValues.push_back(alpha);
        result.hitRecords.push_back(hit);
        return result;
    }
    else if(hit.getMaterial().isSpecular())
    {
        //Try not to terminate on refractive vertices
        if(i == pathLength - 1 && pathLength < MAX_DEPTH) pathLength++;
    }
    else
    {
      result.alphaValues.push_back(alpha);
      result.hitRecords.push_back(hit);
      if(pdf == 0 || alpha == cv::Vec3f()) return result;
      float cos = fabs(QVector3D::dotProduct(outDirection.normalized(), hit.getSurfaceNormal().normalized()));
      assert(cos >= 0 && !isnan(pdf));
      assert(pdf > 0 && !isnan(pdf));
      alpha = alpha.mul(brdf) * (cos / pdf);
      if(i > russianRouletteStartIndex) alpha *= (1 / russianRoulettePdf);
    }
    hit = scene.intersect(Ray(hit.getIntersectingPoint(), outDirection));
  }
  return result;
}
Exemplo n.º 4
0
float Utility::vecAngle(cv::Vec3f& v1, cv::Vec3f& v2) {
	float cosVal = v1.dot(v2);
	return std::acos(cosVal) * 57.29578049;
}