About DirectX models.

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

About DirectX models.

Post by Mel »

If a Direct X model has more than 1 channel for UVW map applied, are the second vertex UV map loaded into the engine too?
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
fmx

Post by fmx »

I don't think so, not for .X files anyway
(I've spent hours staring at Irrlicht's .X file loader just to get it working in my own engine, what a nightmare :roll: )

not sure about B3D files tho
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

We have improved some things for the 1.5 release, but I doubt that multiple UV coords are already supported. If you can provide a mesh to wotk with it could go into Irrlicht 1.6, though :)
zeroZshadow
Posts: 43
Joined: Mon Dec 01, 2008 6:35 pm

Post by zeroZshadow »

multiple UV channels are supported for b3d, tested it with lightmaps :)
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

I tested it yesterday. I exported the level i use to work with, to add it light maps baked into another UVW map, and the .X file was bigger in size than the one which only had 1 set of UV coords, also, the code which loads directX models seems to be capable of loading more than one texture coordinate at first sight, but i wasn't sure if it was really used.
hybrid wrote:We have improved some things for the 1.5 release, but I doubt that multiple UV coords are already supported. If you can provide a mesh to wotk with it could go into Irrlicht 1.6, though :)
count on it ;) Also, it seems LWO models may have unlimited texture UV maps, though graphics card may support up to 16, if i'm not mistaken.
zeroZshadow wrote:multiple UV channels are supported for b3d, tested it with lightmaps :)
Do you know if it also works with HLSL shaders? If so, it would be quite interesting to work with B3D too. Thanks!
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

I've done some research on this matter, did you know about the FVFData{258,...} token in direct X files? seems that it is there where the 2nd set of UV maps is stored.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
fmx

Post by fmx »

I guess it depends on the exporter too. How are you planning to export your .X model, and are you sure the exporter will also write out the data correctly?
.X is a handy, but really awkward format to work with sometimes, so might be a good idea to use B3D too.

I heard .MD5 is also quite a handy format, shame Irrlicht doesn't support it yet
:\
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

B3D seems to be still buggy (1.5, svn1933). I exported the mesh to that format, and suddenly, all the textures turned into 16 bit mode. Although forcing them to be 32 bit still worked right, the shaders also, stopped working well, even those which weren't used in the B3D model. just if all the system went crazy when using the B3D models. My normal map shaders also stopped working right, so, i'm sticking to .X. I'll deal a more detailed bug report about this later.

I have just noticed that too. seems that FVFData 258 is only used in the panda exporter, but also, seems that it is exported like that in other exporters like the KW X port
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

B3D supports flags for disabling mipmaps and forcing 16bit textures. Maybe you just exported in a way (or with an exporter) which doesn't put these things right.
The FVF data is standardized, so it's possible to support such data in more detail. But we do need example files for such things :idea:
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

Oh, my bad then... here is a small sample.
http://rapidshare.com/files/172763368/sample.rar

This is how it should look with the two coordinates applied.
Image
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, I have this working to some extent. However, two things still to define. First, the textures are not stored in the file. I've added them manually and added two texturefilename templates in the same material. Don't know if this is allowed, never saw it like that, but I can use it to add multiple textures per material. Second is, how to interpret the material. Should two textures be lightmap (with which multiplicator?) or detailmap, or maybe even solid_2_layer?! There's no such flag in the .x format that I'm aware of...
The code will be added to trunk/ (i.e. Irrlicht 1.6) because it changes quite a lot in the .x mesh handling, and this is too late to go into 1.5.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

Sorry, my bad. I exported the shape with a shader that the panda exporter couldn't understand, and thus, it omited the texture, here is a fixed version, which defines the texture of the first set of coordinates. there is no way to propose the second texture inside the file.

http://rapidshare.com/files/173035526/fixed-sample.rar

The answer to your other question seems to be that DirectX format originally was meant to have only 1 set of mapping coordinates, but they left the FVFData to add more functionality that wasn't present at first, for developpers. So, people started using the FVFData to store the second set of mapping coordinates. As a consequence of this, there is no meaning for the second set other than the one the programmer wants to give it. In other words, is data for whatever programmers want to do with it, unlike perhaps the Q3 BSP's lightmaps, or B3D multitextures. You can do shadowmapping, detailmapping, or other effects. It seems to be a flexibility added to the format to allow it to be adapted to whatever creators want to do with it.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yep, the problem with this is that you might want only one part of the mesh using lightmaps or detailmaps, but the loader cannot distinguish. Moreover, we'd need to invent means to add proper material types for the lightmapped meshbuffers, while e.g. transparent ones still need to be transparent.
I'll add support for FVF and DeclData for lightmaps and normalmaps, and think about a way to specify materials via scene parameters.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

and think about a way to specify materials via scene parameters.
I thought of a sort of material definition via XML, unlike the one that is already in the engine, one which created basic OGL/DX shader on its own, abstracted to the user, much more focused to an artistic way, much like 3d application materials, using a basic shader as a starting point (a phong, shader, or a flat shaded, or a translucent ) a basic color, a specular power/level and a basic opacity.

Then, adding a series of texture maps (lightmaps, bumpmaps) would modify the basic shader, and texture maps operations (such as fresnel, scrolling and so) to add effects. Though i guess this is not what you were looking for.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Mel wrote:
and think about a way to specify materials via scene parameters.
Then, adding a series of texture maps (lightmaps, bumpmaps) would modify the basic shader, and texture maps operations (such as fresnel, scrolling and so) to add effects. Though i guess this is not what you were looking for.
Correct, I was just thinking about a way to hint .x loader to proper interpretation of the second texture :wink:
Post Reply