Showing posts with label texturing. Show all posts
Showing posts with label texturing. Show all posts

Thursday, May 24, 2007

...Sculpted jewelry!

A really simple set to start out with, while I design more complex things.


The necklace and the earrings, following my tradition, are scripted so the gem and metal colors can be independently changed. The sculpted heart has my usual nine colors: amethyst, blue topaz, citrine, diamond, emerald, garnet, ruby, sapphire and topaz.


And I finally have a better store location, on Flotsam Beach. Part of what makes it better is that I can actually make landmarks and SLURLs which teleport directly there. Also it's bigger, it's not stuck in the back corner of a mall with little foot traffic, and it's in a beautiful new themed sim (an Atlantic beach resort).

I have to design up a nice floor plan, but until that's done I've just stuck vendor boxes on the walls.

Thursday, May 10, 2007

More sculpted gemstones

...and I get back to my Linux machine to discover that they still don't have voice chat in Linux!

Oh well, at least I can play with the sculpted prims on a decent machine for now. I know gemstones are a trivial example of what's possible with sculpted prims, but I'm excited by the thought of more interesting varieties of stones to make jewelry with.

Last night I started all my computers (even the ancient ones) working on churning out textures. This is going to take a looong time - my fastest computer is managing about one texture every hour and forty minutes, and I've got a total of 765 textures to go through (85 gem shapes, and 9 colors for each). So far I've managed to do 62 of them; at this rate, I might have the complete collection finished by the time sculpted prims debut on the main grid. What I've got so far (click to enlarge):


Those are at the default prim size; obviously they can get much smaller. I'll need to redo the sculpting textures, though - if you bring it all the way to its boundaries, a sculpted prim is about twice the size of an unsculpted one. These are all spaced one meter apart; even though they're set to 0.5m in each direction, you can see that they're almost touching each other.

Sculpted prims can't be cut, twisted, dimpled, skewed or otherwise tortured - so the only way to make something smaller is to change the sculpting texture. For example, rather than making the color range 0-255 in each channel, you can cut the size in half by making the range 64-191. Of course, reducing the color range also means reducing the accuracy of your model. There's also a bug at the moment, where color values that get too close to each other turn the sculptures into plain spheres if you get the camera close to them.

It's odd, but I think the back sides are even prettier than the fronts (click to enlarge):

Friday, April 20, 2007

Better Mousetrap

The schedule board at Rockcliffe University, while it looked nice, I'm told it was quite horrible to actually use. It required all sorts of strange configuration via notecards, making the weekly schedule change a nightmare.

I thought there had to be a better way. So I made a similar board - by tapering a box and then mashing it flat, three different letters could be put on a single prim. But instead of arcane configuration, I set it up so you could simply drop a notecard on it, and the text of the notecard would be displayed on the schedule board. Not too bad!

But it was kind of hard to read, and I thought it might be nice if you could change the colors for each line (or groups of lines by day), and added in a #color command which wouldn't be printed, but would set every subsequent line to the specified color, until it was overridden by another #color command. (Shown to the right; click image for a larger view. Classes which had already taken place appear in dim characters.)

And yet I still wasn't satisfied. I was already planning a Web-based schedule database, so the teachers could go in and schedule their classes, which would then appear on the Web site's calendar - so why not also automatically update the board whenever the schedule changed, or a class was over?

This required delving into the XML-RPC functions - which was an interesting learning experience in its own right. But while I was doing that, someone on the Scripters of Second Life group mentioned offhandedly that you could get five letters onto a prim. Well, that sounded like a fun challenge - not to mention cutting the number of prims by 40% - so I set about trying to do so.

Here's a graphic showing the stages of making a 5-letter text segment:


First, we start with a prism. This is the fourth icon on the "Create" pane, between the pyramid and the cylinder. I've colored the front faces red and black just for reference.

Second, set the Taper X and Taper Y both to zero, to get rid of the point on the top and make the edges straight.

Third, set the Path Cut to B=0.2, E=0.8. This cuts a wedge out of the front of the prism, giving us the faces which I've colored green and white. Those particular values leave the red and black faces each taking up one-fifth of the prim's width.

