Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Importing textures to fit specific prims?

Kepster Cure
Paradigm Shifter
Join date: 7 Jan 2006
Posts: 198
03-23-2007 13:06
Does anyone know if their is a way to determine and extract the area of a prim in SL in order to create a texture in Photoshop with those dimensions, so that when it is imported to SL it would fit nicely over the prim when the repeats per meter is set to 0.1
_____________________
Keeping the boundaries distant.

-Cure
Chosen Few
Alpha Channel Slave
Join date: 16 Jan 2004
Posts: 7,496
03-23-2007 13:22
I'd encourage you not to think of it that way. Textures have to be measured in powers of two (see the sticky at the top of the forum for more on this). Prims have no such restrictions. Textures will never work out so that they fit perfectly at 1x1 repeat, unless the prim has been pre-sized with the texture proportions in mind, or the texture has been pre-distorted with the prim size in mind. The former is obviously very restrictive to you as a builder, and the latter isn't always visually desirable.

For an example of pre-sizing a prim to fit a texture, let's say you've got a 256x512 texture, that's a 1:2 ratio, so for 1:1 fitting on a prim, the prim would also need to have a 1:2 ratio. That means the prim could be 1x2 or 2x4 or 0.5x1 or any other size you want, as long as the ratio of height to width remains the same. It's all about proportions, not size.

For a prim that doesn't fit neatly into the available texture proportions, you need to pad your texture onto a larger canvas. For example, say you've got a prim surface that is 5x2. There's no texture size that will fit that ratio perfectly. What you'll want to do therefore, is make your texture use 100% of the canvas in one direction, and 40% in the other direction. When you slap it on a prim, set the repeats to 1x0.4, and the texture will fit perfectly.

Alternatively, you could stretch the texture to fit the whole canvas, and then let the prim unstretch it by using 1x1 repeat, but it won't look quite as good.
_____________________
.

Land now available for rent in Indigo. Low rates. Quiet, low-lag mainland sim with good neighbors. IM me in-world if you're interested.
Kepster Cure
Paradigm Shifter
Join date: 7 Jan 2006
Posts: 198
03-23-2007 16:46
From: Chosen Few


For a prim that doesn't fit neatly into the available texture proportions, you need to pad your texture onto a larger canvas. For example, say you've got a prim surface that is 5x2. There's no texture size that will fit that ratio perfectly. What you'll want to do therefore, is make your texture use 100% of the canvas in one direction, and 40% in the other direction. When you slap it on a prim, set the repeats to 1x0.4, and the texture will fit perfectly.

Alternatively, you could stretch the texture to fit the whole canvas, and then let the prim unstretch it by using 1x1 repeat, but it won't look quite as good.


I understood the first part but I am unclear as to what you mean by "available texture proportions" and how to pad it in the way you have described to fall properly when applied to the prim, would you mind showing me what you mean, I really appreciate your help with this.
_____________________
Keeping the boundaries distant.

-Cure
Chosen Few
Alpha Channel Slave
Join date: 16 Jan 2004
Posts: 7,496
03-23-2007 18:40
From: Kepster Cure
I understood the first part but I am unclear as to what you mean by "available texture proportions"

See the sticky at the top of this forum, entitled Texture Size, Pixel Counts, Video Memory, and File formats? Read it. It contains a section listing every single texture size SL allows.

To summarize, all textures must be measurable in powers of two, as I said before. This is a requirement of OpenGL. SL allows any power of two between 8 and 1024. Any texture that doesn't fit those measurements will be resized by SL at the time of upload, and the results are not always pretty.

From: Kepster Cure
and how to pad it in the way you have described to fall properly when applied to the prim, would you mind showing me what you mean, I really appreciate your help with this.


Take a look at the (ugly) image below. See how the texture does not use the entire canvas? The empty space is called "padding", and is there just to keep SL from resizing the texture on you. It upsizes the canvas in order to make it fit the closest possible SL-compatible size to the texture's actual proportions.

In this example, if you set the horizontal repeats to 1, and the vertical to 0.8, you'll see that the texture will perfectly cover the surface of a 5x2M prim (or any size with the same proportions), and you won't see any of the padding.


_____________________
.

Land now available for rent in Indigo. Low rates. Quiet, low-lag mainland sim with good neighbors. IM me in-world if you're interested.
Kepster Cure
Paradigm Shifter
Join date: 7 Jan 2006
Posts: 198
03-23-2007 19:50
The insight you have provided is invaluable! Thank you sooooo much for clearing that up:D
_____________________
Keeping the boundaries distant.

