Jump to content
  • Advertisement
Sign in to follow this  
CyberSlag5k

What's a submaterial?

This topic is 4880 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm familiar with materials to a degree, but what exactly is a submaterial? I'm reading in information on my models using 3ds max's Ascii Scene Export file format, and I noticed the materials section is a little odd. Here's a small section of it:
*MATERIAL_LIST {
	*MATERIAL_COUNT 2
	*MATERIAL 0 {
		*MATERIAL_NAME "04 - Default"
		*MATERIAL_CLASS "Multi/Sub-Object"
		*MATERIAL_AMBIENT 0.9529	0.7373	0.8314
		*MATERIAL_DIFFUSE 0.9529	0.7373	0.8314
		*MATERIAL_SPECULAR 0.9000	0.9000	0.9000
		*MATERIAL_SHINE 0.1000
		*MATERIAL_SHINESTRENGTH 0.0000
		*MATERIAL_TRANSPARENCY 0.0000
		*MATERIAL_WIRESIZE 1.0000
		*NUMSUBMTLS 10
		*SUBMATERIAL 0 {
			*MATERIAL_NAME "test"
			*MATERIAL_CLASS "Standard"
			*MATERIAL_AMBIENT 0.9529	0.7373	0.8314
			*MATERIAL_DIFFUSE 0.9529	0.7373	0.8314
			*MATERIAL_SPECULAR 0.9000	0.9000	0.9000
			*MATERIAL_SHINE 0.1000
			*MATERIAL_SHINESTRENGTH 0.0000
			*MATERIAL_TRANSPARENCY 0.0000
			*MATERIAL_WIRESIZE 1.0000
			*MATERIAL_SHADING Blinn
			*MATERIAL_XP_FALLOFF 0.0000
			*MATERIAL_SELFILLUM 0.0000
			*MATERIAL_FALLOFF In
			*MATERIAL_XP_TYPE Filter
		}
		*SUBMATERIAL 1 {
			*MATERIAL_NAME "Material #15"
			*MATERIAL_CLASS "Standard"
			*MATERIAL_AMBIENT 0.9255	0.9255	0.8510
			*MATERIAL_DIFFUSE 0.9255	0.9255	0.8510
			*MATERIAL_SPECULAR 0.9000	0.9000	0.9000
			*MATERIAL_SHINE 0.1000
			*MATERIAL_SHINESTRENGTH 0.0000
			*MATERIAL_TRANSPARENCY 0.0000
			*MATERIAL_WIRESIZE 1.0000
			*MATERIAL_SHADING Blinn
			*MATERIAL_XP_FALLOFF 0.0000
			*MATERIAL_SELFILLUM 0.0000
			*MATERIAL_FALLOFF In
			*MATERIAL_XP_TYPE Filter
		}
		*SUBMATERIAL 2 {
			*MATERIAL_NAME "Material #16"
			*MATERIAL_CLASS "Standard"
			*MATERIAL_AMBIENT 0.1569	0.0745	0.0000
			*MATERIAL_DIFFUSE 0.1569	0.0745	0.0000
			*MATERIAL_SPECULAR 0.9000	0.9000	0.9000
			*MATERIAL_SHINE 0.1000
			*MATERIAL_SHINESTRENGTH 0.0000
			*MATERIAL_TRANSPARENCY 0.0000
			*MATERIAL_WIRESIZE 1.0000
			*MATERIAL_SHADING Blinn
			*MATERIAL_XP_FALLOFF 0.0000
			*MATERIAL_SELFILLUM 0.0000
			*MATERIAL_FALLOFF In
			*MATERIAL_XP_TYPE Filter
		}

How/why would I use them? I'm going to use the materials (like the main materials) later, as they are stored like this:
*MESH_FACE_LIST {
			*MESH_FACE    0:    A:    0 B:  970 C:  486 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 1 	*MESH_MTLID 1
			*MESH_FACE    1:    A:  486 B:  973 C:    0 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 1 	*MESH_MTLID 1
			*MESH_FACE    2:    A:  388 B: 1788 C:  486 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 1 	*MESH_MTLID 1
			*MESH_FACE    3:    A:  486 B:  970 C:  388 AB:    2 BC:    1 CA:    0	 *MESH_SMOOTHING 1 	*MESH_MTLID 1
			*MESH_FACE    4:    A:  389 B: 1743 C:  486 AB:    2 BC:    1 CA:    0	 *MESH_SMOOTHING 1 	*MESH_MTLID 1
			*MESH_FACE    5:    A:  486 B: 1788 C:  389 AB:    2 BC:    1 CA:    0	 *MESH_SMOOTHING 1 	*MESH_MTLID 1

So it's pretty apparent how I should use the main materials. Although the odd thing is, there are only 2 material groups, yet the material ID's there go up to 2, and later on they go down as low as 0. That's a little confusing too. Does anyone know how I should be applying these submaterials?

Share this post


Link to post
Share on other sites
Advertisement
There's no real concept of submaterials in OpenGL, they are just used in 3d modelling programs to make it more managable. So you would need to create a new material for each submaterial you come across and split your model into pieces for each material. If I'm remember correctly, the .ase format also supports nested submaterials, so each submaterial may have more submaterials, which may have even more, etc.

The *MESH_MTLID tag tells which submaterial that face uses in the material that is referenced with *MATERIAL_REF in the *GEOMOBJECT block. So if the current geom object's material reference is 0, then a face with *MESH_MTLID of 1 would use the second submaterial of material 0.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!