Fourth, set the Hollow to 65. This cuts into the green and white faces, showing us the interior between them (colored blue.

Fifth, set the X size all the way down to 0.010, which flattens out the prim as much as possible.

And sixth, scale the prim so that it gives us a good height-to-width ratio for text. I scaled it to <0.010,0.964,0.250> so that the letter faces were the same size as the ones on my previous version.

Next came setting the texture offsets. If you just tried to put a texture on the faces, they'd look okay on the second and fourth faces, but stretched out somewhat on the first and fifth faces, and REALLY stretched (and backwards!) on the middle face.

So if we were just going to apply a texture with a single letter to each, we'd have to change the texture repeats and offsets. From left to right:

  1. Repeat 2.5 horizontal, 1 vertical; offset -0.25 horizontal, 0 vertical.
  2. Leave at the defaults (repeat 1 horizontal, 1 vertical; offset 0 horizontal, 0 vertical).
  3. Repeat 15.4 horizontal (flipped), 1 vertical; offset -0.2 horizontal, 0 vertical.
  4. Leave at the defaults.
  5. Repeat 2.5 horizontal, 1 vertical; offset 0.25 horizontal, 0 vertical.
With those settings, you would just need to swap the textures for each face in order to display a different letter. (I did it somewhat differently, though - I made a texture with the lower 128 ASCII characters arranged in a grid, which requires a bit more computation every time the letters change.)

I'm still writing the database portion of the system, but to test the XML-RPC communication, I wrote a quick script on my Web site to contact the board in-world, display the version and time, and then include the output of the Linux fortune program, adding #color commands as appropriate:


Now I just need to add in sequence numbers so that if the Web server doesn't receive a response to its communication, it can resend it, and the schedule board won't duplicate the information if it already received it but its response was lost. And then finish writing the database front-end, of course. But still, not bad for a couple days' work!

Monday, February 19, 2007

A Week's Work

Wow, has it already been a week since the last time I posted?

The head of Rockcliffe University, where I teach building (and am writing a scripting course, which hopefully will debut before the end of the month), went and bought an entire sim. Which means all new classrooms!

One thing which I thought the old space lacked was actual lecture halls. So I decided to build one . Once I got through the inevitable round of "could you change this and this and this?" (never build things "on spec" if you're trying to realize your own vision!), I ended up with this layout:



Sure, it'll get the job done, but it's not all that exciting visually. So I took a couple of days, and wrote the set of scripts I've been planning to write for ages.

One script, which I dropped into every prim in the build (except the chairs), just sat there until I uttered a command. Once I did, each prim announced all of its parameters: location, size, rotation, type, hollow, cuts, and so forth. I copied all that information out of my chat history and pasted it into a text file on my computer.

Then I ran that text file through a PHP script which I wrote to convert each prim's data into a POV-Ray object. POV-Ray is a freeware 3D renderer, which does shadows and other things very nicely. The great thing about it is that its scene description language uses plain text statements which describe graphics primitives very similar to what's used in Second Life: boxes, cylinders, spheres, tori, and so on! So my PHP script converted the build into a POV-Ray scene file, which (when rendered out) looked like this:


Not terribly exciting when everything's grey, so I started adding textures to everything. It's not really easy to add image textures to different surfaces of POV-Ray objects, like it is with Second Life prims, but POV-Ray has some very versatile texturing capabilities in its own right. After another day or so of writing texture statements, it rendered out like this:


I then rendered out orthographic views of pretty much every surface, which gave me image maps I could then upload and apply to the build in Second Life. This was what took the longest, as I had to calculate the repeats and offsets for pretty much every face. But in the end, I think it was worth it, as here's what the final result looks like in Second Life:



The chairs are kind of lame, unfortunately. I had made much better textures for them, with rounded backs and seats which appear to curve down in front, but they'll have to wait until the alpha-texture sorting bug is fixed before they make their appearance.

But regardless of textures, the chairs themselves are very low-prim; each bank of four chairs consists of seven prims, whereas the five-chair banks are only eight prims each. Through the judicious use of alpha textures, I was able to make them look more complex than they actually are. They don't stand up to close scrutiny, but they manage to seat 52 people at a cost of only 88 prims (the entire build is 186 prims).

And here's a view looking from the side of the stage out towards the back of the hall:


Oh, foo, I just noticed I forgot to make the doors more interesting, with a crash bar and a narrow pane of safety glass and one of those things up in the corner to make it close slowly.

And no emergency exits! I hope there aren't any fire code inspectors in Second Life!

Wednesday, January 3, 2007

Baked Textures, attempt 1

I took the plunge and rented myself a little vendor stall. Of course, I wanted to make it look nice, and I wanted to try out some texture baking, so I've spent the past couple of days working on that.

Aimee Weber's American Apparel build changes textures at sunset, and displays a floodlit look at night. Because I don't own the building my stall is in, I couldn't do much about the exterior — but since my stall has windows on two sides, and is across an aisle from similarly windowed stalls, I decided to change the interior lighting and shadows to match the position of the sun.



Every fifteen minutes (except at "night"), it gets the sun's current position and uses that to determine which texture to display. Fortunately, Linden Lab have been kind enough to provide a function to tell us where the sun is:

vector SunDirection = llGetSunDirection();


For some reason, the sun doesn't go straight east to west; it's tilted over by about 45 degrees, and the center of its path is somewhat above the grid, so it's below the horizon only one hour out of every four.

Anyway, making the textures for the store was fairly easy, but time-consuming. I recreated the entire store, plus some of the surrounding walls, ceiling and floor, using the Persistence of Vision Raytracer (a free 3D renderer). I chose POV-Ray over the other 3D packages I have because, like SL, it works with graphics primitives rather than polygon meshes, so it was easy to exactly re-create the geometry. Also, it can be scripted, so I could just plug in the list of sun positions, and make it light the scene from a different position based on which frame number I was rendering.

I had to render everything which would receive a baked texture: the wall, the floor, the ceiling, and every visible side of the wooden "bench" which would hold three vendor boxes. Then upload and apply! (The uploading was a bit pricey, since I had foolishly chosen to make a new set of textures for every fifteen minutes except nighttime. I managed to squeeze all the "bench" textures onto a single image for each time slot, but the grand total was still L$480 for only four things to texture — ouch! Maybe just day/night textures next time after all.)

Friday, December 29, 2006

Tantum Agendum Parvulus Tempus

Oh, no! With the grid down for repair, I've been reading the SL newsletters and the like, and stumbled across the portfolio of Aimee Weber. Okay, so from what I gather she's really well known in SL, but I guess I don't get out of the sandbox often enough; it's the first time I'd heard of her.



Oh. My. God. From what she says on the page linked from the image above, she uses "baked textures" (i.e. the shadows are part of the textures themselves). That is absolutely phenomenal and I MUST LEARN HOW TO DO IT!


Once the grid comes back up, I have to visit the American Apparel store she built; apparently it swaps textures based on the time of day, so that it's lit up with floodlights at night (with shadows on the walls changing to reflect the changing light sources).

My guess is that she must reproduce her builds exactly in an external 3D application, texture and light them the way she wants them to look, then render at least a couple of passes for each wall/floor/cabinet/etc. (one for the base textures, with the furniture removed; and another one for the shadow maps with the furniture present), then combine the passes into a single image and apply them to the SL objects.

Although... in searching through the LSL Wiki for something else, I did run across this function, which includes a mouth-watering flag name: STATUS_CAST_SHADOWS"PREVIEW: If set, object casts shadows on other objects (if shadows are enabled)" Looks like it's time to try out the preview grid!

(As if I don't already have enough things on my SL "To Do" list, and RL Boyfriend isn't already feeling neglected as it is... If only I could get him sucked into SL too!)

Sunday, December 17, 2006

Earrings! And neuroses!

Day 35

Last night (and into the wee hours of this morning), I made a set of earrings from the Cheapside Hoard (actually, I think it may have been a pendant — I stupidly forgot to get a picture of the card saying exactly what it was, or include anything in the picture to give a sense of scale — but I think it looks great as an earring). When I make (or break down and buy) a decent skin, I'll have to take a picture with them on.


The little tiny rings linking the parts together are toruses, of size <0.020,0.020,0.020>, hollow 95, hole size X=0.25,Y=0.49, profile cut B=0.74,0.76, and a twist of B=180,E=180. It's the twist that lets them get so tiny — the profile cut leaves just the smallest sliver around the outside edge of the torus, and the twist rotates it around the minor axis until it's the inner edge.

Once I'd finished the earrings, I had to buy hair that showed my ears! On the other hand, I didn't have to upload a new set of textures for these, so I suppose I came out ahead.

It's funny that I'm obsessing about how much L$ I spend in Second Life; in real life I'm a total spendthrift. "I can't be overdrawn, I still have checks left!" Maybe I could do better at balancing my RL checkbook if I had a real-time display of my available funds in the upper right corner of my field of vision... I'm sure in fifty years, or whenever they finally develop brain-interface computers, people will be able to do that! And I'm stuck here using Excel like a savage!

Speaking of obsessing, I'm really starting to worry about the cross necklace; I don't see much religious symbolism at all in Second Life. Does it make me come across as a religious fanatic? Or am I just neurotic for even worrying about it?

Saturday, December 16, 2006

Much better! (And, goals and obstacles)

Day 34

This morning, I optimized the Necklace Generator — since the necklace should be symmetrical, it's stilly to start in the front and work all the way around. So now I start halfway through (in the center back), and each time I calculate the position for one link, I just have to flip it across the X axis by negating the Y value, and I have the position for its opposite link in the chain! That cut the calculation time in half (though it still seems like it takes forever).


That's a new, nicer chain. I kept the basic link shape (it's a torus, size <0.026,0.010,0.010>, profile cut B=0.15,E=0.35, hollow 95), but instead of those flattened disc things I had linking them, I used a tiny little "cord" in between them (actually it's the same thing as the main link, but just brought down to 0.010 in the X size, and the profile cut range was reduced to B=0.20,E=0.30). You can just see them if you click on the above image for the larger version.

What are my goals?

I feel like a constant newbie, because I don't have a lot of things. And I don't have a lot of things because I vowed not to spend any real-world money on Second Life. It would be so easy to just plunk down $20 for some Linden Dollars (L$5279 at the current exchange rate, quite a bit more than I've been able to amass in over a month of camping chairs, dance pads, Scramble, and the occasional contest prize or gift). But I'm not fishing for handouts here — if I manage to turn my building and scripting skills into a profitable SL business, there'll be a bit more satisfaction in knowing I started from nothing.

I didn't get into the game with the intent of starting a business — I just thought it sounded like a neat playground for someone who enjoyed programming and 3D modeling (and besides, my boyfriend is in grad school and I have to find some way to occupy my time while he's got his nose stuck in a book). But I saw some of the things people were selling, and I thought, "Hey, I could do that! Why not give it a try?"

Obstacles

Now, building is free (though I've been told that it used to cost L$ just to rez a prim). Texturing, on the other hand... if you want to really customize your prim, you have to make the texture yourself. Each texture costs L$10 to upload, and I create each of my gemstone textures in sets of 9 (amethyst, blue topaz, citrine, diamond, emerald, garnet, ruby, sapphire and topaz). The rectangular ones need 18 (one set for vertical orientation, one set for horizontal), so that's L$90 or L$180 per set.

The best place I've found for dancing overnight (and the fact that there are usually open dance pads is part of why it's "best") only pays L$2 per 17 minutes of dancing, so every hour and 25 minutes gives me enough to upload one texture. One nine-color gem texture set requires over fourteen hours of dancing (assuming the sim doesn't get restarted and lose me all the dancing money I've accrued)! Fortunately there are other things, like Scramble games, which pay more, but you have to actually participate; you can't just sit there.

Technical User Interfacing offers a Career Course in jewelry, which includes information on how to set up a business (something I really need). I've talked to a few students who have taken or are taking it, and they all seem to believe it's well worth the L$3000 it costs to take the course. The last time it was offered, I had only a fraction of the cash to take the course. I can afford it now, just barely, but my inner skinflint is apoplectic at the thought of spending that much money all at once! Sigh.

Success!

Day 33

Well, Johanna's Necklace Generator is almost finished! After two days of fruitless script-bashing, I swallowed my pride and asked for help on the Scripters of Second Life group. A very polite young man (from Canada, which explains the politeness) spent about an hour and a half with me, ripping out my Euler rotations and replacing them with quaternion math, and then bashing on those until they finally started doing what I needed.

The Necklace Generator is pretty simple, really — to use, at least! It's a script which you put into a cylinder, along with an object representing the chain link you want to use. Edit the script and tell it the name of the link object, how long the link is (which will usually be a little less than the actual length, assuming the links go through each other), whether or not you want it to rotate every other link 90 degrees, how far down you want the chain to come in back, and a couple of other things.

Then you edit your cylinder and stretch it to the dimensions you want. The dimension along the X axis of the cylinder controls how wide the necklace is from front to back (I know, that should be the Y axis, but that would add a whole new layer of math to everything... no thanks!), the Y dimension controls how wide the necklace is from side to side, and the height of the cylinder controls how far down it comes in front. (If you set its Z dimension to 0.010, it suppresses the drop entirely.) How far down it comes in back is controlled by a variable, as mentioned above; it's pretty much a percentage of how far down it comes in front.

Then you just touch the cylinder, and it thinks for a LONG time, and...


...several months later, you have a necklace chain wrapped around the cylinder! (Well, as long as you leave the cylinder with rotation <0,0,0> — it'll ignore the cylinder's rotation and act like it's unrotated regardless.) That slice cut out of the cylinder is to remind me which way is "front". I suppose I'll eventually make a special cylinder texture for the Necklace Generator.


After seeing it, I'm not really sure I like the style of that link — the rings are so thin they disappear when seen edge-on — but you get the idea. And from further away, it doesn't look too bad on the Cheapside Horde cross. As you can see below, the rotations aren't perfect, but it's close enough that only a couple minutes' tweaking are enough to bring everything in line, which is still much better than having to build the whole chain by hand!


The only thing I have left to do is add an option to make it automatically come to a point in front, for pendants and the like.

Also, I'm trying out some new textures for gems. I loaded a test pattern texture (I think it was from Robin Wood's in-world texture tutorial) onto a cylinder tortured into a gemstone shape to see how the faces were actually patterned. After doing a little unrotating, I came up with this texture:



Basically, it's a straight-on view of the gemstone's table and crown, taking up the top 80% of the image (I pasted shrunken copies underneath it as a "bleed" area), with the bottom 20% being the crown "unwrapped" with The GIMP's Polar Coords filter (Filters -> Distorts -> Polar Coords, with "To Polar" unchecked), cropped to the area beneath the points of the table and above the curves of the girdle, and then resized vertically to take up the bottom 20%.

When uploaded to Second Life, and applied to the gemstone, a little massaging the repeats and offsets just a touch, it resulted in this:


It looks a little blurry, because I made the texture at too small a size. But that doesn't matter for this particular gem, because unless people are looking really closely, they probably won't notice.


This is the gem on top of a cube sized to <0.010,0.010,0.010> — the smallest you can make a prim in Second Life without resorting to prim torture:

The gem's prim is actually <0.020,0.020,0.010>, so it's twice as big around as it could be! (I needed to make it bigger to get the proper slope for the crown.) It's a sphere, set to dimple B=0.95, E=1.00, converted into a cylinder, tapered to X=0.95, Y=0.95, and then resized to <0.020,0.020,0.010>.

If you care to try it, feel free to grab the gemstone texture and put it on the prim! The table (the flat part on top) should have its horizontal and vertical repeats per face set to 0.400, the rotation to -90.00 degrees, and the vertical offset at 0.1. The crown (the sloped edges) should be set with a horizontal repeat per face of 1.000, flipped; vertical repeat per face of 4.000, rotation of 0 degrees, a horizontal offset of 0.000, and a vertical offset of 0.300.

(Edit: For some reason, when I followed my original instructions just to make sure I had them right, they didn't produce the results I expected! Above are the corrected instructions.)

Thursday, December 14, 2006

Jewelry

Day 32

So here are some pictures of the jewelry I've made so far. I'm still not finished with the necklace chain generator, but I'm getting closer (I now have placement on the perimeter of the cylinder and one rotation; I just need two more all three rotations).



Above is the first really intricate piece I made, it's an attempt to reproduce my grandmother's locket in-world. The necklace chain was made by hand, and took almost as long as the locket itself. As with all my jewelry, it's scripted: you can change the color of the metal and the gemstone textures, turn bling on and off, and a couple of other minor things. It's "actual size", the locket itself is about 5cm tall and 4cm wide.


This is a matching circlet, bracelet and armband; I was playing around with torturing a torus and the design suggested itself to me. Like with the locket, you can change the colors — either individually or all pieces at once.



This is a pretty simple brooch. I mainly made it to showcase a set of gemstone textures I made. The problem with the usual gemstone textures is that they don't look good when wrapped around a sphere, spheres need to be textured with a Mercator-like projection for minimal distortion. I rendered a spherical faceted gem in POV-Ray with an orthographic camera, then used The GIMP to perform a reverse polar mapping on it. That gave me the top hemisphere, so I just cloned the layer, rotated it 180 degrees and moved it down so that its top edge was touching the bottom edge of the original layer. Flatten, save and upload, et voilĂ ! A spherical gem texture that looks good on a sphere! I also made it in multiple colors:


I made nine gem colors in all: amethyst, blue topaz, citrine, diamond, emerald, garnet, ruby, sapphire and topaz.

This cross, which hopefully will have a necklace chain sometime before the end of the century, is a reproduction of a piece from the Cheapside Hoard, a treasure trove of jewelry from around 1600, dug up in the early 1900s. There are plenty of things I want to make from the Hoard. Above is a rectangular-cut amethyst texture I made; below are garnet and blue topaz (shown with the metal set to gold and silver, respectively). Actually, I created two textures for each color: one for the gem oriented horizontally, and one for vertical orientation. Alas, the distortion caused by tapering the box robbed a lot of the detail from the sides of the gems, but it's still not too bad. There's no bling on this piece, because I found it was just so tiny the bling particles overwhelmed it. But sometimes subtle is much nicer than flashy.

The little finial gemstones are almost too small, as I mentioned in my previous post; I lost quite a few attempts while making them. Create a sphere and set its dimple to B=0.98 and E=1.00, then change it to a cylinder. Taper it to x=0.95 and y=0.95, and then set the size to x=0.010, y=0.010, z=0.010, and you have an incredibly tiny conical frustum. The rectangular and diamond-shaped pieces were made small (or excessively tiny!) in a similar fashion; dimple a sphere (I think I used B=0.75,E=1), change it into a box, then taper and resize to taste.



Just for a little sense of scale, here's a table showing the different pieces of jewelry I've made so far. The sword isn't really jewelry, but I'm proud of it too. Most nights, the Technical User Interfacing (or TUi) school holds challenge build competitions: you show up, and when the competition starts, they tell you what the topic is. You have 45 minutes to create it entirely from scratch (you can use textures and scripts from your inventory, but that's it — all the prims in your build have to be created, textured, and positioned right there). The topic for that night, obviously, was "swords". I decided I wanted something ladylike — no point in making something I couldn't use! — so I Googled for images of swords and found a beautiful swept-hilt rapier.


I was working right up to the time limit. I didn't win (well, I thought mine looked the best!) but it was fun, and challenging, and I made something I probably wouldn't have otherwise. Unfortunately, those contests are usually held at 10PM Pacific time, so if I participate on a work night I only get about four hours' sleep.