|
 |
If you have seen any of my posted renderings and read my comments, you will know
that I am a big fan of using isosurfaces. Most of the objects in any scene I
create are isosurfaces, unless I am absolutely sure I will not need to apply any
sort of irregular, visible, surface texture to them.
With my latest exploration of SDFs, and how to use them with isosurfaces, I have
a library that covers pretty much all of the POV-RAY SDL primitive objects as
isosurface SDF functions, so I can create just about anything... except text.
There are a number of articles about how to create SDFs for text objects,
including GPU-based game platforms that do this automatically, but I haven't
found anything that would work well with POV-Ray, other than something that
generates meshes. Even then, applying a bumpy surface to a pre-defined mesh
isn't easy.
So, I have resorted to the following:
1. Create a text{} object representing the text I want to render.
2. Create a pigment using the object pattern from that text:
pigment {
object {
_text_object
rgb 1
rgb -1
}
}
3. Create a pigment function from the pigment
4. Create an isosurface using the pigment function as the function and
add/subtract my surface texture function to it.
The difficulty I have had with this is that the pigment function isn't
continuous, so it doesn't really function as an SDF. This can make it difficult
to get the surface texture to "stick" correctly. Plus, the wider the difference
between the "in" and "out" values, the higher the max_gradient I need to get rid
of artifacts.
It does help to use smaller, more appropriate values for the in/out, generally
something just large enough to reflect the maximum extent of the surface texture
being applied, but the discontinuity can still be an issue.
So, I have taken a new approach to create a pseudo SDF by creating N instances
of the pigment function with the object scaled smaller than 1, (representing the
interior), and M instances scaled at greater than 1, (representing the
exterior), and assigning a distance from the surface of the original object that
those scales represent. The isosurface shape function then finds the smallest
scaled instance of the object that the point lies within and assigns the
distance associated with that scale as the distance from the surface.
Depending on how accurate, (and slow), I want the image to be, I can make the
new step-distance-function as close to continuous as I need to get a good
result, while keeping the max_gradient reasonable.
Here is an example. The top, white object is just text {... "What" }. The
bottom, textured one is an isosurface using this pseudo-SDF function with 3
interior and 3 exterior scale values that cover the range where the bumpy
surface texture would apply. (The surface texture is a warped crackle pattern).
Accuracy was 0.005, and max_gradient was 10.
I added some code for creating the pseudo-SDF to libisoshapes.inc:
Iso_object(Object,Gradient) and some functions for creating the gradients that
define the values and scales Iso_object_scale_gradient_create_size().
One important note using this method; the object to be converted should be
centered at the origin. I used the previously defined Text_metrics macros from
libtext.inc to help with this.
-- Chris R.
Post a reply to this message
Attachments:
Download 'text_test.png' (230 KB)
Preview of image 'text_test.png'

|
 |