Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Can someone explain the maths behind shear and topsize?

Ledje Gorky
Registered User
Join date: 1 Jun 2005
Posts: 126
01-17-2006 12:34
Title says its all.

I've tried several plugins for both PS and Gimp. None of them seem to work for me.

So i decided to do it manually.

But before i invest alot of Lindens uploading testpatterns trying to determine how it works......maybe some of you already know :p

The idea is to manually correct for shear and topsize AND BOTH in Gimp (or PS) using the built-in tools.

The one giving me a usefull answer will receive.......my eternal gratitude (hey im poor i dont have alot to give :) )
Davan Camus
Registered User
Join date: 13 Sep 2005
Posts: 67
01-17-2006 14:57
Sure!

(All of this presumes the H and V Repeats are both 1.0.)

The mapping is from a RECTANGLE (your source texture) to a TRAPEZOID (the prim face, with one or both of shear and scale applied, but the top and bottom still parallel).

The transformation is simple. Divide your source RECTANGLE into two triangles, from bottom-left to top-right. Similarly, divide your destination TRAPEZOID (which might be a rectangle, of course), into two triangles. (If scale=0, one of the triangles will be empty.)

The two triangles will each be mapped to their counterparts. In the case of scale=1, and some shear, then you can just "skew" in photoshop. In the case of other scaling, you need to correct the two halves individually.

Hope that helps...
_____________________
Visit Cubes at Alice 100,18.
--------------------------------------------------
Davan Camus, born: 2005 September 8
Out-world location: Santa Cruz, CA
UI Proposal: http://davancamus.hexaflexagon.com/blog/?p=39
Dianne Mechanique
Back from the Dead
Join date: 28 Mar 2005
Posts: 2,648
01-17-2006 15:12
From: Davan Camus
Sure!

(All of this presumes the H and V Repeats are both 1.0.)

The mapping is from a RECTANGLE (your source texture) to a TRAPEZOID (the prim face, with one or both of shear and scale applied, but the top and bottom still parallel).

The transformation is simple. Divide your source RECTANGLE into two triangles, from bottom-left to top-right. Similarly, divide your destination TRAPEZOID (which might be a rectangle, of course), into two triangles. (If scale=0, one of the triangles will be empty.)

The two triangles will each be mapped to their counterparts. In the case of scale=1, and some shear, then you can just "skew" in photoshop. In the case of other scaling, you need to correct the two halves individually.

Hope that helps...
This is right. But it doesn't help you to figure out exactly how it's deformed.

If you are talking about deforming the texture in pshop so the it comes out "undeformed" onthe prim, I have done this a lot and recently just the other day. Unfortunately you need trig to figure it out. :o

if you divide the original square prim into the two triangles as the poster said, the triangle on the left (the top one), is hopelessly squished in every way but the horizontal dimension. You can pretty much forget any kind of texture except "mottled" ones or ones involving horizontal stripes to look any good at all. This is the triangle that disapears when top size equals zero.

The triangle on the right side (lower one) is also distorted, but it is only skewed horizontally. A texture can be placed that is horizontally skewed in pshop (in the revrese direction), by the exact same amount. What you need the trig for is to determine that angle.

Conversely, you can scan in a protractor and load it on a prim and actually measure the angle in SL. As long as you get within a degree it will generally look okay.

I have some examples in world I can show you if you dont get it, but the best thing is to put a "white tile" texture (in your library) on a prim at 10 by 10 repeats to get a graph paper like effect. If you play with the controls you can easily see whats happening.
_____________________
.
black
art furniture & classic clothing
===================
Black in Neufreistadt
Black @ ONE
Black @ www.SLBoutique.com


.
Ledje Gorky
Registered User
Join date: 1 Jun 2005
Posts: 126
01-18-2006 05:47
thx davan and Dianne for replying.

Indeed, the trigonometry for determining the shear isnt that hard, i noticed.
The only downside i noticed so far is that for the texture to appear correct on a sheared prim, you not only need the corrected texture (photoshop) BUT also the mirror-image of it. (the other side of the prim)

For the topsize , i found this very interesting webpage : http://www.robinwood.com/Catalog/Technical/SL-Tuts/SLPages/SLTexTutRingStart.html

Still, combining the 2 seems difficult.

More replies are still welcome.
Robin Sojourner
Registered User
Join date: 16 Sep 2004
Posts: 1,080
01-18-2006 11:50
:D

Yep, I did that about a year ago.

For combining the two, you should be able to do the topsize thing, and then the Shear math. I haven't tested it, though, and I'm not going to be able to test it today.

And yeah, you do need two different maps, one for each side, because the UV on the opposite side has been flipped, (which is a Good Thing, because otherwise it would always be a mirror image of your texture,) but the warping still works by axis point.
_____________________
Robin (Sojourner) Wood
www.robinwood.com

"Second Life ... is an Internet-based virtual world ... and a libertarian anarchy..." Wikipedia