Thursday, October 25, 2012

Optical Optimization Options


Once you have the hang of making your linksets to create and texture your meshes with Mesh Studio, the next important thing to conquer is the almighty LI (land impact) and equally strengthen the LoDs by controlling how they degrade with custom LoDs.  Remember, LoD is level of detail that you see as you move away from the objects with your camera in Second Life.  You see less and less detail, optically, just as in real life, the further you are from something.

First line of defense is your Mesh Studio menu when generating your mesh.  Here is one tactic I use.


ONE.
I create my linkset and leave the default settings for use as the High LoD level.

TWO.
For the Medium LoD level, I select the Low Poly setting on the MS menu.

THREE.
Low LoD level can use the Low LoD setting on the MS menu.

FOUR.
For the Lowest LoD level, you can do one of two things.  Use Use LoD Above or set the Triangle Limit on the level to 0 (zero).  

FIVE.
Calculate with the Use LoD Above setting and then again with the Triangle Limit set to 0 (zero).  Check to see which gives you the lower LI and decide which you want to use.

The second line of defense is to create the lower LoD levels by modifying your linkset.  The above workflow will work in many cases.  I recommend trying it to have values to compare to this second method of working.

The first thing to remember is that you are simplifying your forms but trying to retain the general silhouette of your linkset.  Let's use my lampost as an example.

This lamp is 22 prims: spheres, cylinders, boxes.
Since the center is a single tapered cylinder, let's focus on the top and bottom parts of the lamp.


In addition to the prims that make up the top of the lamp, I have created two sets of colored prims by tinting the faces of some of the plywood prims.  One I will use for the glass casing around the lampflame and another for the metal encasing what will be textured as glass.  The rest of the prims are all in plywood and this constitutes another material for a total of three.  In 3D programs, these material faces are set up by selecting faces on the mesh and assigning materials; in Mesh Studio, we select faces on the prims and tint them with all faces having the same tint belonging to the same material.

Second Life chose not to change their Edit menu, so to access these materials on the uploaded mesh, we use Select Face.  Doing this on any face that was within one tinted group of faces selects all faces in the group even if they are on opposite ends of the mesh (think of having candles in a candelabra and all the candles have one material; selecting and texturing one candle, textures all the candles at the same time).

The bottom of the lamp is a series of cylinders and a cut sphere.
This linkset had the Object2JoinedMesh script added and the default settings were used to generate the High LoD level.  Remember to name your root prim.

I made a copy of this lamp linkset and renamed it to reflect I would use it for the Middle LoD level.  Now it's time to examine the prims and see what you can do to simplify, but keep the general shape of the lamp.


It is very important, if you have made materials, to make sure that there is at least one face left on a prim that bears the tint used for a material face, so in this case that would be the plywood (which would be abundant) and the blue and green.  On the left is the original and on the far right, you can see the prims I removed (they need to be unlinked so they are no longer part of the linkset) and then the remaining prims modified to adjust for the removal of these prims.


It's a bit of experimentation to find what works and/or what is acceptable.  Remember these will be seen from further away.  You can see what I removed from the bottom and how I adjusted the prims, but I could have chosen to try it differently.

On the next copy I make, I name the root for the Low LoD level for which it will be used.  I have removed more prims and begin simplifying to full tapered boxes, but always seek to maintain the general shape that will be seen as your camera moves further away.

Since this is an LoD which is implemented at a much further distance, I am not concerned with small spaces between prims, you really won't see it.
Again, simpler forms.  As long as they have a visual feel for the shape, it will read fine at distance.
Note: The LoD will push on the shape of the prim to its largest mass, so it can be tricky to make shapes match the more delicate they are.  Case in point is the final version of the lamp as follows...

I changed the central cylinder on the lampost to a tapered box (right hand prims in image).  Notice how the tapered box looks thinner than the cylinder.  In trying this out, thicker versions, with the box shape, spread out in mass more than what could be seen with the cylinder, thus making the change visibly too different to the eye.  This thinness kept a more loyal silhouette to the original lamp and that is the goal.


For this final LoD, I was trying to trim a much fat as possible (i.e.prims/faces).  Look carefully on the right hand side final version and you'll see there is still one part of the blue material face prims left (bottom of the green prim) to make sure that the number of faces are maintained throughout.


So each of these versions, the original and the three simplified versions is used to do the four DAE files that are used in the four LoD levels in the SL Uploader window.  I set physics to lowest.  When this lamp was uploaded to Second Life, it came in at 4 LI from 22 prims and very strong LoD.


Hopefully this gives you some information to start bringing in your meshes with lower LI and better LoD.

Happy Meshing!
~ele

Break it down to shed some light!


