|
|
So how would *I* implement a raytracing API?
1. Basic primitive would be "object" or "node", terminology doesn't matter just the principle that we have objects which have services the tracer can use. The most basic service would be to intersect a ray with the object, and handle the intersection.
I would have controls to change the transformations of the objects in different frames of reference, scale, rotate, translate, the usual stuff you can do in a 4x4 matrix.
This arrangement would give headroom to implement the "object" anyway imaginable, to place acceleration at different levels.
2. Grouping of primitive types. Primitive type, object, could be "trimesh", "nurbs surface" or "triangle list" (trimesh would actually just be list of "triangle list"'s with associated properties).
This begins to sound more and more like OpenInventor, doesn't it?
This is the level where ray-tracing engine would be best implemented in, not in the "vertex-triangle-material" -level, because that's too little information for raytracer to be efficient.
..
Now to the practise. The raytracers I wrote before pretty much been "triangle soup" renderers.. I take this pre-transformed, in-worldspace triangle soup, where each triangle has pointer to material and such quite trivial basic arrangement. Because never needed to be a bit more "advanced". Even the latest traver, which I didn't write, but we use where I work at, is using the same basic scheme.. it's just used to calculate preprocessed lighting (lightmaps you could say) for datasets we use in realtime productions.
The stuff is really simple, I'm first to admit that, but it gets the work done before the universe collapses, so that's good. ;-)
Now when I think that I have the whole scene.. I go and describe it primitive-by-primitive to the DirectX 8 when rendering (only parts which contribute to the image), it works in realtime. That's something we can live with. When raytracing, *every* primitive does contribute to the image, or atleast, we cannot be sure before the part is required. With DirectX/GL like API we just must bend and send everything in, because we can't request it when it's needed. This is overhead I can't see how it could be acceptable with very high-density scenes.
I believe firmly on the lazy evaluation principle, but I guess I'm the stupid one.
I'd be much more inclined to think that it would be nice, if the tracin' API could capture the scene. OK, the description could be procedural, through API calls, fine. You could modify the scene through API calls, again, fine.
But scene description and rendering should be kept separate interfaces. I think that's what should be the ticket.
... my opinion only, as usual, wrong. ;-)
|