-Cure
Tod69 Talamasca
The Human Tripod ;)
Join date: 20 Sep 2005
Posts: 4,107
03-24-2007 04:57
*sigh* I'd sell my mother for good ol' UVW Mapping Co-ordinates in Second Life. :(
Rachel Darling
Registered User
Join date: 3 Jun 2006
Posts: 95
03-24-2007 06:15
Because I'm lazy and I suck at math when figuring out repeats --

Sometimes, if my texture absolutely MUST fit as a 1x1 repeat and my prim is not of the same ratio as the original graphic, I create the texture with a 1-to-1 ratio to the size of the target prim, then resize to the closest standard SL texture size before uploading.


Example: A painting that is 175p x 300p

Create the texture at 175x300 and do any post work to it that you need. At the last, I change the image size to 128x256 in PS (turn off "Constrain Proportions" in the Image Size dialog) and then upload into SL. Now, create your prim at a size of 1.75m x 3.00m and place the texture on it at full size. (edited to correct the typo Chosen was kind enough to point out in a later post.)

You may get a little loss of detail, but in general it's not noticeable. This is more effective when the texture is only repeated once on a prim; if you're trying to tile it, you'll get seams.

One last note -- I don't really advocate this for doing building textures, for several reasons. For one, as stated above, you'll generally lose the ability to tile the texture. For two, every unique texture you use in your build must be loaded into the graphics card of the client, and texture loading is an enormous cause of lag. Far better to create a few textures that are close to the correct ratio, and then scale your build around them and reuse the same ones over and over. Your buildings will rez much faster, as each unique texture only has to be downloaded to the graphics card once.
Chosen Few
Alpha Channel Slave
Join date: 16 Jan 2004
Posts: 7,496
03-24-2007 07:09
From: Rachel Darling
Now, create your prim at a size of 175p x 300p and place the texture on it at full size.

How is it that you're measuring prims in pixels? That's not possible. In-world 3D geometry has no correlation to pixels whatsoever. Pixels are only a function of your 2D computer screen, and are completely arbitrary as far as the 3D world is concerned.

Try this. Rez a default cube. Zoom in on it so it fills your whole screen. Assuming you have an average size monitor, that cube is now somewhere between 1000 and 2000 pixels wide. Now zoom out as far as you can. The same cube might now just be a single pixel. It's size hasn't changed though. It's still half a meter.

As I said before, it's all about ratios, not about any absolute sizing. If you want a prim that's guaranteed to fit your 175x300 pixel texture, start with a cube that is 1.75x3 meters, and then uniformly scale it from there (via the white corner handles) to any size you want. It works because 1.75:3 is the same ratio as 175:300, not because the prim is measurable in pixels in any way.

Let me help you with figuring out your repeats. Again, it's all a question of ratios. You don't need to be good at math in any way, shape, or form. You just need a calculator, and about 5 seconds of time. Just take the area of the canvas you want to use, and divide its size by the size of the whole canvas. You'll get a decimal on your calculator. That decimal is the exact same decimal you'll want to use for your repeat value in SL. It's really, really simple.

Let's take your 175x300 example, and work with that. Since 300 is so close to 256, I'd probably downsize to 149x256 first, but for the sake of the example, let's assume you're not doing that. This will give us a chance to demonstrate the math twice instead of just once.
  1. Starting with 175x300, we'd choose a padded canvas size of 256x512. I assume you're with me so far on that.


  2. Okay let's figure out the repeats on the short side:

    175 / 256 = .684
    Set your repeat for that dimension to .684 in SL.


  3. And now the long side:

    300 / 512 = .586
    Set your repeat for that dimension to .586 in SL.


That's all there is to it. It's no more time-consuming or thought-intensive than the resizing you were doing previously. It will result in better looking textures though.

I do hate to think of all the wasted pixels that are in place if padding is over-used, but it's no more wasteful than resizing to fill the whole canvas.

If someone's smart about it, it can actually save pixels, as the empty space can be used for mounting additional textures, assuming they'll fit, to be accessed by using offsets in SL in addition to repeats. For example, you could fit an 81x512 and a 175x212 on the same canvas with your 175x300.
_____________________
.

Land now available for rent in Indigo. Low rates. Quiet, low-lag mainland sim with good neighbors. IM me in-world if you're interested.
Johan Durant
Registered User
Join date: 7 Aug 2006
Posts: 1,657
03-24-2007 07:41
From: Rachel Darling

Sometimes, if my texture absolutely MUST fit as a 1x1 repeat and my prim is not of the same ratio as the original graphic, I create the texture with a 1-to-1 ratio to the size of the target prim, then resize to the closest standard SL texture size before uploading.

This is the right approach to take when preparing an image for your classified ad.
_____________________
(Aelin 184,194,22)

The Motion Merchant - an animation store specializing in two-person interactions
Ceera Murakami
Texture Artist / Builder
Join date: 9 Sep 2005
Posts: 7,750
03-24-2007 13:53
From: Rachel Darling
Now, create your prim at a size of 175p x 300p and place the texture on it at full size.


From: Chosen Few
How is it that you're measuring prims in pixels?


I believe Rachel meant you make the prims have the intended aspect ratio? For example. male a prim that measures 1.75 Meters by 3.00 Meters in the above case.

I have used this before to get things like a round alpha-mapped window on a rectangular wall texture. Maybe I want a wall that will be 5 M high and 7 M wide, with a round window somewhere on it. I make the original art 1000 x 1400 pixels, which is the same aspect ratio. I scale that to 512 x 512 and import. Placed on the 5M x 7M wall, the window is round.
_____________________
Sorry, LL won't let me tell you where I sell my textures and where I offer my services as a sim builder. Ask me in-world.
Rachel Darling
Registered User
Join date: 3 Jun 2006
Posts: 95
03-24-2007 14:43
From: Chosen Few
How is it that you're measuring prims in pixels? That's not possible. In-world 3D geometry has no correlation to pixels whatsoever. Pixels are only a function of your 2D computer screen, and are completely arbitrary as far as the 3D world is concerned.


Indeed...it was a typo; thank you for taking the time to point it out in such detail, Chosen. I'll be certain to proofread more carefully next time.

What I MEANT to type was 1.75m x 3.00m