int TraceRowJob(int y, int width, int height, NativeArray <Color> backbuffer, ref CameraWrap camera, int frameID) { int rayCount = 0; for (int x = 0; x < width; ++x) { Color color = Color.black; for (int i = 0; i < SAMPLE_PER_PIXEL; ++i) { float u = (x + Random.Range(0, 1.0f)) / width; float v = (y + Random.Range(0, 1.0f)) / height; Ray r = camera.GetRay(u, v); color += Trace(ref r, 0, ref rayCount, null); } color /= SAMPLE_PER_PIXEL; color = color.gamma; var old = backbuffer[y * width + x]; backbuffer[y * width + x] = (old * (frameID - 1) + color) / frameID; } return(rayCount); }
public void PixelDebug(CameraWrap camera, float u, float v) { var infos = new List <Vector3>(); Ray r = camera.GetRay(u, v); int rayCount = 0; infos.Add(r.origin); Trace(ref r, 0, ref rayCount, infos); for (int i = 0; i < infos.Count - 2; ++i) { Debug.DrawLine(infos[i], infos[i + 1], Color.red, 10); } if (infos.Count >= 2) { Debug.DrawRay(infos[infos.Count - 2], infos[infos.Count - 1], Color.red, 10); } }