Esempio n. 1
0
        public static RefractiveDispersiveMaterial Diamond(double refractionAttenuation = DefaultRefractionAttenuation)
        {
            RefractionIndex red   = RefractionIndex.Diamond(Light.RedWavelength);
            RefractionIndex green = RefractionIndex.Diamond(Light.GreenWavelength);
            RefractionIndex blue  = RefractionIndex.Diamond(Light.BlueWavelength);

            return(new RefractiveDispersiveMaterial(red, green, blue, refractionAttenuation));
        }
Esempio n. 2
0
 public RefractiveDispersiveMaterial(RefractionIndex redRefractionIndex,
                                     RefractionIndex greenRefractionIndex, RefractionIndex blueRefractionIndex,
                                     double refractionAttenuation = DefaultRefractionAttenuation)
 {
     this.RedRefractionIndex    = redRefractionIndex;
     this.GreenRefractionIndex  = greenRefractionIndex;
     this.BlueRefractionIndex   = blueRefractionIndex;
     this.RefractionAttenuation = refractionAttenuation;
 }
Esempio n. 3
0
        public double3 RefractRay(Scene scene, Traceable traceable,
                                  IntersectData data, Ray ray, TraceData traceData,
                                  double3 n, double nDotRay,
                                  RefractionIndex refractionIndex, out bool traceDataExceed)
        {
            traceDataExceed = false;
            double criticalAngleCos = nDotRay <= 0 ? refractionIndex.CriticalInAngleCos : refractionIndex.CriticalOutAngleCos;

            if (Math.Abs(nDotRay) >= criticalAngleCos)
            {
                if (traceData.Refractions > 0)
                {
                    double  k            = nDotRay <= 0 ? refractionIndex.CoefficientIn : refractionIndex.CoefficientOut;
                    double3 f            = ray.l.RefractI(n, nDotRay, k);
                    double3 p            = traceable.Advance(data.P, f);
                    Ray     refractedRay = new Ray(p, f);
                    traceData = traceData.GetRefracted();
                    double3 color = scene.Trace(refractedRay, traceData);

                    return(RefractionAttenuation * color);
                }
                else
                {
                    TraceData.RefractionLimitExceedCount++;
                    traceDataExceed = true;

                    return(TraceData.RefractionLimitExceedColor);
                }
            }
            else
            {
                if (traceData.Reflections > 0)
                {
                    double3 r            = ray.l.ReflectI(n, nDotRay);
                    double3 p            = traceable.Advance(data.P, r);
                    Ray     reflectedRay = new Ray(p, r);
                    traceData = traceData.GetReflected();
                    double3 color = scene.Trace(reflectedRay, traceData);

                    return(RefractionAttenuation * color);
                }
                else
                {
                    TraceData.ReflectionLimitExceedCount++;
                    traceDataExceed = true;

                    return(TraceData.ReflectionLimitExceedColor);
                }
            }
        }
 public RefractiveMaterial(double refractionAttenuation = DefaultRefractionAttenuation,
                           double refractionIndex       = DefaultRefractionIndex)
 {
     this.RefractionAttenuation = refractionAttenuation;
     this.RefractionIndex       = new RefractionIndex(refractionIndex);
 }