Hard Light Productions Forums

Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: bobbtmann on January 18, 2009, 07:19:23 pm

Title: UV Mapped AND Tiled
Post by: bobbtmann on January 18, 2009, 07:19:23 pm
Is it possible to have a model where parts of it are tiled and parts are not? And how is this done? For that matter, how is tiling done? I'm using 3ds max and so far I've only ever been able to export a mapped single texture model.
Title: Re: UV Mapped AND Tiled
Post by: Scooby_Doo on January 18, 2009, 08:48:42 pm
Two ways possible:

First, the less expensive, fewer textures route:

  First the repeating texture must go from one side of the image to the other side.  For example you want a repeating texture that goes horizontal, like a landing    bay floor.  The floor texture would go from the left side all the way to the right side.  In max then you can adjust the repetition count as much as you want. 

Here's an example, the landing strip and walls can be repeated as many times as needed.
(http://img.photobucket.com/albums/v356/Shodan_AI/Extras/bay.jpg)


Second route is to seperate the textures out.  The repeating tiled texture would be on it's own image.  It's easier to do but not recommended if you have lots of repeating textures.  This is basically how the original freespace 2 is done.  Also note if you want to add glowmaps and normal mapping this method may prove to be more time-consuming.
Title: Re: UV Mapped AND Tiled
Post by: Galemp on January 18, 2009, 09:03:14 pm
You can see on the retail Lucifer, Aten, and Cain that :v: used a UV map for some areas and a tile map for others. This is a decent trade-off if full UV mapping is intimidating.

Like Scooby says, with clever layouts you can get the detail and efficiency of both. I used this technique on the high-poly Karnak--take a look at the texture, and how it's applied to the model with repetition.

To apply more than one material in Max, you need a multi-subobject material in your material editor, and you need to assign Material IDs on a per-polygon basis that correspond to the texture you're using. There are tutorials online, but that should help you know what to search for.
Title: Re: UV Mapped AND Tiled
Post by: bobbtmann on January 18, 2009, 10:32:05 pm
Thanks for the help! I'll give it a try.
Title: Re: UV Mapped AND Tiled
Post by: SeeNeYe on February 06, 2009, 04:38:04 am
Quote
To apply more than one material in Max, you need a multi-subobject material in your material editor, and you need to assign Material IDs on a per-polygon basis that correspond to the texture you're using.

Hi everyone,

We've done a model that works fine in Freespace SCP, with one texture (2048x2048), some parts of it are reduced to maximum on the uvmap and at the beginning we've just apply to it a pure color in the uvmap.

Now that we have see this thread, we wanted to try to tile these parts and modify the model within 3DSmax with a multi-subobject material and Material ID assignment. The result is fine in 3DSmax.

We've got 5 materials in the multi-subobject material, with different bitmap textures assigned.

The matter is that in freespace, only the first material of the multi-subobject is visible, all the rest in invisible. However, all the textures have been stored in the maps folder.

I wonder if it is not a texture size issue, as for the moment, it is not "freespace2 compliant" :

The sizes of the 4 other textures added to the uv main map are :

570x570 (resized to 1024x1024???), 428x360 (resized to 512x512???), and 3072x2304 (ouch ! resized to... 4096x4096???).

Of course i'll try to standardize the texture sizes, i just wanted to know if this issue may result in invible textures ingame ?

Thanks in advance for your responses !

Peace
Title: Re: UV Mapped AND Tiled
Post by: Scooby_Doo on February 06, 2009, 05:03:59 am
Are you using the Collada converter for pcs2?
Title: Re: UV Mapped AND Tiled
Post by: SeeNeYe on February 06, 2009, 05:11:58 am
Yes sir !
Title: Re: UV Mapped AND Tiled
Post by: Scooby_Doo on February 06, 2009, 05:21:13 am
Oh I think I see the answer...

Most games required textures to be a factor of 2   2,4,8,16,32,64, 128,256......1024, 2048.  Freespace included.  You'll need to resize them to fit the nearest one. 
Also might not hurt to combine some of those textures into one larger one.   AkA  1@1024 is better than 2@512.

Title: Re: UV Mapped AND Tiled
Post by: SeeNeYe on February 06, 2009, 05:34:51 am
Okay, thanks i'll tryout that when I come back home !
Title: Re: UV Mapped AND Tiled
Post by: Scooby_Doo on February 06, 2009, 05:45:36 am
Also try to keep them below 4096, not everyone has 1GB video cards.
Title: Re: UV Mapped AND Tiled
Post by: SeeNeYe on February 06, 2009, 07:59:09 am
 :D Sure, it was just a test... i don't think that it will even exceed 1024x1024 at the end.
Title: Re: UV Mapped AND Tiled
Post by: shiv on February 06, 2009, 09:48:16 am
Also try to keep them below 4096, not everyone has 1GB video cards.
I don't think that there's need for higher-res maps than 4096... :doubt:
Title: Re: UV Mapped AND Tiled
Post by: Reprobator on February 06, 2009, 02:57:14 pm
you say that because you never saw my new nav buoy  ;7
Title: Re: UV Mapped AND Tiled
Post by: SeeNeYe on February 06, 2009, 04:35:19 pm
Well, this is definitely a texture size issue as I tryout with a dummy white.tga and black.tga and it  works perfectly, Thanks Scoob !!  :yes:
Title: Re: UV Mapped AND Tiled
Post by: SeeNeYe on February 08, 2009, 04:29:20 pm
 :sigh:

I've completely redone the textures, and I'm now "freespace2-compliant", the sizes are 16x16 or 256x256.

In 3DS, depending on the material, the factor of tiling is 5, 10, 1000, and up to 10000.

The problem is that ingame, i don't really see the textures, instead I see some pure color scheme that barely correspond to the textures main colors !

Someone got an idea about that issue ? Is there any correlation with the factor of tiling set in 3ds ?

Thanks in advance !  :nod:
Title: Re: UV Mapped AND Tiled
Post by: Water on February 08, 2009, 05:21:41 pm

The problem is that ingame, i don't really see the textures, instead I see some pure color scheme that barely correspond to the textures main colors !
Really small texture sizes have that problem. The colours get averaged out to one colour from a distance.
Title: Re: UV Mapped AND Tiled
Post by: SeeNeYe on February 09, 2009, 01:45:29 am
Quote
Really small texture sizes have that problem. The colours get averaged out to one colour from a distance

I see what you mean but the problem is present even with 256x256 textures...
Title: Re: UV Mapped AND Tiled
Post by: Scooby_Doo on February 09, 2009, 01:54:40 am
How many repetitions are you using?
Title: Re: UV Mapped AND Tiled
Post by: Galemp on February 09, 2009, 01:57:35 am
View menu -> Show mapping... or something like that, I don't remember exactly what it says.
Title: Re: UV Mapped AND Tiled
Post by: Scooby_Doo on February 09, 2009, 02:03:30 am
View menu -> Show mapping... or something like that, I don't remember exactly what it says.

If your referring to Max, it's Views->Activate all Maps
Title: Re: UV Mapped AND Tiled
Post by: Water on February 09, 2009, 04:24:16 am
I see what you mean but the problem is present even with 256x256 textures...
At a tiling factor of 1k to 10k, a 4096 texture won't make a difference. It can make a difference if you reduce the tiling factor.

It all comes down to scale. On a large ship, tiling gives sharp visuals close up, but you lose the sense of scale. All walls you are close to look alike. A non tiled texture with ambient occlusion gives a sense of scale but the close up suffers. For 1-3km I'd go with non tiled. But I'm guessing you are thinking a bit bigger than that.
Title: Re: UV Mapped AND Tiled
Post by: Reprobator on February 09, 2009, 05:04:18 am
interesting,
i m asking that to know about optimisation but, when you tile a texture for exemple 2x 1024*1024
does  the game load the map to the memory two times and finally react as you had a 2048*2048 texture?
Title: Re: UV Mapped AND Tiled
Post by: ssmit132 on February 09, 2009, 05:18:40 am
I doubt that it works how you're saying just there, but if it did, it would be 4x 1024*1024, since doubling the sides quadruples the area.
Title: Re: UV Mapped AND Tiled
Post by: Water on February 09, 2009, 05:52:48 am
interesting,
i m asking that to know about optimisation but, when you tile a texture for exemple 2x 1024*1024
does  the game load the map to the memory two times and finally react as you had a 2048*2048 texture?

When you tile a surface it loads the texture once and draws it on screen many times. Thats why dds is important. As the surface gets smaller due to distance the vid card needs to resize the texture. If the dds has mip maps it grabs a smaler image to save time.
Title: Re: UV Mapped AND Tiled
Post by: SeeNeYe on February 09, 2009, 01:00:13 pm
Quote
At a tiling factor of 1k to 10k, a 4096 texture won't make a difference. It can make a difference if you reduce the tiling factor.

It all comes down to scale. On a large ship, tiling gives sharp visuals close up, but you lose the sense of scale. All walls you are close to look alike. A non tiled texture with ambient occlusion gives a sense of scale but the close up suffers. For 1-3km I'd go with non tiled. But I'm guessing you are thinking a bit bigger than that.

I understand, in fact, i'm not working on a big big ship but on a cockpit, although i think it is the same concept for tiling.

Actually, the problem is that i've started with uvmap, for all elements that needed detail mapping and think other parts might be in pure colors, so I place all the others parts of the pit in three little squares on the uvmap, and paint them through photoshop. That's why the tiling factor is that big ! All the elements I want to tile are very very small on the uvmap, so to get the good render in 3ds, i use big factors.

The issue come from the interpretation by the freespace 2 engine of the tiling factor of the maps, considering the maps not appropriate and replacing them by average map pure color. True ?
Title: Re: UV Mapped AND Tiled
Post by: Water on February 09, 2009, 08:19:22 pm
I sorta think we are talking different jargon.  Tiling = repeated texture over part of the model. I'm guessing tiling factor is the scaling factor for a uv map island?

For non tiled textures (standard uv maps)
The amount of pixels an element gets on the uv map is the amount of pixels it can use on screen. Even if it is right in front of you taking up the whole screen.
Title: Re: UV Mapped AND Tiled
Post by: SeeNeYe on February 11, 2009, 07:25:07 am
We have fixed the missings textures issue, by making all textures 256x256 sized and reduce the tiling factor to 20 in value. We also make the little pieces tiled bigger in the uvmap (in fact we've moved them outside of the base square).

So we're seeing the maps ingame, but the problem is that the tiling factor is not taken into account during the export process. DAE file is good when reopen it trough 3ds but when loading into PCS2, we clearly see that a factor of 1 is applied to all textures.

An idea ?  :)
Title: Re: UV Mapped AND Tiled
Post by: Galemp on February 11, 2009, 12:19:01 pm
You need to scale up the UV map itself, FS will always use a factor of one.
Title: Re: UV Mapped AND Tiled
Post by: SeeNeYe on February 12, 2009, 02:04:07 am
 :( Ouch
Are you saying there is no possibility to apply a tiled texture with a factor without doing it manually ? (like the first scooby solution in this topic)

I am sad. That's bad...  :p
Title: Re: UV Mapped AND Tiled
Post by: SeeNeYe on February 12, 2009, 07:00:10 am
To clarify the purpose of our questionnings, we've done an example of what we done on our model, this is a simple cube.

thanks to have a look !

 :D

[attachment deleted by admin]
Title: Re: UV Mapped AND Tiled
Post by: Vasudan Admiral on February 12, 2009, 08:27:20 am
I *think* I have a rough idea of what you're saying, and if I'm right, it's basically a misconception of how tiling vs UV mapping works. If you know this already then I apologise - but it's best to make sure, and it might help others at some point anyway. :)

Whether you are UV mapping or texture tiling a face, the data you will end up creating is EXACTLY the same: the face itself, a reference to which texture map it uses and a UV projection of that face onto a 2d plane.

Whenever you 'texture tile' a face what you're actually doing is creating a UV projection for it - except unlike in UV mapping, the program is creating a projection automatically, based on what you input as tile factor (which becomes UV projection scale) and translation/rotation.

I'll use your cube to show you what I mean:
Here the cube has been 'texture tiled' with a tiling factor of 1. You can see how the UV is projected in EXACTLY the same way as the 'UVMAP' texture on the top of your cube has been.
(http://i5.photobucket.com/albums/y184/VA--Twisted_Infinities/BlenderTutorialStuff/Tiled-UV1.jpg)

Here the tiling factor has been increased to about 4. All that's changed in the UV editor is that the projection of that face is four times larger than it was at 1.
(http://i5.photobucket.com/albums/y184/VA--Twisted_Infinities/BlenderTutorialStuff/Tiled-UV2.jpg)

So, technically there is no way FS2 CAN'T support any type of texture tiling. If the tile factor is not being preserved, then it's simply a bug somewhere in the conversion where the tiling factor is being reset to 1 before it spits out the face-texture-uvprojection data. If that is the case, you can ALWAYS fake tiling by just resizing the UV projection of those faces manually in a UV editor so it can't get 'lost'.

Hope this helps - let me know if you don't follow any aspect of it. :)
Title: Re: UV Mapped AND Tiled
Post by: SeeNeYe on February 12, 2009, 09:38:15 am
 :D

Nice tuto Vasudan Amiral  :)

Thank you all for your great explanations.

Okay, i've tryed to resize directly the uv of one of the material id and it works perfectly (just tested in PCS2 so far, but i think it won't be different ingame).

I will apply this method to the other parts of the model !

Title: Re: UV Mapped AND Tiled
Post by: Vasudan Admiral on February 12, 2009, 06:38:17 pm
Excellent. :)

