Пример #1
0
/*
 Get ray is a method which returns a ray whose origin is in the right place which passes through a certain pixel of the pixel frame.
 When using depth of field the
 The two tasks too perform are 1, choose an origin, 2, choose a direction
 The origin lies on the imaging plane,
 
 Depth of field approximations are nominally done by:
 Find calculate eye through image plane line
 then find the claculated image plane through focal point line;
 with a fixed focal point we can then jitter on the image plane, this in turn yeilds the correct behavior.
 location on the image plane is given by: imagePlane = center point of the image plane
 imagePlane - width/2 = left edge
 imagePlane - height/2 = bottom edge
 + instead is upper edges
 then goal: convert pixels => real units:
 pixels/pixelTotal*realUnitsTotal
 */
ray camera::getRay(int px, int py){
    //find the center of the pixel we're going to be collecting light from
  double xLoc = (px+.5+linearAdjust(.5))/(double)x*width;
  double yLoc = (py+.5+linearAdjust(.5))/(double)y*height;
  vec3d imLoc = imBL+Up*yLoc+Right*xLoc;
    
    return makeRay(imLoc);
};
Пример #2
0
ray camera::getRayStrat(int px, int py, int subray, int subrayMax){
    //find the center of the pixel we're going to be collecting light from
    int subx = subray%subrayMax;
    int suby = subray/subrayMax;
    double xLoc = ((px) +(subx+.5 +linearAdjust(.5))/(double)subrayMax )/(double)x*width;
    double yLoc = ((py) +(suby+.5+linearAdjust(.5))/(double)subrayMax )/(double)y *height;
    vec3d imLoc = imBL+Up*yLoc+Right*xLoc;
    return  makeRay(imLoc);
    //this jitter needs to be moved into the Up, Right basis:
};
Пример #3
0
Color sceneTraceRayAtPixel(const Scene *scene, const int currentPixel, const int width, const int height, const int numCameraRayBounces) {
	
	const float cameraFov = 40;
	const float cameraAspectRatio = 1;

	float maxX = tanf(cameraFov/360.0*PI);
	float x =  ((((currentPixel % width) + randf()) / width ) * 2 - 1) * maxX;
	float y = -((((currentPixel / width) + randf()) / height) * 2 - 1) * maxX / cameraAspectRatio;

	return sceneTraceRay(scene, mrMul(mInversed(scene->cameraOrientation), makeRay(makeVectorOrigo(), vNormalized(makeVector(x, y, 1)))), numCameraRayBounces);
}
Пример #4
0
DebugShape& DebugDrawer::DrawPlane(const Plane& plane, float sizeX, float sizeY)
{
  DebugShape& shape = GetNewShape();
  Math::Vector3 right;
  Math::Vector3 up;
  Math::GenerateOrthonormalBasis(plane.GetNormal(), &up, &right);
  
  Math::Vector3 center = plane.GetNormal() * plane.mData.w;

  shape.mSegments = makeRay(Ray(center, plane.GetNormal()), (sizeX + sizeY)/2.0f);

  shape.mSegments.push_back(LineSegment(center - (up * (sizeY / 2.0f)), center - (right * (sizeX / 2.0f))));
  shape.mSegments.push_back(LineSegment(center - (up * (sizeY / 2.0f)), center + (right * (sizeX / 2.0f))));
  shape.mSegments.push_back(LineSegment(center + (up * (sizeY / 2.0f)), center - (right * (sizeX / 2.0f))));
  shape.mSegments.push_back(LineSegment(center + (up * (sizeY / 2.0f)), center + (right * (sizeX / 2.0f))));
  return shape;
}
Пример #5
0
DebugShape& DebugDrawer::DrawRay(const Ray& ray, float t)
{
  DebugShape& shape = GetNewShape();
  shape.mSegments = makeRay(ray, t);
  return shape;
}
Пример #6
0
Ray mrMul(const Matrix matrix, const Ray ray) {

	return makeRay(mvMul(matrix, ray.origin), vNormalized(mvMulDir(matrix, ray.direction)));
}