KatsBits Community

Game Editing => General Content Creation => Topic started by: ward on May 12, 2011, 02:12:44 PM

Title: [UDK] Blender UV problems
Post by: ward on May 12, 2011, 02:12:44 PM
(https://www.katsbits.com/community/proxy.php?request=http%3A%2F%2Fimg853.imageshack.us%2Fimg853%2F7791%2Fhousesuverrors.jpg&hash=17b468fdb078dc0b194f80251a588ead80fdfe6b) (http://img853.imageshack.us/img853/7791/housesuverrors.jpg)

Any automated ways to fix the darker parts? Sometimes it seems fixed by rotating the corresponding UV island as far as i can remember. I kindof gave up on UDK because of this and the removal of foliage since last year. I hope someone here knows what the exact problem is and how to fix it, this was exported as FBX.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 12, 2011, 04:23:22 PM
There are a couple of 'darker' areas on the mesh that look like they're cause by 'bad' mesh smoothing (either the exporter isn't keeping them, corrupting them or the mesh doesn't have any). So, check the FBX exporter is properly exporting smoothgroups and/or you applied any modifiers before exporting (depending on Blender version). Try that and see if it fixes it.. if not post (or send) the *.blend if you can.

PS: you should be able to use the [ img ]image url[/ img ] tag on imageshack files (remove spaces).
Title: Re: [UDK] Blender UV problems
Post by: ward on May 12, 2011, 05:11:24 PM
Thanks for the fast reply, the FBX exporter from blender 2.49b does not export smoothgroups, I used the edgesplit modifier to get sharp edges. Blender 2.5x produces FBX files that crash UDK, and with ASE I keep having trouble.

Btw thanks for including the image, I figured it was too wide for that so I linked it. (and in forums they freak out about that lol)
Title: Re: [UDK] Blender UV problems
Post by: kat on May 12, 2011, 05:48:29 PM
Hmm.. What sort of trouble are you having with 2.49 exported ASEs? The script should be saving those in a way that UDK understands.. mind you, that assumes Epic haven't changed something in UDK since the last time I used it. I'll have to update and test to make sure.

No probs re. the image, the forum should auto-resize but sometimes it breaks depending on the source.
Title: Re: [UDK] Blender UV problems
Post by: ward on May 12, 2011, 06:14:59 PM
You mean this script right? http://www.katsbits.com/files/ase/goofosASE-2.44v0.6.10b_UT.zip (http://www.katsbits.com/files/ase/goofosASE-2.44v0.6.10b_UT.zip)

I'll just try it again and post my results. So if I just apply an edgesplit modifier first, it will automatically create proper smoothgroups for me? (Like this article: http://www.katsbits.com/tutorials/unreal/setting-up-smooth-groups-correctly-in-blender.php (http://www.katsbits.com/tutorials/unreal/setting-up-smooth-groups-correctly-in-blender.php))
Title: Re: [UDK] Blender UV problems
Post by: kat on May 12, 2011, 06:28:04 PM
Yes that's the one, works with 2.49b despite the filename. And yes, make sure you 'apply' the modifier before export otherwise it'll be ignored (iirc). Do a test export first and assign the modifier just to make sure it's working, if it imports properly (you should see the facets associated with the smooth groups) go back and set the smoothing up as per what you want (using 'sharp' edge marking) on the mesh if it the mesh.
Title: Re: [UDK] Blender UV problems
Post by: ward on May 12, 2011, 06:29:27 PM
I tried that script, and from what I see in UDK with UV overlay it seesms to have screwed up one of my 2 UV layers, in UDK it's layer 1 (0 and 1 being used). However, the layer order seems to be inverted relative to the layer order in blender (or it scaled down my UV map for my materials, which of course is out of bounds, since i use tiling materials).
Title: Re: [UDK] Blender UV problems
Post by: kat on May 12, 2011, 06:39:51 PM
OK, remove UV2 and re-export, you need to make sure that smoothing is being exported prooperly first... if that works then you know for definate there's an issue using a second UV layer. If that's the case then it means trying to figure out a way around that issue; doesn't UDK have the ability to generate a lgithmap UV layer on models? If it does it might be worth ditching UV2 in Blender and using UDK for that.

Just thinking about it actually, it may be because you're mixing UV map types so trying to use both on the same mesh may cause a problem regardless as to what you do to the mesh UV to fix it, it's probably always going to automatically re-map UV1 to match UV2 (within bounds that is).
Title: Re: [UDK] Blender UV problems
Post by: ward on May 12, 2011, 06:45:05 PM
UDK can repack UV's into a channel of your choice, maybe that's good enough to create a lightmap from the material UV's, i'll try that (after exporting with just one UV layer containing my material UV's) and post my results, thanks again.
Title: Re: [UDK] Blender UV problems
Post by: ward on May 12, 2011, 06:48:55 PM
I just tried and the problem remains the same, UDK seems to rescale my UV map. Also there are no material slots exported with the script, everything is one single material.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 12, 2011, 07:10:09 PM
Can you send me the *.blend (include the ASE file as well)?
Title: Re: [UDK] Blender UV problems
Post by: ward on May 12, 2011, 07:23:34 PM
Yep:

http://www.filefactory.com/file/cb38d04/n/TestCase.blend
http://www.filefactory.com/file/cb38d05/n/TestCase.ase
Title: Re: [UDK] Blender UV problems
Post by: kat on May 12, 2011, 07:32:19 PM
Stick um in a zip and email them, that site gives me problems when trying to download files from there - info@katsbits.com.
Title: Re: [UDK] Blender UV problems
Post by: ward on May 12, 2011, 07:39:19 PM
Done, not as zip though sorry, nothing available to make zips atm.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 12, 2011, 08:45:13 PM
No probs, files received... OK there are a couple of things you need to look at;

1) remove all *dead* material references from your models, especially so if you're exporting *sections* of a larger mesh broken down into smaller more manageable model units - this tends to leave unwanted assignments on the smaller sections that cause trouble.

2) you ideally need to have an actual bitmap image associated with both the individual materials and the the UVW map applied to the mesh, if there isn't one there the exporter simply assumes a 'blank' mesh (so to speak) and appropriately formats the resulting text file - physical texture assets are actually needed because that's what game engines latch onto for shader/material path information; when you look at the asset browser/editor, the 'path' info you see comes from the presence of the texture when the mesh was exported.
Title: Re: [UDK] Blender UV problems
Post by: ward on May 12, 2011, 09:57:29 PM
I'll try with some images, thanks, I'll let you know if that helped in a bit, didn't think of trying that, I assumed it didn't mather.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 12, 2011, 10:14:43 PM
Yeah it's a 'myth' that seems to persist in the UDK community for some reason; I know the tools can import 'blank' meshes, but that ability wasn't implemented or intended to be used as a legitimate step in the production process like that. There are no shortcuts to properly optimised and set-up meshes in other words.