One additional thing which I think has been mentioned already in this thread - FSO doesn't like multiple textures. It will display them fine, but switching between textures takes a relative age. So much so that using two 512 tiled textures will be slower than using a single 1024 - even though they offer only half the resolution.

To that end, if you really need to tile, I would recommend doing as Galemp and Scooby described in the first couple of posts and blend as many tile textures into one map as you can, as this will improve performance considerably for the exact same visual result.
Title: Re: UV Mapped AND Tiled
Post by: SeeNeYe on February 13, 2009, 03:16:03 am
Sure, i see the goal of all that, we'll try to bake all the tiled textures into one 1024x1024 texture maximum or maybe 512x512, as we have just 4 tiled textures of 256x256.

At the end, we will have just 2 textures for the model, one for the detail map (1024² or 2048²) and the other for the tiled stuff (512² or 1024²).

As it is a cockpit, the textures will be loaded only one time at the beginning of each mission, will it be really essential to group the 2 textures into one ?
Title: Re: UV Mapped AND Tiled
Post by: Reprobator on February 13, 2009, 03:24:13 am
as i understood the way freespace2 works (feel free to correct me if i'm wrong), the number a models or texture is used do not change the loading time as it is loaded one time and then repeated in game (tested with loading 1 orion in a mission and compared with 9 orion and did not see difference in the loading time).
I think it would have more impact on the framerate ingame than the loading time.
ah another thing beeing forgot :

i wish you a warm welcome to hardlight.

(http://www.hard-light.net/forums/Smileys/HLP/wel_blue.jpg)

i think that some point that was highlighted in this thread could be wikified  :confused:
Title: Re: UV Mapped AND Tiled
Post by: Scooby_Doo on February 13, 2009, 03:52:26 am
Last I remember, the game loads the textures into system memory once, however, during frame rendering, the game renders each subobject as a texture change.   I believe this is one area where they wanted to improve the performance (do a texture change [aka load into vram] once per frame).
Title: Re: UV Mapped AND Tiled
Post by: Water on February 13, 2009, 04:27:31 am
At the end, we will have just 2 textures for the model, on for the detail map (1024² or 2048²) and the other for the tiled stuff (512² or 1024²).

As it is a cockpit, the textures will be loaded only one time at the beginning of each mission, will it be really essential to group the 2 textures into one ?
I think you could do a good job with a 1024.  - bake the tiled stuff into that texture and mirror some parts.