protected virtual void Start() { ppmTexture.Init(200, 100); RTRay ray = new RTRay(); Vector3 origin = Vector3.zero; Vector3 leftBottomCorner = new Vector3(-2, -1, -1); Vector3 horizontal = new Vector3(4, 0, 0); Vector3 vertical = new Vector3(0, 2, 0); for (int j = 0; j < ppmTexture.Height; ++j) { for (int i = 0; i < ppmTexture.Width; ++i) { float u = (float)i / ppmTexture.Width; float v = (float)j / ppmTexture.Height; ray.Set(origin, leftBottomCorner + horizontal * u + vertical * v); Color color = GetColor(ray, 0); ppmTexture.WriteAPixel(color); } } ppmTexture.Complete(); RenderingComplete(); }
public RTRay GetRay(float u, float v) { RTRay ray = new RTRay(); ray.Set(origin, leftBottomCorner + horizontal * u + vertical * v - origin); return(ray); }
public RTRay GetRay(float s, float t) { Vector3 rd = RTMath.RndInUnitSphere() * len_radius; Vector3 offset = u * rd.x + v * rd.y; RTRay ray = new RTRay(); ray.Set(origin + offset, leftBottomCorner + horizontal * s + vertical * t - origin - offset); return(ray); }