An additional but incidental point you might want to look into is how you've done your UVW map, it's particularly important because of your wanting to use tiled textures. Right now what you have is this;

(https://www.katsbits.com/images/misc/udk-model-uvw-unoptimised_sml.jpg)

The problem here is that you've got UVW map sections pointing all over the place so if you assume for the sake of argument that you use a tiling 'wood' texture, it means the grain of the wood will also be all over the place. So... what you should ideally be doing is something similar to the following.. map each section based on *material usage* so all object that use the same material are pretty much (certainly as much as is possible) mapped to the same texture image. You ideally need to reconnect a lot of those smaller UVW islands back into larger segments, there are technical reasons for it but suffice to say here it makes your job as an artists easier come time to texture the mesh.

(https://www.katsbits.com/images/misc/udk-uvw-optimised-direction_sml.jpg)
(https://www.katsbits.com/images/misc/udk-uvw-optimised-texturebounds_sml.jpg)

An Additional point as well is that if you UVW map similar to the above, you may then be able to bake ambient occlusion per-texture, per-group.
Title: Re: [UDK] Blender UV problems
Post by: ward on May 13, 2011, 12:13:39 AM
Is it a must to puzzle the islands back together? Faster to project from view those parts then I guess.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 13, 2011, 12:54:40 AM
In a word "yes", it's quite easy to do using UVW "Seams". Read this tutorial (for 2.49 and/or below) (http://www.katsbits.com/tutorials/blender/blender-basics-unwrapping-uvw-maps.php)

Those technical reasons I alluded to previously are important to be aware off, essentially when you're making something you need to make it as easy and quick as possible for the game to do what it's trying to, UVW maps are interpreted by an engine the same/similar way to a mesh, so when it looks at a UVW like the one you originally did its having to work harder to read what's there.

Think of it in a literal sense.. look at the two images below. You can immediately see the difference between the two, the original being quite 'chaotic' because of the mapping - your eyes 'dance' all over the place as you try to make sense of what you're seeing, right? A game engine would pretty much do the same thing when looking at that mesh so it's always best to unify and simplify, the bottom image.

(https://www.katsbits.com/images/misc/udk-uvw-gable-end-original_sml.jpg)
(https://www.katsbits.com/images/misc/udk-uvw-gable-end-remapped_sml.jpg)
Title: Re: [UDK] Blender UV problems
Post by: ward on May 13, 2011, 01:45:40 AM
Thanks, the ASE script keeps giving me trouble though, I cannot get it to create material slots, but it also has these dark spots... I Guess it's just because not everything is rotated the same way, doing this by hand (basically fixing what smart projections ruined, it rotates the crap out of UV islands), or projecting them from view is going to take so much time that I guess I should just forget about it. Thanks anyway.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 13, 2011, 02:03:47 AM
Read the tutorial linked to above (http://www.katsbits.com/tutorials/blender/blender-basics-unwrapping-uvw-maps.php), if you made the meshes in Blender then you'll already have the skills to address this problem and quickly fix it using Seams (Select an edge, "Ctrl+E > Mark Seam", then "Unwrap"). You've done some decent models (based on the test you sent through) so it seems a shame not to bring the UVW maps up to par as well. I'll see about sending you back the test you sent in the next day or two so you have something as a reference. Work on something else in the meantime so you don't burn out on these particular assets.

[EDIT] was just taking another look at the mesh, you need to go over it carefully and delete any isolated vertices and/or edges before exporting I found a couple attached to the beam sections. Remove those as they can cause additional issues if let in place.
Title: UDK, ASE, Python and export problems
Post by: kat on May 13, 2011, 06:35:35 PM
Just discovered a potential problem that might explain some of the problems you're having. I imported the test mesh into UDK (Nov 09 and Apr 11 versions) to double check the meshes had been exported correctly. As you can see below the first image has 'black' spots similar to the problem you're having - they are smoothing related. The second image shows the mesh without this problem. Both meshes are exactly the same so the same export procedure was done to both (separate meshes are joined together, modifiers are applied before export etc).

The *only* difference between the two is that for the first export Blender wasn't using the full (correct) version of Python for 2.49 because my systems Python path is setup for 2.5(n) testing (http://www.katsbits.com/tutorials/blender/setting-up-windows-python-path-system-variable.php). On removing the path variable and re-exporting the mesh (to a different revision number) it appears to have exported correctly with mesh smoothing intact. (note the material references by the way).

This is a speculative assumption as I've only tested this on one machine (running 32bit Vista SP2) which is using Blenders own ability to self-discover where Python is installed (as you'll see in the console when starting the application). If you have the Python system variable in place, try deleting it - check Blenders console before hand though to see if it's the correct version or if its using it/found it.

If you still have problems, try detaching the mesh into its original elements, cleaning them up and them re-exporting, that's what all I did to get this to work.

Mesh exported 'incorrectly' because Blender isn't using full Python
(https://www.katsbits.com/images/misc/udk-ase-export-python-problem_sml.jpg)

Mesh exports correctly because correct Python references are used?
(https://www.katsbits.com/images/misc/udk-ase-export-fixed-no-python_sml.jpg)
Title: Re: [UDK] Blender UV problems
Post by: ward on May 13, 2011, 10:05:46 PM
It's definitely not a smoothing problem, these black spots on my screenshot are complete area's that correspond with UV islands.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 13, 2011, 11:44:58 PM
Yeah as mentioned in a previous post, those black splodges usually happen for two reasons, lightmap errors or smoothing (sometimes both), I can't really confirm either without being able to look at the entire mesh the test section belonged to so can you send that? You'll need to include details regards to how many textures the mesh should be referencing (names aren't important).

And you do mean these right? You said said there are problems with the mesh but haven't actually highlighted which parts are the actual errors - looking at the mesh without knowing what your textures are like, I can read quite a few problems in the image (highlighted below).
(https://www.katsbits.com/images/misc/udk-housesuverrors.jpg)
Title: Re: [UDK] Blender UV problems
Post by: ward on May 14, 2011, 06:02:26 PM
The 2 upper left circles, with the question mark in between, are just lighting artifacts, don't mind them, they disappear when lighting is built. The others are indeed what I meant. I meant just the parts that are obviously much darker, on both the wood, and the yellow material. I didn't have much time for it lately. But when I have time I will either try to unwrap one of my models correctly by hand (to see if it looks ok then), or try to remove the code portion that rotates the islands out of the smart projections script. (If you have any tips on that, very welcome of course.)

I'll let you know if this works out, if it does not I'll email you one of the models in the screenshot, the testcase is indeed just a part of a model, thought that would be more practical.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 14, 2011, 06:29:34 PM
Have you tried just doing a quick test and unwrapping one of the buildings UVWs so they're contained within bounds? If the problem appears to be associated with the UVWs extending beyond the texture borders just remap them inside and see what results you get when you then export with and without the second lightmap UV layer.
Title: Re: [UDK] Blender UV problems
Post by: ward on May 14, 2011, 11:32:32 PM
No, but I modified the smart projections script from blender 2.49b (uvcalc_smart_project.py) , to not rotate the crap out of my UV's while packing them, now the output is much better, everything in the correct direction. Only sideeffect is that i have to rotate the UV's for slim horizontal parts manually, but that's just a few seconds, and any other angle then horizontal still gets made vertical by the script :) . I just tested this with one of the models and so far so good, I'll let you know after I tested some more.
Title: Re: [UDK] Blender UV problems
Post by: ward on May 16, 2011, 01:45:07 PM
The dark spots are gone, but I keep having small problems, to be clear: I'm using the FBX exporter builtin in blender 2.49b, not the ase export script. I'm going to quit it for some time, I've had enough of this crap for now.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 16, 2011, 05:40:32 PM
Send me one of the buildings if you want and I'll take a look at it.
Title: Re: [UDK] Blender UV problems
Post by: ward on May 20, 2011, 12:41:15 AM
A couple of the models are unwrapped now, almost without any problems, I spotted a few problems that are so minor I don't mind them much. I even distorted the models to make them look more realistic/not straight. If I have more problems I will email a model. First I'll unwrap the others too as good as I can. Smoothing and everything now works nice with the FBX exporter on 2.49b (with edge split modifier though, no real smoothgroups). Disabling some rotate stuff in the smart projections export script is mainly what solved the dark spots problem. And the only trade in is dat now I need to rotate horizontal parts of the model by hand (so all the other slim islands are still automatically rotated to be vertical).

The ASE script was giving me trouble because apperantly it requires a unique texture / material channel (or what is it called), but the .FBX just seems to do the job better for me. I also tried the updated version of the ASE script for 2.57b (at the UDK forum iirc, I saw your name between the messages too). Kept having trouble with both.

And something unrelated to the problem I had (but problably not worth to open a new thread): Someone told me that if a mesh has 7 materials for instance, the intire mesh will be rendered 7 times, is this correct or bs? If it is I guess creating components per material is the best way to export i guess? Now I just export the intire models.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 20, 2011, 01:04:15 AM
Good to see you're finally getting the results you're after, it's often a case of just playing with what you're doing to find the best solution, so if *.fbx are working ok then stick with that as UDK is supposed to have better support for that format. And yes, the ASE script to 2.57 is still WIP so it'll cause problems whilst it's being finalised (and yep, that's me over there as well ;) ).

With regards the materials, it's sort of correct. If you imagine what UDK is doing when its rendering a mesh it's basically pulling in the entire asset (everything associated with the model - mesh, materials, shader effects etc.) and rendering it in 'layers' or 'passes'. First you have the mesh (the wall object, or fountain and so on) and then the materials, then the shaders and effects and so on. Each 'layer' of data requires the renderer to 'parse' it, so yes, if you have seven materials on a mesh the rendering engine is pretty much looking at that object several times, reading each individual material with a view to render them based on where they are on the mesh. If each material has a shader that's a further seven passes being made.

This is why UDK makes more extensive use of 'unique' textures where everything on an object is mapped to the one image, it's only doing a single pass to render those types of objects. Tiled or reused objects differ because although it means the renderer is loading in more assets, those assets can be reused and kept in memory.

Incidentally, this is why polycount isn't always the cause of bad performance
Title: Re: [UDK] Blender UV problems
Post by: ward on May 20, 2011, 01:22:37 AM
So is it best to make a component for each material, and export it that way? These are models that will be used a bunch of times (so I ticked "Used For Instancing" in the static mesh editor). Everything so far uses tiling materials in UDK.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 20, 2011, 02:43:11 AM
It depends really. Ideally what you should be looking to do is making sure that each house is a compact unit in of itself so that as a group they're all using the same materials, that then offsets the repeat parsing to process the multimaterial assigned to each model - even though you have several *objects* instanced around a level, they all use the same two ot three materials. So no, you don't really need to break the models up into per-material segments, certainly not for those types of objects.
Title: Re: [UDK] Blender UV problems
Post by: ward on May 20, 2011, 02:56:22 AM
Well outside and inside have diffrent material slots, so in total most have 6 or 7 materials, i could for instance split them up once, so i got the outside and inside so each has 3 to 4 materials, and then it would remain more or less manageable/pratical in UDK. (Although most practical is to not split them at all.) Maybe this would be a good "middleway"?
Title: Re: [UDK] Blender UV problems
Post by: kat on May 20, 2011, 03:20:08 AM
Ah yes, that's what I'd do, separate them into 'inside' and 'outside' units, that way you can spam each element without necessarily having the overheads associated with rendering everything when not necessary (background scene objects for example, players can see but can't interact).
Title: Re: [UDK] Blender UV problems
Post by: ward on May 20, 2011, 03:43:55 AM
They will always be used together though, never for backgrounds etc.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 20, 2011, 04:58:08 AM
If the textures/material don't have any special effects applied then leave them as a unit in that case, because yes, although you do have meshes that use a few materials, you're essentially reusing both the texture and 3D assets, it's not like each building has it's own set of textures - that's really where this over-rendering causes problems. In other words so long as you 'instance' them in some way you're off-setting the render load.
Title: Re: [UDK] Blender UV problems
Post by: ward on May 20, 2011, 01:05:49 PM
... it's not like each building has it's own set of textures - that's really where this over-rendering causes problems.
Well these are temporary testmaterials, eventually there will be per house textures, however only about 5-10 sets that will be re-used randomly, so the houses will look unique.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 20, 2011, 05:56:43 PM
In that case your use of temp textures now should reflect what you intend to do later so all you need do is swap them over thus avoiding any reworking/building of the assets and/or reduce the possibility of unforeseen problems.
Title: Re: [UDK] Blender UV problems
Post by: ward on May 21, 2011, 10:20:41 PM
How is this best done by the way? Unique materials for multiple instances, almost finished with unwrapping the models.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 21, 2011, 10:28:53 PM
You just use temp textures of the same number and proportion (size doesn't matter as such) as your finals. The pictures on the previous page are simple checkers for example, you can use several of those - they have the same file name as your final assets, so "wall.tga", "beams.tga" and so on. All you then do save over those when you're done and/or re-import them into UDK.
Title: Re: [UDK] Blender UV problems
Post by: ward on May 22, 2011, 01:54:19 AM
Yeah i know that part, but do i need to copy the mesh a bunch of times and assign diffrent materials, or is there a better way? (Since, ideally the geometry only needs to be loaded once.)

By the way I didn't mention yet that the models come from sketchup 8 (exported as collada), material slots get exported too. So I just assign a diffrent color for a diffrent material in sketchup, blender imports this, and in UDK I assign the proper materials. This works pretty good for tiling materials, and when I need it for aligning I just add an image in blender. Of course I also unwrap them in blender, and further distort them to make them look older. I'll post a decent screenshot with testmaterials sometime.
Title: Re: [UDK] Blender UV problems
Post by: kat on May 22, 2011, 07:00:20 AM
Thought they might be SketchUp models  ;)

Anywho, to answer your question.. if I'm understanding you correctly it depends on what you're going to do with the models. The screenie you posted previously shows 5 different versions of the same type of house so what you could do is have several sets of all five houses, one set is 'red', another 'blue', yet another 'green' and so on, that way you're at least minimising the texture over heads by using each asset repeatedly.

You could go one step further and break the models up as per what was discussed above as that would reduce overheads even more by only changing the outer texture set, so even though you had 20 or so houses in a map for each 'set', the innards would all be the same (relative to their being a set).

The alternative is to mess around with UDK's shader settings, iirc you can edit specific instances of meshes in the editor so although you could have the same model loaded a few times each one would be slightly different because of the additional node work applied to it. Ah here it is...

http://udn.epicgames.com/Three/MeshPaintReference.html - Mesh Painting (essential reading)
Also bookmark this forum on Polycount (http://www.polycount.com/forum/forumdisplay.php?f=63), a lot of the guys posting there are professionals using UDK/Unreal tech
Title: Re: [UDK] Blender UV problems
Post by: ward on May 22, 2011, 12:21:10 PM
Do you mean I could make one set of materials, but paintable, so I don't need to copy the models? Just to make sure I understood correctly. I already knew about vertex painting, one of my materials already is paintable :).
Title: Re: [UDK] Blender UV problems
Post by: kat on May 22, 2011, 04:28:44 PM
Depending on how complex that vertex painting can get, yes you might potentially only need one set of houses and one set of textures, you then use vertex painting to make each model look unique even though they're not. I'd do some tests first, make *one* model and fully texture material it then spam it around a test map and see how unique you can make that one item. If the results look OK then you know you're going to be OK doing that to all of them.