Best Uv Unwrap Software

0 views
Skip to first unread message

Rosetta Ockman

unread,
Aug 5, 2024, 9:08:59 AM8/5/24
to snowilmansi
Youcan never have a UV texture for a curved surface without some stretching. Having said that, for a UV sphere, a straightforward way to minimise the stretching is to unwrap as gores (like an old-fashioned globe):

UV sphere.jpg1628737 306 KB




Something that can help if you really need to unwrap an UV Sphere instead of using the subdivided plane warping is to change the poles topology.

Example a Sphere projection UV with a default UV sphere :


All faces have the same area, which may be useful for certain types of UV mapping containing non-organic textures. An example that comes to mind is an isocahedral die or billiard balls where stretch must be minimized near the point where the number is printed onto the ball.


However, my attempts at neatly unwrapping an icosphere have mostly failed (smart UV unwrap works perfectly for using baked textures, however I was hoping for something more like the example in the 6th post of this thread, with a nice clean rectangular map).


How can an icosphere (I assumed the term "geosphere" in the thread was referring to a (geodesic) sphere made of triangles, like an icosphere) be cleanly unwrapped? Or if it's not possible, is there another way to do this which I'm missing?


EDIT: It just occurred to me that some of the issues which people are having with stretching in their textures may be related to the Sub-Divide UV's Option in either of the two sub-D modifiers(Multi-res).


I guess what you want is myriahedral projection. I did this once for an icosphere as a test. AFAIK there is no way to do this automatically, i had to place the seams by hand. I uploaded my old .blend file here, have a look at it and see if it is what you need.

This is what the UV layout looks like:




For your case: When I was making a pool balls for an animation I used a UV sphere and created separate materials for the (White or coloured) sections at the poles and another material for the number band applied to the faces around the middle. Then I could very easily seam the edges of this equatorial region and UV map it with a band and number.


Is it ever acceptable to use unwrap()/expect() in rust production level code? The more articles I read, the more opinions I see about avoiding unwrap at all costs but it seems as though most crate functions return a Result or an Option type, which would result in so many match or "if let" statements if unwrap/expect is not used.


For example, say I had a function that has 5 different function calls in it that all return a Result type. Would it be best practice to handle every single one within the function with a match statement or would you normally just propograte up the error to the caller by returning Result?


If you believe that the error can never happen, use unwrap or expect. In other words, if the only way for the error to happen is that there is a bug in the code somewhere, panic. Don't propagate errors resulting from bugs.


The post by burntsushi is very good, and I just want to add that if you have a multithreaded or async program, it is important to remember that threads and tasks are panic boundaries, so you should have some means of propagating them. That is, if you're using expect when it would only fail due to a bug, you should probably expect the JoinHandle of the corresponding thread if you can.


Thank you for the detailed answer, I agree that in most circumstances it is best to have the caller decide what to do. But, by propagating errors via ? to the caller, doesn't that cause generic error displays which would be a bit more difficult to debug?


Each one of those operations results in an .unwrap(), which would propagate up to the function caller because of ?. If the function caller just does a generic error!("Failed to fetch data and parse to u32");, doesn't that provide a little less context as to what actually went wrong (i.e. fetch vs json parse vs cast)?


If I'm pretty sure something isn't possible, it should shout loudly if I'm wrong so I can go fix that. But I also shouldn't be forced to handling things that never happen in practice, because making people write a bunch of never-tested error handling paths reduces both velocity and reliability.


(Assuming you have a reasonable path to get telemetry about the failures and deliver updated builds, as well as an elegant handler to turn things into 500s or save recovery information or whatever. But those are all things you ought to have no matter what you're doing, because lots of things might panic and they're just good anyway.)


As far as I am concerned unwrap() is an admission that I have no clue as to how to proceed in the face of that error. Or a statement that if that error happens there is no sensible way to recover. Either way it's better to abort immediately rather than try and limp along in a broken state. It's probably better to use expect() to help with future debugging.


Im trying to unwrap a dog model that Ive made, Ive upped the polycount a bit from my normal models. All the UV unwraps i see for quadrupeds tend to be spread out like a cow hide on the floor. This kind of makes sense, however, I don't seem to be able to unfold the shell so that all quads are equal. Splitting the shell in half seems to work much better.


