curv3d / curv

a language for making art using mathematics
Apache License 2.0
1.14k stars 73 forks source link

POV-Ray export feature #70

Closed wadewadewadewadewadewade closed 5 years ago

wadewadewadewadewadewade commented 5 years ago

For those users wanting a print-worthy export, you could add an export function for Persistence of Vision Ray Tracer. I've used it back in the 90s to generate 300DPI images for giant prints that can be printed on photo paper by a a Lightjet 430, and they turned out great! And POVray uses constructive solid geometry as well as polygon and polynomial forms with a simple text-based file input format. http://www.povray.org/

Just a suggestion for fellow digital artists...

doug-moen commented 5 years ago

It's an interesting idea. I don't have any experience with povray, and I am not sure if it is possible to export Curv shapes to Povray in the general case.

Looking at the documentation, I see that Povray has isosurface objects, which use the same representation as Curv shapes. In theory, we could compile a Curv shape's distance function into a Povray function, then put the resulting distance function into a Povray isosurface object. But is povray powerful enough? Do Povray functions support conditional expressions and recursion? Because it's not clear that this is supported.

wadewadewadewadewadewade commented 5 years ago

To be honest, I've never used an isosurface object before. But to answer your question about recursion, povray is more like xml markup than a scripting language. So you'd have to dump out a file with everything built already and then povray could run it's raytracing on that static file. Does that make sense?

doug-moen commented 5 years ago

So you'd have to dump out a file with everything built already and then povray could run it's raytracing on that static file. Does that make sense?

Sorry, I'm not sure how to do that. Curv supports a lot of interesting shape operations, not just boolean CSG operations, but also non-affine transformations like bend and twist. You can construct procedurally generated textures, you can build or transform shapes using fractal noise, you can make traditional 3D fractals like the MandelBulb using IFS (iterated function systems). And these operations can all be composed together. This flexibility is obtained by representing all shapes using signed distance fields. A lot of this expressive power seems to be missing from povray, unless you write code inside of an isosurface object.

Curv compiles every scene into a single signed distance function before rendering it, either displaying it on the screen, or converting it to a mesh file for 3D printing. A lot of the power of Curv comes from the ability to write iterative code inside a signed distance function. If povray doesn't support recursive functions, then you can't iterate inside a povray isosurface object, and that would mean many of the shapes in the examples directory cannot be translated into povray.

doug-moen commented 5 years ago

I think we do want to leverage existing open source software to allow Curv shapes to be raytraced. But I'm not sure if povray is the best solution.

doug-moen commented 5 years ago

One possibility is to create a fork of PovRay that lets you embed Curv code in a PovRay source file.

There's lots of buzz about real time raytracing on a GPU right now. Maybe there is an open source raytracer that runs on a GPU, that can be integrated with Curv.

wadewadewadewadewadewade commented 5 years ago

I've read that the Unity game engine is or has added support for the Nvidia RTX real-time stuff. I don't know if OpenGL/WebGL in the browser supports it, but maybe that will be an option too.

I get it tho about povray. It sounds like you dump a file for some other packages, so that's probably good until someone asks for povray support. No need to write code that nobody will use, right? :)

On Wed, Mar 20, 2019, 11:05 AM Doug Moen notifications@github.com wrote:

One possibility is to create a fork of PovRay that lets you embed Curv code in a PovRay source file.

There's lots of buzz about real time raytracing on a GPU right now. Maybe there is an open source raytracer that runs on a GPU, that can be integrated with Curv.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/curv3d/curv/issues/70#issuecomment-474962468, or mute the thread https://github.com/notifications/unsubscribe-auth/AWMT-vIwgNrmmrBpfKfL0JlMe5DH7Nl7ks5vYnhQgaJpZM4b8dBS .

doug-moen commented 5 years ago

I don't think that POV-Ray export is going to work. And I don't see there is another POV-Ray like ray tracing tool that supports the full range of SDF based geometry and geometric transformations that Curv has. So I think this feature request is a dead end.

Other users have asked for more sophisticated rendering inside of Curv itself. See issue #73.