When approaching anything you want to build, you can use the same methods employed by 2D and 3D artists alike.  All things complex can be broken down into simple forms.

If you look at a lightbulb, you can do a sphere for bulb.  While it often curves into a more cylindrical shape at it's bottom, we could take liberties and just use a short tapered cylinder going into a smaller, but longer tapered cylinder which is the metal part from which the glass protrudes.  It can be rounded on the bottom, so a small, thinned-out half sphere can work.  For the threads, the torus, when used with radius and revolutions, can give us something akin to what we seek.



For this example, I don't want to mess with alphas.  In SL, it's not absolutely critical.  You could create a material face so the bulb part could change to a whitish yellow when lit and it gives a very nice effect, especially with glow and light.

We now have a bulb composed of 5 prim parts.  I made any parts that are not going to be seen set to 100% Transparency.  I used two textures out of this glass and metal 4-in-1 texture image to texture the bulb as explained in my previous post.


Using the Object2JoinedMesh script, I generated the bulb mesh with defaults and it was 1.9 LI.  I decided to try and make the lower LoDs with the menu settings.  I generated the mesh again, this time setting to the Low Poly setting, and once again, using the Low LoD setting.  I used the first one I originally made for high LoD, the Low Poly as the medium LoD, the Low LoD version for the Low LoD setting and zeroed out the lowest with physics using the lowest settings.  This bulb came in at 0.6 LI (rounds up to 1).  And, of course, when I put the 4-in-1 texture image on the mesh, it matched the prim linkset.

So when you see something complex, remember, it's just a bunch of simple shapes put together.

Happy Meshing!
~ele

When you texture the prim, you texture the mesh...it's MAGIC!


(updated 09.15.12/12:15 pm PT)
Even after working with something for a long time, I find that I still have so much to learn.  This is, however, why I like to teach people because it makes me delve and ask questions and really try to understand things in order to explain them to someone else.

So in speaking with TheBlack Box and asking some questions, I had an AHA! moment.  Some of you may already know, but I finally just got it.

Here is the lectern I've shown before.




The one on the left is made from my prim linkset made of 19 boxes, no material faces, with the Object2JoinedMesh script.  I simply made it and made it mesh and threw on a seamless texture, the one on the left, you see in the bottom picture, light maple bounded on top and bottom with tiger oak.  Didn't texture bad at all.

Now look at the one in the center.  This is the same linkset, but this time I textured all the prims beforehand, using the same single seamless texture.  I used offsets, repeats and rotations to get the texture to go onto the different faces as nicely as possible; decorating it more as I had wanted.  When you do this, Mesh Studio uses the repeats/rotations/offsets in the creation of the UVs and when you generate the DAE and upload it to Second Life, the mesh has all of this texture information embedded.  Drop your texture into the texture panel of the Edit Menu or, if you have no materials as on mine, drop the texture onto the mesh itself.  It will match the textures as you set them on the prims in your linkset.

BUT WAIT, THERE'S MORE!  Look at the lectern on the right.  Note the texture below it on the bottom right of the illustration.  It is a 1024x1024 image comprised of four textures, each 512.  I retextured the linkset once more, this time repeating and offsetting to utilize one quarter of each texture on any given face.  All four of the textures in this image are used on one face or another throughout the prim linkset.  Once I generated the DAE and uploaded, I dropped my texture on this single material mesh and it also matched everything I did to the prims.  Using the four textures in one, expanded what I could do on the prims design-wise.

What this means is that without making a material face, you can get more than one texture on your mesh.  All without ever going to a 3D program.  That is pretty darned nifty!

Take a look at the steps in this linkset.  They have had a simple brick seamless texture put on them.  You can see, on the left, when all the settings are 1:1 with no offsets, they are different sizes and don't follow how a brick pattern should look.  On the second linkset, to the right, the pattern has been offset and scaled to provide a more realistic use of the pattern.


So it's just a matter of setting up the textures before you create the mesh.  While it doesn't mean that the mesh will upload with the textures on the mesh when it rezzes, the textures are already in SL and you just drop them on your uploaded mesh.





How do you work with a four-textured-tiled-image?

If you start with a 1024x1024 texture that has one 512x512 textures in each corner you'll end up with a texture that can have multiple uses for texturing your prim linkset for Mesh Studio.  Upload this texture to Second Life.  First, we will talk about using this on a prim linkset where you have elected to use no additional material faces.  

My recommendation is to make whatever faces, on your linkset, that are not visible at all when you will look at the mesh, and set those to a transparency of 100% which means these faces will not generate any mesh.  Now you can either drop the texture on each face, or open the linkset in edit and drop the texture into the texture window of the SL Edit panel or select it from the list of available textures.

