Purple model

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Asimov
Posts: 246
Joined: Thu Dec 04, 2014 7:41 pm
Contact:

Purple model

Post by Asimov »

Hi all,

I am wondering if anyone knows why my model has come out purple. I am having to use OpenGL cos it complains if I use Directx LOL.
By the way I am new here, so will probably be asking a lot of stupid questions heh heh.

Code: Select all

IMesh* invader = smgr->getMesh("invadertest.obj");
IMeshSceneNode*node = smgr->addMeshSceneNode(invader);
 
if (node)
{
 
    node->setMaterialTexture(0, driver->getTexture("invader.tga"));
    node->setMaterialFlag(EMF_LIGHTING, false);
}
smgr->addCameraSceneNode(0,vector3df(100, 70, 150), vector3df(0, 70, 60));
The original model has tranparency maps and normalmaps, but so far I have only worked out how to load the diffuse tga in. By the way I have also tried converting my tga to jpg, and bmp, and it is still purple.

Image
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Purple model

Post by mongoose7 »

May be wrong Irrlicht DLL. Try compiling Irrlicht and your code with the same settings, say both DEBUG.
juanjpro
Posts: 12
Joined: Mon Nov 24, 2014 12:54 pm

Re: Purple model

Post by juanjpro »

Have you tried other models to see if they have this issue?
Asimov
Posts: 246
Joined: Thu Dec 04, 2014 7:41 pm
Contact:

Re: Purple model

Post by Asimov »

Hi all,

I have found a workaround for this issue.
My model was exported from 3ds max as an obj.

So this is what I tried. I loaded one of the stock models from the irrlicht media folder and put my texture on, and strangely enough my texture was the correct colour.
So then I think that irrlicht is having a problem with obj format.

So I searched and found an md2 exporter for max. Then I exported my model in md2 format, and now the colour is fine.

All I have to do now is to work out how to load in the normalmap and the transparency now.
I have already made it spin heh heh, but not in deltatime. Haven't quite worked out how delta time works yet. So it will probably spin twice as fast on another computer heh heh.

Image
CuteAlien
Admin
Posts: 9682
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Purple model

Post by CuteAlien »

Would have been interesting which material type the obj loader has assigned to this model (node->getMaterial(0).MaterialType).
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
Asimov
Posts: 246
Joined: Thu Dec 04, 2014 7:41 pm
Contact:

Re: Purple model

Post by Asimov »

Hi CuteAlien,

Unfortunately once I got the md2 model to work I deleted the obj that I had created. I just used this code to load it

Code: Select all

 
IMesh* invader = smgr->getMesh("data/invad.obj");
IMeshSceneNode*node = smgr->addMeshSceneNode(invader);
//smgr->loadScene("testscene.irr");
if (node)
{
    node->setMaterialFlag(EMF_LIGHTING, false);
    node->setMaterialTexture(0, driver->getTexture("data/invader2.tga"));
}
 
Mind you I found out later that I can export from max 2015 with 3ds format and that works quite nicely also.

Had a bit of fun trying to get my opacity map to work. Then I read that you cannot have a separate transparent map and it has to be in the alpha.
So I added my transparent map to the alpha with these settings
EMT_TRANSPARENT_ADD_COLOR
and then I tried a few other settings. and I couldn't get it to work in OPENGL.

I would have tried DIRECTX9 but code::blocks and mingw gcc compiler don't seem to have it, and I haven't quite worked out how to recompile the dll for directx yet.

I am painfully slowly learning new things. I got delta time to work now anyway.

Asimov
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Purple model

Post by mongoose7 »

How you loaded it is of no consequence. The question is, how did the loaded manage to remove the green component in the colour. My guess is that the material file had diffuse after diffuse map, so the material had a colour as well as a map.

For TRANSPARENT_ADD_COLOR you need two textures. The alpha channel is not used in this case. Maybe you want to try TRANSPARENT_ALPHA_CHANNEL.
Asimov
Posts: 246
Joined: Thu Dec 04, 2014 7:41 pm
Contact:

Re: Purple model

Post by Asimov »

Hi Moongoose,

