예제 #1
0
 public SdfSmoothUnion(ISdfObject a, ISdfObject b, double blend, Color color)
 {
     A          = a;
     B          = b;
     Blend      = blend;
     this.color = color;
 }
예제 #2
0
 public SdfBlend(ISdfObject a, ISdfObject b, double blend)
 {
     A     = a;
     B     = b;
     Blend = blend;
     color = Color.White;
 }
예제 #3
0
 public SdfSmoothUnion(ISdfObject a, ISdfObject b, double blend)
 {
     A     = a;
     B     = b;
     Blend = blend;
     color = a.ObjectColor;
 }
예제 #4
0
파일: Scene.cs 프로젝트: Tygrak/RayMarcher
        private Color PointToColorFakeShadows(Point3d hitPoint)
        {
            ISdfObject sdfObject = ClosestObject(hitPoint);
            Point3d    normal    = new Point3d(
                (hitPoint + new Point3d(0.001, 0, 0)).DistanceFromSdfObject(sdfObject) - (hitPoint - new Point3d(0.001, 0, 0)).DistanceFromSdfObject(sdfObject),
                (hitPoint + new Point3d(0, 0.001, 0)).DistanceFromSdfObject(sdfObject) - (hitPoint - new Point3d(0, 0.001, 0)).DistanceFromSdfObject(sdfObject),
                (hitPoint + new Point3d(0, 0, 0.001)).DistanceFromSdfObject(sdfObject) - (hitPoint - new Point3d(0, 0, 0.001)).DistanceFromSdfObject(sdfObject)
                ).VectorNormalize();
            double NdotL = LambertNdotL(normal, GlobalLight);

            NdotL = NdotL > GlobalIllumination ? NdotL : GlobalIllumination;
            return(Color.FromArgb((int)(sdfObject.ObjectColor.R * NdotL), (int)(sdfObject.ObjectColor.G * NdotL), (int)(sdfObject.ObjectColor.B * NdotL)));
        }
예제 #5
0
파일: Scene.cs 프로젝트: Tygrak/RayMarcher
        private Color PointToColorRayShadows(Point3d hitPoint)
        {
            ISdfObject sdfObject = ClosestObject(hitPoint);
            Point3d    normal    = new Point3d(
                (hitPoint + new Point3d(0.001, 0, 0)).DistanceFromSdfObject(sdfObject) - (hitPoint - new Point3d(0.001, 0, 0)).DistanceFromSdfObject(sdfObject),
                (hitPoint + new Point3d(0, 0.001, 0)).DistanceFromSdfObject(sdfObject) - (hitPoint - new Point3d(0, 0.001, 0)).DistanceFromSdfObject(sdfObject),
                (hitPoint + new Point3d(0, 0, 0.001)).DistanceFromSdfObject(sdfObject) - (hitPoint - new Point3d(0, 0, 0.001)).DistanceFromSdfObject(sdfObject)
                ).VectorNormalize();
            Point3d lightPoint = hitPoint + (GlobalLight) * renderDistance;

            (double distance, int steps, Point3d lightHitPoint) = RayMarch(lightPoint, hitPoint, renderDistance * 2);
            double light = (hitPoint - lightHitPoint).VectorLength();

            light = (1 - Math.Min(light, 1.0)) / 1;
            light = light > GlobalIllumination ? light : GlobalIllumination;
            return(Color.FromArgb((int)(sdfObject.ObjectColor.R * light), (int)(sdfObject.ObjectColor.G * light), (int)(sdfObject.ObjectColor.B * light)));
        }
예제 #6
0
파일: Scene.cs 프로젝트: Tygrak/RayMarcher
        private ISdfObject ClosestObject(Point3d point)
        {
            if (objects.Count == 0)
            {
                return(null);
            }
            ISdfObject closest = objects[0];
            double     min     = point.DistanceFromSdfObject(objects[0]);

            for (int i = 1; i < objects.Count; i++)
            {
                double dist = point.DistanceFromSdfObject(objects[i]);
                if (min > dist)
                {
                    min     = dist;
                    closest = objects[i];
                }
            }
            return(closest);
        }
예제 #7
0
 public SdfRepetition(ISdfObject primitive, double repetitionDistance)
 {
     Primitive          = primitive;
     RepetitionDistance = new Point3d(repetitionDistance, repetitionDistance, repetitionDistance);
 }
예제 #8
0
 public SdfRotation(ISdfObject primitive, Point3d rotation)
 {
     Primitive = primitive;
     Rotation  = rotation;
 }
예제 #9
0
 public SdfOnion(ISdfObject primitive, double thickness)
 {
     Primitive = primitive;
     Thickness = thickness;
 }
예제 #10
0
 public SdfUnion(ISdfObject a, ISdfObject b)
 {
     A     = a;
     B     = b;
     color = a.ObjectColor;
 }
예제 #11
0
 public SdfSliceXZ(ISdfObject primitive)
 {
     Primitive = primitive;
 }
예제 #12
0
 public SdfSmoothSubtraction(ISdfObject a, ISdfObject b, double blend)
 {
     A     = a;
     B     = b;
     Blend = blend;
 }
예제 #13
0
 public SdfIntersection(ISdfObject a, ISdfObject b, Color color)
 {
     A          = a;
     B          = b;
     this.color = color;
 }
예제 #14
0
 public SdfIntersection(ISdfObject a, ISdfObject b)
 {
     A     = a;
     B     = b;
     color = a.ObjectColor;
 }
예제 #15
0
 public SdfRepetition(ISdfObject primitive, Point3d repetitionDistance)
 {
     Primitive          = primitive;
     RepetitionDistance = repetitionDistance;
 }
예제 #16
0
 public SdfTranslation(ISdfObject primitive, Point3d translation)
 {
     Primitive   = primitive;
     Translation = translation;
 }
예제 #17
0
 public double DistanceFromSdfObject(ISdfObject sdfObject)
 {
     return(sdfObject.DistanceFromPoint(this));
 }
예제 #18
0
 public SdfElongation(ISdfObject primitive, Point3d elongation)
 {
     Primitive  = primitive;
     Elongation = elongation;
 }
예제 #19
0
 public SdfUnion(ISdfObject a, ISdfObject b, Color color)
 {
     A          = a;
     B          = b;
     this.color = color;
 }
예제 #20
0
 public SdfSubtraction(ISdfObject a, ISdfObject b)
 {
     A = a;
     B = b;
 }