The most common setting for using these four textures in one image is to set the repeats to 0.5 on both the horizontal and vertical repeats.  Then set the offsets to 0.25 or -0.25 in horizontal and vertical offsets.  By changing the offsets from positive to negative 0.25 in each offset field, you can quickly apply any of the four textures from your single image.  In the case of very narrow prims or odd cuts, you may need to increase or decrease the repeats.  You may also, depending on the texture and it's pattern, change the number of horizontal or vertical offsets to place something in the texture just where you want it.  You may also try rotations and flipping the repeats horizontally or vertically.  

However these textures end up on your prims, the parameters you set for the textures on each face will be faithfully reproduced on your mesh.

NOTE:  At this time, Mesh Studio does not support the use of Planar Mapping.  Only the Default setting works as expected.  This may change; I will update the blog if it does.

ALSO:  DO NOT USE TINTS when texturing, these tell Mesh Studio that you want a separate Material Face for that area.  

In the next post, I am hoping to continuing this topic by incorporating the use of material faces as well to further expand what you can do not only with textures, but the "effects" settings of transparency/glow/shine and bump.

Happy Meshing!
~ele

Unwrap that thing already!


This video will show you how to examine the UVs of your Mesh Studio mesh in Blender.  Now you don't have to...really.  Come back.  I didn't mean to scare ya! :)

When I talk with you guys inworld, I get a better sense of where my information fails to impart stuff correctly or gives a false impression.  First and foremost, you never have to use a 3D program to use Mesh Studio if you do not want to.  You CAN use one, and it gives you a broader tool set to work with your meshes made with Mesh Studio.  I will be looking at how to teach you to work with MS when you don't want to learn a 3D program, though.  When I show Blender in this blog it will be to illustrate something about mesh in general or specifically for use with Mesh Studio meshes and Second life. :)

You can just look at the video to see them and hopefully get a little understanding of what happens to the uvs, and thus the textures, so you know what you might expect when you attempt to texture a mesh from Mesh Studio that you made with the Object2JoinedMesh script.

I'm using the lectern from a previous post as it was created with this script and is one solid, inseparable mesh.  The textures are basically layered on top of each other and the way that works is what is on top of another uv part will texture the same as any above or below.  However, the UVs are not necessarily in scale to each other because we're using all manner of prims, sizes, cuts, torture and this affects how they lay out.  Being able to examine the UVs gives you better insight into how you can best use textures on the mesh.

Above and beyond that, however, is the ability to rearrange the UVs.  While I will show different ways you can do this in coming posts, I'm starting with the fastest/easiest: Smart UV Project (as in projection).  Even this method can be finessed more than I show in the video.  So bear with me as I try to show you bit by bit so that the written and video tutorials are in manageable chunks than one big wallop to the head.


I do try to show things you need to do what I'm presenting to you in Blender, but we can't take up time to show the basics of getting around in and editing in Blender.  However, I have a page on Blender information where I have listed a variety of information and links on where to learn the basics and more in Blender.  You can download the latest version of Blender at Blender.org.

The one thing I didn't cover in the video, but ran through quickly, I'll elucidate a bit better here:



Once you assign a texture to your model in Blender, to see the texture on your model, you can go into the Properties Bar (toggle with the letter N) and checkmark the Textured Solid button under Shading.

The other thing to keep in mind is that if you do choose to change the UVs, you need to create a new DAE file and this time from the 3D program you are working within.  For Blender, I recommend saving a .blend file of your mesh so you can easily go back and edit more if you need to in future.  As I mentioned in the video, you should try to save all associated files: blend, dae, textures, at the same directory level.  It's wise practice to create a folder for each project and since Mesh Studio has one for your dae if you open the zip, you could consider using that one for storing all the files you make for your mesh.

To export the .dae, select your mesh object, either in object mode or in edit (with all verts selected) and go to the File menu in Blender to select Export and then Collada(default)(.dae).

When it opens the file browser, you want to navigate to your directory, where you're putting your mesh's files, and then before saving, you want to check the areas I'm indicating in the following image:


You can then upload this new DAE file in the same manner that you upload the ones generated by Mesh Studio.

I hope you are enjoying these posts.  Please leave comments or questions.

Happy Meshing!
~ele

It's my mesh, so I'll clean it up!


TheBlack Box's "Sculpt Studio" is a feat of scripting virtuosity, that uses scripted prims, in Second Life, to simulate 3D program functions.  His Mesh Studio can use sculpts from SS, prim linksets or both, to generate mesh all while inworld.