Well I have tried various things to get my opacity map to work. I only added the opacity to the alpha because after a lot of google searches I read that is what other people do. Whether they are right or wrong, I have no idea. I know in Unity you also have to add the opacity map to the alpha of the image, thus being TGA.

However personally I prefer to keep my maps as separate maps eg diffuse, specular and opacity.
I tried this

Code: Select all

node->getMaterial(0).MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL;
Which seemed to make my whole model transparent and odd black things all over it.

I wonder if you could show me the code that lets me load a diffuse, and an opacity as separate maps?
I will be wanting to use a normalmap also at some point.

By the way I do have a game in mind, but learning to walk before I can run. Before I can make a game I have to know how to load my models in.

Asimov
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Purple model

Post by hendu »

The fixed materials do not support such separate alpha. You will need to write a shader.
Asimov
Posts: 246
Joined: Thu Dec 04, 2014 7:41 pm
Contact:

Re: Purple model

Post by Asimov »

Hi Hendu,

I messed around with shaders in Unity, but I only achieved simple shaders. Not delved too deeply into it.
Is writing a shader using irrlicht similar to how other game engines works.

I presume it would have to be written in C++ though.

Now I am going to have to learn how to make a shader.

I have been busy building my new scene for my game in 3ds max too.

Asimov
CuteAlien
Admin
Posts: 9682
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Purple model

Post by CuteAlien »

Shaders ware written in GLSL (for OpenGL) or HLSL (for Direct3D). Irrlicht has no own shader language. In theory you could also use cg, but Nadro recently mentioned that it's getting deprecated, so probably not a good idea to use that.

There are some examples in the media folder and there is a shader example how to use them.

It usually takes a while to get results as good as you get without much work with the fixed function pipeline. A good starting point are probably the GLSL shaders in the Irrlicht ogl-es branch. Those try to simulate the fixed function pipeline. And certainly the advantage is that you can code the graphiccard then directly to do much more than the fixed functions it offers through opengl/direct3d.
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
Asimov
Posts: 246
Joined: Thu Dec 04, 2014 7:41 pm
Contact:

Re: Purple model

Post by Asimov »

Hi CuteAlien,

Thanks. I really want to use directx, because I like directx. Spent the last few hours trying to recompile the irrlicht library with no success. I know there is GLSL but I don't really want to learn how to do an openGL shader when I really want to use directx. I keep getting errors at the moment eg fatal error: d3dx9.shader.h. no such file or directory. I downloaded the directx9 sdk and installed it and pointed to the correct directory like in this tutorial http://irrlicht3d.org/wiki/index.php?n= ... 9WithMinGW. I am getting a little disheartened, so I gave up and did a little more 3d in max heh heh. I have almost finishhed building my game room. Then I am going to texture it in mudbox. A new pipeline that I have been trying out. I am using code::blocks and mingw gcc at the moment.

Asimov
CuteAlien
Admin
Posts: 9682
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Purple model

Post by CuteAlien »

Error sounds pretty clear. It does not find that file. So either it's not there or your include path is wrong.

Thought no idea why anyone would prefer a proprietary API which runs only on one platform to an open one that runs basically on all platforms these days. GLSL can for example be used in Windows, Linux, MacOSX, Android, iPhone and some more. By now even most browsers support webgl (which is basically GLSL). While HLSL, well ... runs on Windows, that's it. So you just make it harder to ever port your game to other platforms without gaining anything.
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
Asimov
Posts: 246
Joined: Thu Dec 04, 2014 7:41 pm
Contact:

Re: Purple model

Post by Asimov »

Hi CuteAlien,

Mainly it is because I have an Nvidia graphics card and directx is actually written for the nvidia card. I have no intention of porting my game to linux, or mac. So it will be windows only.
The only time I have ever used Linux is on a server and I am not over fond of the operating system. As for a mac I have never used one. I have no intention of making money from my game, so I am happy to use directx. Also when it comes to sound I know how to program the sound in directx already, as I have done it in previous 2D projects, and I can just port my sound class over to be used in the irrlicht game engine when I get that far heh heh.
CuteAlien
Admin
Posts: 9682
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Purple model

Post by CuteAlien »

NVidia cards also have OpenGL drivers - you probably won't notice a difference there. But your choice certainly.
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
Post Reply