Exemplo n.º 1
0
        public override Color Eval(Normal normal, Vec inDir, Vec outDir, Vec2D uv)
        {
            float thetaIn = MathF.Acos(Utility.NormalizedDot(normal.ToVec(), inDir));
            float thetaOut = MathF.Acos(Utility.NormalizedDot(normal.ToVec(), outDir));

            if (MathF.Abs(thetaIn - thetaOut) < this.thresholdAngleRad)
                return this.pigment.getColor(uv);
            else
                return new Color(0f, 0f, 0f);
        }
Exemplo n.º 2
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
                        );
        }