Replies: 299 (Who?), Viewed: 97843 times.
Page 1 of 12
The ModFather
retired moderator
Original Poster
#1 Old 2nd Jan 2005 at 4:26 PM Last edited by Numenor : 19th Nov 2005 at 7:25 PM.
Tech Discussion: The Material Definition ("TXMT", a.k.a. "MATD")
This thread's scope is to collect all the data currently available about the structure, the content and the functions of the MATDs (Material Definition).

I've studied them a little, and I found them very interesting, because they hold information over objects' transparency, reflectivity, texture, lighting and many other (still unknown) things.

*Everybody is welcome* to add his knowledge, his experiences, the results of his experiments and everything related to the subject. Don't be afraid to give your contribution: despite the thread title, this discussion involves every level of knowledge, from the lowest to the highest.

If we'll be able to create an organized data repository, maybe we can then transfer it into the Wiki.
And if I find there are many people interested in contributing to the collective knowledge, I can start new Tech Discussion threads for other subjects.

Share the knowledge! :grouphug:

I've finally started my Journal. Information only, no questions.

My latest activity: CEP 9.2.0! - AnyGameStarter 2.1.1 (UPD) - Scriptorium v.2.2f - Photo & Plaques hide with walls - Magazine Rack (UPD) - Animated Windows Hack (UPD) - Custom Instrument Hack (UPD) - Drivable Cars Without Nightlife (UPD) - Courtesy Lights (FIX) - Custom Fence-Arches - Painting-TV - Smarter Lights (UPD)


I *DON'T* accept requests, sorry.
7 users say thanks for this. (Who?)
Advertisement
Warrior Gryphon
site owner
#2 Old 2nd Jan 2005 at 4:30 PM
Theres a bunch of stuff on the wiki about MATD already

http://www.modthesims2.com/wiki/49596978
The ModFather
retired moderator
Original Poster
#3 Old 2nd Jan 2005 at 5:10 PM
General function and Texture reference.

My first contribution (I'll add more later) is about the general function of the MATD in relation of the flow of data that has to be collected in order to represent an object in the game.

Once the game has collected the 3D mesh of the object that has to be rendered, it needs to know what should be the exterior look of the object itself.
So, it looks into the SHPE file(s) and the GMND file(s) in order to know:
1) what parts (subsets) the object is made of;
2) how those subsets should be represented in the game.

For each subset there is at least 1 MATD, but often we can find multiple MATDs for each subsets, because the subsets may be multistate (clean/dirty, lit/unlit...) and/or they may have more than 1 color.

