Adding materials
-
- Posts: 21
- Joined: Mon Oct 26, 2009 3:21 am
Adding materials
I exported a mesh from Maya in .obj and got it to load however the materials didn't. Is there a material attach class I need to use, and is this the kind of thing I should search the hierarchy for, or is it ok to ask here?
The materials for .obj files are saved into a .mtl file. If this file is in the same directory as the .obj then Irrlicht should load it.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 21
- Joined: Mon Oct 26, 2009 3:21 am
I thought that might be the case but here's what's happening:
How it looks in the maya:
How it looks in maya rendered with materials:
The code from example 1 used to load the mesh: (The only other change was the render engine to OpenGL.)
Showing I have both of the buildingtest2.mtl and .obj in the media folder:
The result in the program:
Any idea why it's not loading? (This is a rather crucial step for me.)
How it looks in the maya:
How it looks in maya rendered with materials:
The code from example 1 used to load the mesh: (The only other change was the render engine to OpenGL.)
Code: Select all
/*
To let the mesh look a little bit nicer, we change its material. We
disable lighting because we do not have a dynamic light in here, and
the mesh would be totally black otherwise. Then we set the frame loop,
such that the predefined STAND animation is used. And last, we apply a
texture to the mesh. Without it the mesh would be drawn using only a
color.
*/
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("../../media/buildingtest2.obj") );
}
The result in the program:
Any idea why it's not loading? (This is a rather crucial step for me.)
the material has already loaded (therefore you can see the colors). the thing that you don't see now is the lighting because you had it disabled.
1. enable lighting
2. create a light scene node
what you should do now isnode->setMaterialFlag(EMF_LIGHTING, false);
1. enable lighting
2. create a light scene node
My company: http://www.kloena.com
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
-
- Posts: 21
- Joined: Mon Oct 26, 2009 3:21 am
-
- Posts: 21
- Joined: Mon Oct 26, 2009 3:21 am
I added a light scene node but it still looks like it only carries over the color information. The shaders that give it a nice look didn't. Do you have to add sharers in personally and material is only flat color?
Last edited by ProjectIRR on Sat Oct 31, 2009 2:00 am, edited 1 time in total.
I don't know what sharers are (or do you mean shaders?). Probably it's something which can't be exported. Maybe play around with specular settings - the effect at the door could maybe be possible with those.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 21
- Joined: Mon Oct 26, 2009 3:21 am
(Sorry, I often just accept my spell check's changes, it doesn't know shader )
I'm not quite sure how to mess with the specular, not in maya, because it's not exporting anything but flat color, so I suppose I'd have to code it in, and I'm not sure how to do that. So your saying for anything besides flat color I'm going to have to code shaders...?
Is it this way with Blender and Max?
I'm not quite sure how to mess with the specular, not in maya, because it's not exporting anything but flat color, so I suppose I'd have to code it in, and I'm not sure how to do that. So your saying for anything besides flat color I'm going to have to code shaders...?
Is it this way with Blender and Max?
Specular-reflection are part of the material settings of your mesh and are probably multiplied with the specular part of the light. Maybe just try changing SpecularColor and Shininess values in the material. I don't know how to export such settings from Maya. In the mtl file the specular color settings are the Ks values and the shininess is the Ns value (range is 0-1000 in mtl files) so you can change those value there directly or check how they change depending on your export settings. I think specular colors are per-polygon, so the effect will probably only work if your door has many polygons.
For nicer effects you will have to use shaders. Maybe someone else can help you there as that's not my area of expertise.
For nicer effects you will have to use shaders. Maybe someone else can help you there as that's not my area of expertise.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 21
- Joined: Mon Oct 26, 2009 3:21 am
try directional light maybe it will look closer to your maya shots.
My company: http://www.kloena.com
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
-
- Posts: 21
- Joined: Mon Oct 26, 2009 3:21 am
I'm not familiar with directional lighting, is it a scene node?
Does no one here use maya, what programs do people use, because this engine isn't very Maya friendly at all. I'll have to hit some maya forums and see if it can export more than flat color.
Can shaders do all this and more? (make it look like the attributes I set in maya?
Does no one here use maya, what programs do people use, because this engine isn't very Maya friendly at all. I'll have to hit some maya forums and see if it can export more than flat color.
Can shaders do all this and more? (make it look like the attributes I set in maya?
Shaders could probably do that, but I don't know of any way to export such settings from a 3D modeller and get the corresponding shader code in the engine automatically.
Also Maya does not have to do realtime, modeling realtime graphics is just different from modeling render-graphics used for example in movies. Finding ways around that to make games still look good is part of the job. For example you could render the effect into a texture. Which means light would be static and each copy of the node would look similar. So a better solution is often that you place the nodes first and then render a lightmap - light is still static but nodes look different now. That's actually the solution we used (and then we hacked up the .obj format to support this: http://www.michaelzeilfelder.de/irrlicht.htm#Lightmaps).
Or maybe you find even ways to write an exporter or some plugin which allows you to automatically generate shadercode for certain settings, but I can't help you much there.
Also Maya does not have to do realtime, modeling realtime graphics is just different from modeling render-graphics used for example in movies. Finding ways around that to make games still look good is part of the job. For example you could render the effect into a texture. Which means light would be static and each copy of the node would look similar. So a better solution is often that you place the nodes first and then render a lightmap - light is still static but nodes look different now. That's actually the solution we used (and then we hacked up the .obj format to support this: http://www.michaelzeilfelder.de/irrlicht.htm#Lightmaps).
Or maybe you find even ways to write an exporter or some plugin which allows you to automatically generate shadercode for certain settings, but I can't help you much there.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
it's because in Maya you are just applying a flat color to it therefore it turns out to be... flat color. in Maya the material is called "shader" and that's exactly the thing you'll need. it's not that irrlicht isn't "MAYA FRIENDLY" (i'm maya user too) but the exporter does not export the whole shader and you'll need to write it yourself.ProjectIRR wrote:I'm not familiar with directional lighting, is it a scene node?
Does no one here use maya, what programs do people use, because this engine isn't very Maya friendly at all. I'll have to hit some maya forums and see if it can export more than flat color.
Can shaders do all this and more? (make it look like the attributes I set in maya?
My company: http://www.kloena.com
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
-
- Posts: 21
- Joined: Mon Oct 26, 2009 3:21 am