|
|
In case anyone is interested, here's an easy way to make 3D text using
sphere_sweeps. To get the data points, I made a bit-map image of the letter "L"
and drew several dots along the path of the character. It was a little tedious
to type the <x, y> coordinates of the dots. I suppose it's bad form to use the
third vector component for something unrelated to the first two but it's very
convenient.
In the example picture, the pink "L" in the upper left corner is the original.
The TrueType font is called "Pinyon Script." The blue "L" in the middle is the
sphere_sweep character. Using the orthographic camera causes spots to appear.
The sphere_sweep character is overlaid with the original in the upper right
corner. The bottom shows the sphere_sweep character with a normal camera.
This was a first attempt and I didn't put much effort into placing the dots
along the original letter but it turned out pretty well anyway. Adjusting the
diameter multipliers was pretty easy.
Have a great day everyone!
Kind regards,
Dave Blandston
The code is so short I'll just include it here:
-----------------------------------------------
#local NPoints = 32;
#local Coordinate = array [NPoints] { //<x, y, diameter multiplier>
<516, 451, 1>,
<513, 457, 1>,
<475, 485, 1>,
<422, 497, 1.8>,
<360, 495, 1.8>,
<264, 475, 1>,
<175, 451, 2>,
<93, 454, 2>,
<75, 473, 1>,
<94, 489, 1>,
<194, 490, 1>,
<277, 452, 2>,
<390, 328, 4>,
<532, 135, 1.5>,
<579, 93, 1.5>,
<631, 65, 1>,
<678, 56, 1>,
<719, 69, 2>,
<728, 104, 2>,
<683, 179, 2>,
<596, 255, 1>,
<500, 307, 1>,
<415, 334, 1>,
<329, 336, 1>,
<260, 313, 2>,
<228, 272, 2>,
<223, 236, 3>,
<234, 201, 2>,
<261, 167, 1>,
<300, 144, 1>,
<339, 137, 1>,
<349, 138, 1>
} //array
#local MinX = 9999;
#local MaxX = 0;
#local MinY = 9999;
#local MaxY = 0;
#for (I, 0, NPoints - 1)
#if (Coordinate [I].x < MinX) #local MinX = Coordinate [I].x; #end
#if (Coordinate [I].x > MaxX) #local MaxX = Coordinate [I].x; #end
#if (Coordinate [I].y < MinY) #local MinY = Coordinate [I].y; #end
#if (Coordinate [I].y > MaxY) #local MaxY = Coordinate [I].y; #end
#end //#for
#local MaxY = MaxY - MinY;
#local S = 1 / MaxY;
#for (I, 0, NPoints - 1)
#local Coordinate [I] = Coordinate [I] - <MinX, MinY, 0>;
#local Coordinate [I] = <Coordinate [I].x, MaxY - Coordinate [I].y,
Coordinate [I].z> * <S, S, 1>;
#end //#for
#local BaseRadius = .011;
#local ThreeDText = object {
sphere_sweep {
b_spline
NPoints
#for (I, 0, NPoints - 1)
<Coordinate [I].x, Coordinate [I].y, 0>, BaseRadius * Coordinate [I].z
#end //#for
} //sphere_sweep
} //object
Post a reply to this message
Attachments:
Download 'test.jpg' (48 KB)
Preview of image 'test.jpg'
|
|
|
|
"Dave Blandston" <IsN### [at] protonmailch> wrote:
> Alain Martel <kua### [at] videotronca> wrote:
> > How so ?
> > What we see in those circled areas is exactly as expected.
> >
> > To smooth out those areas out, you'd probably need to convert the whole
> > thing into an iso_surface and apply some blobing.
>
>
> Yes that's what I'm thinking of trying. Bald Eagle has made some amazing code
> that does the smoothing. It's a small detail but I think it would make the
> letters look better.
I just translated Inigo Quilez's Shadertoy code into SDL. I'm sure he got the
basics of that from OpenGL
"jr" wrote:
> that's an interesting page, some of the other posts I scanned cursorily looked
> worth returning to. thanks.
> (sticking my neck out) I think we'd need WFP to become interested, make 'povr'
> export/make visible the TTF data it (as pointed out) already has, in the parser;
> pass in a text{} and get back metrics, that sort of thing.
Well, I would say that as "purists", we tend to dismiss 3rd party/"other"
software, but I would strongly encourage everyone to explore what's out there
and _make use of_ those software packages and programming languages and use them
as inspiration for functions, macros, and other things that are in SDL.
If I was going to pursue this project, I'd probably start out by contacting
Inigo Quilez or Martijn Steinrucker (Art of Code on YouTube) and asking about
how to write functions to make the required sphere sweep segments. I'd also
find somewhere to post on the ShaderToy forums to see if anyone has written code
to translate TTF into renderable ShaderToy code.
Look for TTF importing/decoding libraries in languages that you understand.
Perhaps Freya Holmer has done some work on this in relation to ... her ...
presentations on Bezier curves.
Casting about on the internet in places you don't often go can broaden your
horizons, give you new idea and inspiration, and you can _communicate with
people about POV-Ray_ which may spark their interest in some way.
I'm confident that a lot of the necessary steps can be done in SDL, but perhaps
there's a simple command-line thing that will spit out the bezier spline control
points of the segments that make up the glyphs in a font. Then you could use
that to generate a text file for use in POV-Ray.
I'd say first get it to work, then if you want, you can do the programming
needed to gather it all into an SDL-only scene file.
But rule #1 is usually "See if this has been done before" and use other people's
code - it will save a ton of time, mistakes, and debugging frustration.
The other point/aside I wanted to make, is that if there was a way to make a
signed distance function for the whole glyph, then you could probably just code
them at an undersized diameter, and then "inflate" them to get the rounding
automatically, but I think that would be a very very long shot, and probably not
something that would lend itself to automation.
Post a reply to this message
|
|