For example, the "Bella Squared" painting has 2 subsets: the painting and the frame (there is a 3rd subset related to the shadows that the object casts over the wall, but from now on, let's forget the shadows, that are not interesting for our study.
As this painting has no multiple colors option, and it's not a multistate object, we have only 2 MATDs for it (not counting the shadows).
Another example is the "Bon Apetit" dining chair: it's made by 2 subsets, as well (fabric and wood), but the fabric comes in 7 colors, and the wood in 2 colors, so we have a total of 9 MATDs for this chair.

The main scope of the MATD is to hold information about the texture that has to be applied to the subset in order to render it in the game.
The texture reference can be found in the stdMatBaseTextureName string field of the MATD.
In order to let the game display the texture, the stdMatBaseTextureEnabled boolean value must be set to True
Then the graphic engine must know how to apply the texture over the 3D mesh: the texture might be tiled over the surface, or stretched across it, or maybe something else... Anyway, the stdMatBaseTextureAddressingU and stdMatBaseTextureAddressingV fields are suitable for the purpose.
I'm sure that these two fields may assume different values, but so far the only value I've found in these fields is: Tile. If anyone has more information, pleas let us know.
Warrior Gryphon
site owner
#4 Old 2nd Jan 2005 at 5:13 PM
I wonder how the stdMatBaseTextureAddressing values correspond to the UV coordinates held within the GMDC files themselves.

It might act like a base offset from the original coordinates given.
The ModFather
retired moderator
Original Poster
#5 Old 2nd Jan 2005 at 5:21 PM
Quote:
Originally Posted by Delphy
Theres a bunch of stuff on the wiki about MATD already

http://www.modthesims2.com/wiki/49596978


Thank you Delphy, I knew it, but I think that the wiki, while it's an important tool for the experienced modders, is quite difficult to use and understand for the not-so-high experienced users.
I'm trying to push those people to share every little bit of knowledge they may have collected: maybe they think that those "little bits" aren't enough to post them and share them with the Community, so I started this thread as a "collector" for them. Maybe it will be only an unsuccessful experiment, but at least I shared what I know in a more understandable way then the Wiki can do.

Anyway, your "watching over us" is really appreciated! Where do you find the time to read all the threads we start and to post your advice, too?! :D
The ModFather
retired moderator
Original Poster
#6 Old 2nd Jan 2005 at 5:28 PM
Quote:
Originally Posted by Delphy
I wonder how the stdMatBaseTextureAddressing values correspond to the UV coordinates held within the GMDC files themselves.

It might act like a base offset from the original coordinates given.


But then, why I always find the value "Tile"? Aren't there other ways of applying the texture over the mesh?
And, to tell the truth, I only open the GMDC in order to extract some meshes with your plugin...! I know nothing about the GMDC, but the "Tile" value doesn't seem to refer to a coordinates set. I'm quite confused on this subject, because is really out of my study field... :err:
Warrior Gryphon
site owner
#7 Old 2nd Jan 2005 at 6:09 PM
Textures can be tiled across a mesh by increasing the UV coords greater than 1. So, a UV of 2 would indicate a tiling pattern.

Perhaps the MATD version of tiling alters the mesh UV coordinates in some way as to tile the texture by X, depending on what is specified.

I agree that the Wiki is very much for technical file formats, and and actual discussion about *what* particular values mean is called for, so it's good that you've made this thread

As for having time to read everything, I just scan the new posts and comment on stuff thats interesting
The ModFather
retired moderator
Original Poster
#8 Old 3rd Jan 2005 at 1:26 PM Last edited by numenor : 3rd Jan 2005 at 1:47 PM. Reason: Typo :)
The Blend Mode: part 1

Another very important function of the MATD is to hold information about the blend mode.
Among the other things, the blending lets the user alter the look of the object, adding to the texture transparency, color, brightness, light/shadow patterns and so on.
The blending can be used in conjunction or alternatively to the texture.
In other words, sometimes the texture is referenced into the MATD and the special effects can be added to it; on the contrary, sometimes the rendering of the object isn't based on a texture, but relies only on those special effect.
The typical example is the glass: to render a glass object, there is no need to use a texture: the only things we need to specify are its transparency, and its colour (if any).

The blending mode is activated/deactivated by using the stdMatAlphaBlendMode key; the values accepted by this field (correct me if I'm wrong) should be: none, additive, blend, blendreflective, mask, maskbump.
Every one of the mentioned values instructs the game to look for additional keys into the MATD, in order to collect the needed rendering information.
Obviously, the none means that no blending is to be applied to the object, so there's nothing to talk about.

Let's begin our analysis with one of most frequently used blending mode: blend.
As seen, we can activate it by means of the key: stdMatAlphaBlendMode: blend.
Then, we have to specify some more parameters in order to give our object the look we want it to have.
The most useful parameters are stdMatDiffCoef, stdMatUntexturedDiffAlpha and stdMatDiffCoef.
These three parameters are used to have the so-called "color blend".
Here is the syntax & acceptable values.

Code:
stdMatAlphaBlendMode = blend
stdMatDiffCoef = [0-1],[0-1],[0-1]
-> RGB values for glass colour
Values of 0,0,0 give as a result a dark (but still transparent) glass; 0.5,0,0 give a reddish glass, and so on.

-------------------------
Code:
stdMatAlphaBlendMode = blend
stdMatUntexturedDiffAlpha = [0-1]
-> glass transparency
A value of 0 means "completely transparent" (beware: it means invisible!), while 1 means "solid".
Typical value for clear window glass is ~0.3


-------------------------
Code:
stdMatAlphaBlendMode = blend
stdMatEmissiveCoef = [0-1],[0-1],[0-1]
-> RGB values for glass brilliance
The brilliance is the "inner" light that the glass may have. It's not a "light", because it doesn't add light to the room; it's just a bright look.


-------------------------
Experiment by yourself different values for the three parameters and look at the differences. I find very useful, for testing these values, the "window" part of the cheap microwave (obviously, you have to install the CEP in order to recolour it ).

End of part 1
Administrator of Loverat's Tea and Underpants
#9 Old 3rd Jan 2005 at 1:36 PM Last edited by RGiles : 3rd Jan 2005 at 1:54 PM.
To get the value you want in stdMatDiffCoef, pick a color you like in a paint program and find out the Red Green and Blue values for it. Divide each of them by 256. These are then the numbers you'll list as the values for stdMatDiffCoef.

For instance the middle-grey color is R 128, G 128, and B 128. 128/256 = 0.5 so stdMatDiffCoef would be set to 0.5, 0.5, 0.5

stdMatDiffCoef sometimes has a fourth parameter. I assume it relates to the alpha (transparency) channel, but I haven't been able to see what effect it has. Does anyone know?

Edit: This value can be applied to objects that are not glass as well. For instance if you wanted to give a textured object a "warm" look you might set this to a very faint yellow, and if you wanted it to have a "cool" look you might set it to a very faint blue. It can blend with the texture that will be laid over it, so that the same texture can be applied to a different overall effect.

RG
The ModFather
retired moderator
Original Poster
#10 Old 3rd Jan 2005 at 1:53 PM
Sorry, I made a mistake while copying & pasting: the third "code" is stdMatEmissiveCoef and not stdMatDiffCoef. Now I've fixed my post.

The stdMatEmissiveCoef sets the "brilliance" values, while the stdMatDiffCoef sets the "color" values.
Thanks for having pointed this out and for having exlained the method to get the Coef values starting from the RGB values.

As for the fourth parameter of the DiffCoef, I've seen it sometimes but I don't know what it is for. I hope that someone will tell us.
Administrator of Loverat's Tea and Underpants
#11 Old 3rd Jan 2005 at 2:03 PM
Ah, I see. I changed my post above so as not to cause confusion.

What else can I add? Hmm... I'll see what else you have to post in Part 2 and beyond so we're not duplicating. I probably have more questions than answers anyway. :D

RG
One horse disagreer of the Apocalypse
#12 Old 3rd Jan 2005 at 2:37 PM
I don't know if this is relevant but did you know you can set some things in a BHAV, like "My 48 assign to 0" (followed by a Refresh instruction) sets the object transparent? That's the alpha, and there are other values for red, blue and green.
The ModFather
retired moderator
Original Poster
#13 Old 3rd Jan 2005 at 3:24 PM
Very interesting!
The 0x48 (Render Alpha) operand probably changes "on the fly" the stdMatUntexturedDiffAlpha value, and the 0x49/4A/4B (Render Red/Green/Blue) should change the stdMatDiffCoef values.
Do you think so?
One horse disagreer of the Apocalypse
#14 Old 3rd Jan 2005 at 3:40 PM Last edited by Inge Jones : 3rd Jan 2005 at 3:42 PM.
Well I found only 255 and 0 actually appeared to do anything in the game, and I am afraid I didn't try the RGB ones at all. It affects the whole object, whereas I would have thought editing the materials would apply differently to the various parts of the object.

For example, in a shower, the frame and the back are separate materials, aren't they? Yet the BHAV instruction makes the whole lot visible or invisible.

Could it be a toggle (0/255) meaning apply the channel or don't apply the channel, applied to the values defined in the material?
The ModFather
retired moderator
Original Poster
#15 Old 3rd Jan 2005 at 4:04 PM
Quote:
Originally Posted by Inge Jones
Well I found only 255 and 0 actually appeared to do anything in the game, and I am afraid I didn't try the RGB ones at all. It affects the whole object, whereas I would have thought editing the materials would apply differently to the various parts of the object.

For example, in a shower, the frame and the back are separate materials, aren't they? Yet the BHAV instruction makes the whole lot visible or invisible.

Could it be a toggle (0/255) meaning apply the channel or don't apply the channel, applied to the values defined in the material?


The stdMatUntexturedDiffAlpha value into the MATD applies to the single part of the object (but it doesn't consider the alpha channel of the texture, so the transparency is applied to the whole texture of the object part).
The problem is that there is 1 MATD for each part of the object, and (afaik) the "My Render Alpha" operand doesn't accept a parameter to indicate which part you want the alpha to be applied to, nor it's possible to set the stack to point to anything less then a whole object. So, I think that the operand modifies the Alpha for the whole object, regardless of the parts it is made of.

BTW, haven't you tried any other values between 0 and 255? If it's just a toggle switch, why the values are 0-255 and not 0-1...?
One horse disagreer of the Apocalypse
#16 Old 3rd Jan 2005 at 4:13 PM
Yes I tried various other values for My 0x48. All non-zero values resulted in a 100% solid object, no hint of tranlucency at all. You ask why 0-255 if it's only a toggle? Well in my time with The Sims I have come across zillions of quirks where I thought "Why on earth did they do it like that?!?!" :D
Administrator of Loverat's Tea and Underpants
#17 Old 3rd Jan 2005 at 7:23 PM
LOL. Yeah, that's a good question a lot of the time, Inge. In a lot of cases it looks like they started to implement something and then gave up on it.

I know Rain was interested in irridescent effects. I came up with these 2 textures in playing around. I used a glass material and added my own reflection map is all. By the way, do you want this globe for the CEP? It's not a standard catalog object. It's one that Carrigon added to the catalog from debug stuff.

RG
Screenshots
One horse disagreer of the Apocalypse
#18 Old 3rd Jan 2005 at 7:28 PM
Ooh that's weird! Yeah, sure, the more the merrier :D
Instructor
#19 Old 3rd Jan 2005 at 7:32 PM
If it is ok with Carrigon, the please yes. Add this to the CEP :D
Administrator of Loverat's Tea and Underpants
#20 Old 3rd Jan 2005 at 7:44 PM Last edited by RGiles : 3rd Jan 2005 at 9:48 PM.
I'll check about that. It's a nifty object. It would be niftier still to have a clone of it that does something. This one just sits there. It's purpose was to test materials and lighting... curved objects are good for that, so I picked it too.

RG
Firestarter
#21 Old 3rd Jan 2005 at 9:20 PM
It looks great. Add it I hope we can eventually hack it to do something interesting :D
The ModFather
retired moderator
Original Poster
#22 Old 3rd Jan 2005 at 9:55 PM
I knew that object since long time ago, it was originally used as a test for lighting and reflection. I've never showed it in my "Maxis lost & Found" because it's useless, without some modding; for the same reason I've skipped it in the CEP. There were other test objects (or abandoned objects) nested into the Objects.package, most of which were brought to the "public attention" by the ingenious "collection" by Carrigon.
If you like it, I can add the ball to the CEP, and other object, as well. I just have to test if the CEP will work with such "hidden" objects without actually bring them to the normal catalog (cloning the ObjectData, like I did for the Umbrella Light).
Administrator of Loverat's Tea and Underpants
#23 Old 3rd Jan 2005 at 10:07 PM
It requires Carrigon's package of debug objects. I do like this one because it's useful for testing materials (the original purpose as you said) and because it's a fully built decorative item where a lot of the objects are not very detailed.

I've already got the files for CEP if you want me to upload.

Edit: Did you make any progress on recoloring fences? I think they have to be cloned to be recolored because they are 2 pieces bound together by an XML file. But I figure I should check with you before I give up on it.
The ModFather
retired moderator
Original Poster
#24 Old 4th Jan 2005 at 12:52 AM
RGiles, would you please post the MATD for that iridescent sphere, so I can study it? Or maybe you can describe what MATD values have to be changed to have such an effect.

(As for the fences, I haven't even looked at them, but let's talk about the CEP in the older thread)
Nearly alive
#25 Old 4th Jan 2005 at 1:33 AM
Maybe this is a tiny bit off topic, but I don`t think the MATD files link to the GMDC files. I think the SHPE file links the GMDC and MATD files together, in the SHPE , there is a list of the the named "objects" in part 3 of a GMDC file and next to each (seemly divided by a single character, though this character varies) is the name of a MATD file.
In the tests I have done so far in creating new GMDC files, this list needs to fit in with what is in the GMDC file, else the graphics for the object will not show up in the game.
Page 1 of 12
Back to top