I've attached a grab of how the half looks - its top edge follows the contours of the animal - wouldn't making that flat and joining it with the other half mean it couldn't be unfolded properly? or am i doing something wrong perhaps?


When unwinding occurs, it is possible to catch the panic anddo something with it. For example, a web server might catch panics that occurinside of request handlers to avoid bringing down the entire server. Anotherexample is a test harness that catches a panic that occurred in a test, so thatother tests may be executed and the results pretty printed instead of bringingdown the entire harness immediately.


While panics can be used for error handling, it is generally regarded as a poorform of error handling. Notably, the language does not have good support forusing panics as error handling and, crucially, unwinding is not guaranteed tooccur.


No! Routines like unwrap() or expect() only panic if its value is not whatthe caller expected. If the value is always what the caller expects, then itfollows that unwrap() and expect() will never result in a panic. If a panicdoes occur, then this generally corresponds to a violation of the expectationsof the programmer. In other words, a runtime invariant was broken and it ledto a bug.


(Note: A std::num::NonZeroUsize has benefits other than enforcing thisparticular invariant at compile time. Namely, it permits the compiler to doa memory layout optimization where in a Option has the samesize in memory as a usize.)


There are two uses of expect() here. In each case, the expect() messageis somewhat useful, but the real meat of why expect() is okay in both casescomes in the form of comments. The comments explain why the from_str_radixand from_u32 operations will never fail. The expect() message just gives anadditional hint that makes the panic message slightly more useful.


My contention is that none of these really add any signal to the code, andactually make the code more verbose and noisy. If a Regex::new call failswith a static string literal, then a nice error message is already printed. Forexample, consider this program:


Basically, at a certain point, writing the same expect() message over andover again for the same common operations becomes a tedious exercise. Instead,good judgment should be employed to determine whether to use unwrap() orexpect() in any given situation.


One common argument against the idea of using good judgment is that it canbe nice to remove human judgment from the equation. If one lints againstunwrap(), then one forces every programmer to write something other thanunwrap(). The thinking goes that if one forces this step, then programmersmight think more deeply about whether their code can panic or not than theywould otherwise. Needing to write expect() and come up with a message, Iagree, exercises more brain cells and probably does result in folks thinkingmore deeply about whether a panic can occur.


A parting thought for for what's left of 2020... It's seemed to me for a long time it's time to move towards deprecating the force unwrap operator from the Swift language. At this stage I'd suggest that it any usage becomes a compiler warning as it is for most Swift code linters. It's generally a sign of laziness and there are almost always better alternatives that make the developer consider how to properly handle an optional being nil. Swift has done a great job of preventing undefined behaviour and yet it leaves this potential foot gun laying around which was at one point was a suggested fix-it. I'd lay odds it has to be 90% of the time a Swift program crashes it was due to a thoughtless force unwrap. It's just too easy to use.


I don't agree with this point. It's an assertion the programmer is making about their program and is no more a sign of laziness than any other assertion. You could make it more verbose, but it seems hard to justify the code churn and you give up the nice consistency between !, try! and as!. You could remove it and force people to write a custom message explaining the assertion, but that message is generally going to communicate the exact same thing: I thought that this couldn't be nil at this point but it is.


What should I use in situations like these after force unwrapping is deprecated? I don't know any other way to handle a situation when optional is never nil. I could use if let or ?? but that suggests that the result could be nil


Somewhat agree, but it seems to exist in Swift more because of UIKit + storyboards. Unfortunately lifetimes of some of the UIKit objects should be the same theoretically, but for historical reasons they are not and you end up with a lot of implicit and explicit unwrapping.


Moreover, when you are confident something can not be nil but say the language forces you to unwrap nicely, you may not have a clear bail out path - you simply may not know what to do at runtime if it's nil. In these situations I'd rather let my app crash and let me know something is wrong, e.g. the storyboard connection didn't work, or something even more fundamental.

3a8082e126
Reply all
Reply to author
Forward
0 new messages