Mesh Studio is 4999 Lindens (that's about $20US, give or take); same price as Sculpt Studio.  For most SL users, building with prims is a fundamental skill you develop to make houses, furniture, clothing, hair and more.  Many are very good at building with prims.  Land in Second Life sustains a limited amount of prims you can rez before it smacks you and says, "Stop!".  The amount varies with the amount of land you own, or rent, or are allowed to rez when visiting.  Hence the all mighty quest to do more with less to maximize your prim allowance.

Notice where the arrows change scale on these shapes even when they are very simple.  The texture being applied can be seen in the lower right hand side.

Sculpts are a kind of mesh hybrid....like mesh but with limitations and LOTS of rules.  They are standardized sizes for the sculpt maps, they use up parts of the sculpt mesh to reinforce and withstand LoD changes (level of detail you see as you move away from an object inworld) or collapse rows into, what are called, poles, to make separations within a single sculpt.  The sculpt map is an exact square which means the rows of the mesh are continuous (think, first, a plane as the starting point; then a cylinder, a sphere or a torus, the four basic shapes from whence all sculpt shapes start).  You are more shaping an object than creating from the ground up.  Due to the rows all being the same size on the map, but squished or stretched on the 3D model, the textures are hard to do in just a 2D image editor; painting in 3D will greatly help this.  To do more with the sculpt, which counts as one prim against the land, we stretch and cajole the points to make more and more out of one sculpt.  This, of course, takes a toll somewhere:  LoD, texturability, smoothness of surface.

With the cylinder shaped into a wineglass (this is the outer surface only/more needs to be done to create the inside of the glass), the same "arrows" texture presents how the sculpt reshaping distorts the texture when it is applied as is; things like projection painting in a 3D program or materials are useful to avoiding distortion.

Once you generate the sculpt map, it is 1024 faces.  A good mesh modeler can do a lot more with that budget than can be done with a sculpt and it can texture far better.

I was able to make this deer head, in Blender, with 1638 faces; less than two sculpts.  It comes into SL with 1 LI.  Note the difference in the handling of the UVs (uv editor lower right) for this mesh deerhead; uvs can have many pieces, called islands, and are closer to the shapes of the mesh object.

There is only one acceptable type of sculpt map for sculpt UVs.  There is an infinite number of ways you can UV map/unwrap your mesh when it's not a sculpt.  You have the full set of tools available in your 3D program to create and build your mesh, and are basically using a small subset of tools when you do sculpts.  Finally, a sculpt works best when closer to an evenly spaced sculpt mesh, but by the nature of making a shape, the first thing we do push and pull the sculpt out of this even space to make it look like our desired object.

Still, for Second Life, there are advantages for using sculpts over mesh for some things.  So they shouldn't be out of the picture entirely.

So let's say you are interested in doing mesh, but you don't want to learn a 3D program or have tried and just don't get it.  Perhaps you have an easier time building up something in prims or need something that is specific in sizing to interact with something else in Second Life.  This is where Mesh Studio comes in.

Prim linkset on left is 22 prims (less the one added for the candle particle).  Colored surfaces (you can have eight total colors which would include the plywood or blank texture if it can be seen on the prims) create material zones on the mesh which you can access in SL, in edit, by using Select Face and applying your texture to the face as you would on a prim face.  The generated mesh was 4 LI with strong LoD.


This linkset was composed of 19 box prims.  The generated mesh was only 1 LI with strong LoD.  Boxes will produce lower LI in most instances.

You get to build with prims and turn them into mesh which will likely be far fewer LI (land impact which is the number of prims the object counts as against your land) than the original prim linkset.  Scripts are provided in the product that generate mesh in two different ways.  In addition, those with Sculpt Studio can create sculpted shapes, that may be unachievable with prims, and  vastly broaden what you can put together to generate mesh with Mesh Studio.  Sculpt Studio owners will find that a Mesh Dropbox has been added in the latest updates for just this purpose.

I will post information, tips, techniques, written and video tutorials to explain and help you get the most out of your Mesh Studio.  I'll show more on using sculpts from Sculpt Studio and how to prepare pieces for use only in SL or further work in 3D programs (I use Blender 2.6x.)  This includes the creation of static meshes and pieces that could be used in rigging for use on an SL Avatar.  Static pieces can be done fully inworld with Mesh Studio and we'll be exploring how to strengthen LoD and create physics meshes so you can go through doors, walk up stairs and stand on floors.  Rigging can presently only be done in a 3D program.

Our TAMA site has a general information page on Mesh Studio and how to get set up to be allowed to upload mesh in Second Life.  This blog will be able to address topics in more depth to make your experience with Mesh Studio enjoyable, and profitable, if you choose.  Feel free to leave comments to ask questions or suggest topics.

Happy Meshing!
~Ele