Exemplo n.º 1
0
    private void LinearScanner(object o)
    {
        ScannerCofig config = (ScannerCofig)o;

        for (int j = 0; j < config.height; j++)
        {
            for (int i = 0; i < config.width; i++)
            {
                Vector3D color = new Vector3D(0, 0, 0);
                double   u     = (double)(i + Tools.RandomDouble()) / (double)width;
                double   v     = 1 - (double)(j + Tools.RandomDouble()) / (double)height;
                Ray      ray   = camera.GetRay(u, v);
                color = GetColor(ray, world, 0);
                // color = new Vector3D(Math.Sqrt(color.X), Math.Sqrt(color.Y), Math.Sqrt(color.Z));//这里不应进行伽马校正
                SetPixel(i, j, color);
            }
        }
    }
Exemplo n.º 2
0
    private void LinearScanner(object o)
    {
        ScannerCofig config = (ScannerCofig)o;

        for (int j = 0; j < config.height; j++)
        {
            for (int i = 0; i < config.width; i++)
            {
                Vector3D color = new Vector3D(0, 0, 0);
                float    u     = (float)(i + Mathf.Randomfloat()) / (float)width;
                float    v     = 1 - (float)(j + Mathf.Randomfloat()) / (float)height;
                Ray      ray   = camera.GetRay(u, v);
                color = GetColor(ray, world, 0);
                //color = new Vector3D(Mathf.Sqrt(color.X), Mathf.Sqrt(color.Y), Mathf.Sqrt(color.Z));//这里不应进行伽马校正
                SetPixel(i, j, color);
            }
        }
    }
Exemplo n.º 3
0
    private void LinearScanner(object o)
    {
        ScannerCofig config = (ScannerCofig)o;

        for (int j = 0; j < config.height; j++)
        {
            for (int i = 0; i < config.width; i++)
            {
                Vector3D color = new Vector3D(0, 0, 0);
                float    u     = (float)(i + Mathf.Randomfloat()) / (float)width;
                float    v     = 1 - (float)(j + Mathf.Randomfloat()) / (float)height;
                Ray      ray   = camera.GetRay(u, v);
                color = DeNaN(GetColor(ray, world, scene.LightShapeList, 0));
                if (!scene.Gamma)
                {
                    color = new Vector3D(Mathf.Sqrt(color.X), Mathf.Sqrt(color.Y), Mathf.Sqrt(color.Z));
                }
                SetPixel(i, j, color);
            }
        }
    }
Exemplo n.º 4
0
    private void LinearScanner(object o)
    {
        ScannerCofig config      = (ScannerCofig)o;
        Hitable      lightShape  = new XZRect(213, 343, 227, 332, 554, null);
        Hitable      glassSphere = new Sphere(new Vector3D(190, 90, 190), 90, null);

        for (int j = 0; j < config.height; j++)
        {
            for (int i = 0; i < config.width; i++)
            {
                Vector3D       color = new Vector3D(0, 0, 0);
                float          u     = (float)(i + Mathf.Randomfloat()) / (float)width;
                float          v     = 1 - (float)(j + Mathf.Randomfloat()) / (float)height;
                Ray            ray   = camera.GetRay(u, v);
                List <Hitable> a     = new List <Hitable>();
                a.Add(lightShape);
                a.Add(glassSphere);
                HitableList hitableList = new HitableList(a);
                color = DeNaN(GetColor(ray, world, hitableList, 0));
                color = new Vector3D(Mathf.Sqrt(color.X), Mathf.Sqrt(color.Y), Mathf.Sqrt(color.Z));
                SetPixel(i, j, color);
            }
        }
    }