예제 #1
0
            public void Execute()
            {
                var nx = (float)size.x;
                var ny = (float)size.y;

                // TODO - make this a CameraFrame input / default
                var lowerLeftCorner = new float3(-2, -1, -1);
                var horizontal      = new float3(4, 0, 0);
                var vertical        = new float3(0, 2, 0);
                var origin          = new float3();

                for (float j = 0; j < size.y; j++)
                {
                    for (float i = 0; i < size.x; i++)
                    {
                        float  u   = i / nx;
                        float  v   = j / ny;
                        Ray    r   = new Ray(origin, lowerLeftCorner + u * horizontal + v * vertical);
                        float3 col = Color(r, World);

                        var index = (int)(j * nx + i);
                        Pixels[index] = col.ToRgb24();
                    }
                }
            }
예제 #2
0
            public void Execute()
            {
                var nx = (float)size.x;
                var ny = (float)size.y;

                for (float j = 0; j < size.y; j++)
                {
                    var rowIndex = j * nx;
                    for (float i = 0; i < size.x; i++)
                    {
                        var    index = (int)(rowIndex + i);
                        float3 col   = new float3();
                        for (int s = 0; s < numberOfSamples; s++)
                        {
                            float u = (i + random.NextFloat()) / nx;
                            float v = (j + random.NextFloat()) / ny;
                            Ray   r = camera.GetRay(u, v);
                            col += Color(r, World);
                        }

                        col          /= (float)numberOfSamples;
                        Pixels[index] = col.ToRgb24();
                    }
                }
            }
예제 #3
0
            public void Execute()
            {
                var nx = (float)size.x;
                var ny = (float)size.y;

                for (var j = 0; j < size.y; j++)
                {
                    var rowIndex = j * nx;
                    for (var i = 0; i < size.x; i++)
                    {
                        var col   = new float3(i / nx, j / ny, 0.2f);
                        var index = (int)(rowIndex + i);
                        Pixels[index] = col.ToRgb24();
                    }
                }
            }