Beispiel #1
0
 /// <summary>
 /// Basic constructor for the class.
 /// </summary>
 /// <param name="i"><see cref="HdrImage"/> input parameter</param>
 /// <param name="c"><see cref="Camera"/> input parameter</param>
 public ImageTracer(HdrImage i, Camera c, int sps = 0)
 {
     this.image          = i;
     this.camera         = c;
     this.pcg            = new PCG();
     this.samplesPerSide = sps;
 }
Beispiel #2
0
 public PathTracer(World world, Color? bkg = null, PCG? pcg = null, int numOfRays = 10, int maxDepth = 3, int russianRouletteLimit = 2) : base(world, bkg)
 {
     this.pcg = pcg ?? new PCG();
     this.numOfRays = numOfRays;
     this.maxDepth = maxDepth;
     this.russianRouletteLimit = russianRouletteLimit;
 }
Beispiel #3
0
        public override Ray scatterRay(PCG r, Vec incomingDir, Point interactionPoint, Normal normal, int depth)
        {
            Vec rayDir = new Vec(incomingDir.x, incomingDir.y, incomingDir.z).Normalize();
            Vec normalVec = normal.ToVec().Normalize();
            float dotProd = normalVec * rayDir;

            return new Ray(
                            origin: interactionPoint,
                            dir: rayDir - normalVec * 2f * dotProd,
                            tm: 1e-5f,
                            tM: Single.PositiveInfinity,
                            dep: depth
                        );
        }
Beispiel #4
0
        public override Ray scatterRay(PCG r, Vec incomingDir, Point interactionPoint, Normal normal, int depth)
        {
            List<Vec> a = normal.createONBfromZ();
            Vec e1 = a[0];
            Vec e2 = a[1];
            Vec e3 = a[2];

            float cosThetaSq = r.randomFloat();
            float cosTheta = MathF.Sqrt(cosThetaSq);
            float sinTheta = MathF.Sqrt(1.0f - cosThetaSq);
            float phi = 2 * MathF.PI * r.randomFloat();

            Vec dir = e1 * sinTheta * MathF.Cos(phi) + e2 * sinTheta * MathF.Sin(phi) + e3 * cosTheta;

            return new Ray(interactionPoint, dir, tm: 1e-5f, dep: depth);

        }
Beispiel #5
0
 public abstract Ray scatterRay(PCG pcg, Vec incomingDir, Point interactionPoint, Normal normal, int depth);