Twilight POV
A custom modification of PovRay.

Focused on allowing functional distortions of regular objects.

By Jeff M. Thomas
(This site is hastily thrown together with no polish whatsoever. It may improve some day, but probably not, I do internet work for a living so doing it on my spare time is not a high priority :-)

I love isosurfaces and their ability to add real programmatic distortions to the surface of an object, it creates effects I find much more satisfying than surface normals and some things you simple can't do any other way.

But isosurfaces have some drawbacks, most notably that you can only create objects that can be defined mathematically. Try to mathematically define an end table, or a statue of a horse. Not easy. I wanted to be able to surface distort all types of POV-Ray objects like CSGs and Mesh2s.

So I downloaded the POV-Ray 3.5 source code to see what I could do. After looking at the code for a bit I decided the best approach would be to 'convert' the objects into isosurfaces and surface distort them in the usual way rather than try to modify each type of object. To do this I opted to create an object function, similar to the pigment function, that would take any object and make it appear to be a mathematically defined function. After one false start and lots of learning about POV I got it going. The above POV-Ray banner was rendered with this function.

Here are some more sample images followed by a brief explanation of how it works, what problems it still has and what I hope to get done soon.
Here's the first full successful image I rendered. I was using serif fonts to test my code because they're a little complex but since True Type fonts tend to be slow in themselves I switch to the POV-Ray CSG logo.
This is the first image I was happy with. Unfortunately I was having troubles with the max_gradient setting which caused dropouts near the bottom.
Here is the relevent code used to create the above image (not the exact one, I was endlessly toying with the color_map settings and lost those), to give you an idea of how this works in the scene description code. click here. The key point is that with the patch ANY POV-Ray object can be defined as a function using the format function{ object{ [object] } } and this object function can be used like any other function, not just in isosurfaces.

I went overboard with this one adding a reflective metal surface variant of the previous image and a bright cloudy sky_sphere. I set it up and went to bed. After 7 hours of rendering it was quite disappointing.
Now this looks good, a nice turbulent surface based on T_Stone26.
Gotta love a good deep crackle pattern. Still getting some dropouts on the tip.

How this works is deceptively simple. Much simpler and more effective than my first stab at it in fact. Basically the function works by returning the distance of the given point from the nearest surface of the object. The distance is negative if the point is inside the object.

Naturally the tricky part is finding the nearest surface. Because the only sure way of finding a surface of any given object in POV-Ray is to intersect it with a Ray, the object function shoots out a number of rays from the point in question in a spherical pattern. If it fails to hit anything it increases the number of rays and tries again.

This works quite well but as you might imagine it's quite slow. The average time to render one of the sample images above was over 2-3 hours (on a 800mhz PIII), the banner at the top took over 7 hours. Right now I'm working on an optimization scheme. If anyone has any ideas please e-mail me at the address below.

It also isn't working with hollow objects (such as Mesh2s) which, predictably, always return false to Inside_Object calls. I have a solution to this but I haven't put it in code yet.

If anyone is interested in obtaining the code, or a winpov binary, let me know. I'm not ready to release it or do an 'official un-official' build of the executable at this time, and I probably wont be until I've got some optimization work done, but if enough people are interested I'll put it on the to-do list.

Questions? Comments? Rants? Raves? Ponderous Pontifications? Startling Insightful Revelations? Vitriol Filled Accusations? Spiteful Incendiary Insinuations? Endless Hyperbolic Meandering Ramblings?
Send them all to:
(I can't promise I will reply to all senders, but I will read it)