Normal map shading problem and advanced material questions

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.
Post Reply
thinkinmonkey
Posts: 2
Joined: Tue Jul 14, 2009 10:11 am

Normal map shading problem and advanced material questions

Post by thinkinmonkey »

Hi all,
I'm moving first steps with Irrlicht and I have some questions for you.
The most important is about a strange fact: I've studied some tutorials and copying the same instructions from them, but as you can see in these screenshots:
ImageImage
on the left you have only diffuse channel, while, on the right, you can see the normalmap applied.
The problem is when the normal map is on, using the same commands found in tutorial 11, I have the mesh in flat shading, if you know what I mean, every polygon is visible, instead I'd like to have a well smoothed shading, I read the manual, but there's no instruction like "EMT_NORMAL_MAP_SMOOTH".
So what's wrong with it or what should I do to render my knight with normal map right?

The second question is about how to create advanced material.
I want my knight with material with a diffuse, normal map and transparency: I've tried a lot of combination but with no success, ok, I give it a fast try, but it seems impossible to have a material with normal map and transparency (the diffuse texture has alpha channel for transparency).
Other than that, I should know if Irrlicht is able to manage specular map as well.
How can I have advanced shader like that? Is DirectX better than OpenLG or it's just a question of programming directly in GLSL or HLSLS to achieve what I want? Where can I find some useful tutorial/documentation?
Thanks in advance, I really need help.
Michael
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

When creating the tangent mesh (as part of your code to create the normal map effect) you should check the parameters for preserving the original normals. This should fix your problems with flat shading (which is actually a problem with per-face normals, flat shading would also affect color interpolation on the edges).
Right now, Irrlicht has transparency handled as a separate material. We're going to factor that property out in one of the next versions, but right now you have to alter the vertex shader on your own to fix this issue.
Specular map would also need another tweak of the shader, in order to support the specular values from the third texture layer. If you want to use HLSL or GLSL for this purpose is a matter of taste and knowledge about the language.
thinkinmonkey
Posts: 2
Joined: Tue Jul 14, 2009 10:11 am

Post by thinkinmonkey »

Hybrid,
thanks for you answer and I hope you have a little time to answer me again.
I've seen that createMeshWithTangents has three attributes about normals, but no combinations seem to work for my case: if you was speaking about something else, please, be kind to tell me what to do.

About transparency and vertex shader, I suppose you're referring to make transparent the mesh where needs but using vertices, that is not the same result achieved by using texture: if I'm right, alpha on vertices Vs alpha texture on polygons, I have to wait next version.

About specular map (values from texture), I don't understand if it's possible to have or not, I don't understand what you mean with "tweak the shader": is Irrlicht able to handle that and how?

Because I'm in hurry, really, I have to take a choice in order to have quasi Triple A shader, so my doubts are about:
1. Better HSLS or GLSL, I mean, as well supported by most video cards, simple programming, and so on...
2. Could nVidia's Fx Composer be of any help for me (Geforce owner) to boost my project?

Thanks in advance for any help.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I guess you have to use false, true, true as parameters.
You have to program the transparency handling inside the shaders. That's not done inside the currently used shaders. Just as with the specular map, you have to do it on your own.
And 1./2. There's no difference between GLSL and HLSL support/features/other sutff. And yes, you can use tools for shader generation. They need to be adapted later on, but that's a minor part.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I recommend checking out this normal mapping shader: http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=21186

It doesn't use the mesh tangents so you don't have to use createMeshWithTangents() and it also support specular mapping.

To get texture transparency with that shader, add

Code: Select all

"   color.a = fvBaseColor.a;"
right before

Code: Select all

"   gl_FragColor = color;" 
And change

Code: Select all

 mtlToonShader = gpu->addHighLevelShaderMaterial(
               vertBumpShader.c_str(), "main", video::EVST_VS_1_1,
               fragBumpShader.c_str(), "main", video::EPST_PS_1_1,
               callback, video::EMT_SOLID);


to

Code: Select all

 mtlToonShader = gpu->addHighLevelShaderMaterial(
               vertBumpShader.c_str(), "main", video::EVST_VS_1_1,
               fragBumpShader.c_str(), "main", video::EPST_PS_1_1,
               callback, video::EMT_TRANSPARENT_ALPHA_CHANNEL);


This should give you everything you want in OPEN_GL.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Post Reply