1

I ran into "official tuto 10 Shader" in Irrlicht 1.8.3, and i modified this official example to use the shader that I exported from Blender using the addon: http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Game_Engine/Export_GLSL

The exported material is just composed of simple diffuse and specular color that is not black at all, but in Irrlicht it looks Black

Here is part of the shader tuto in Irrlicht SDK (i just modified the names of the shader loaded) assuming no CG used, and advanced Shader used.

case video::EDT_OPENGL:
    if (UseHighLevelShaders)
    {
        if (!UseCgShaders)
        {
            /**I MODIFIED NAMES OF THE ORIGINAL FRAG VERT FILES BELOW*/
            psFileName = "../../media/mat_Material.frag";//opengl.frag";
            vsFileName = "../../media/mat_Material.vert";//opengl.vert";
        }
        else
        {
            // Use HLSL syntax for Cg
            psFileName = "../../media/d3d9.hlsl";
            vsFileName = psFileName; // both shaders are in the same file
        }
    }
    else
    {
        psFileName = "../../media/opengl.psh";
        vsFileName = "../../media/opengl.vsh";
    }
    break;
}
  • 3
    The code fragment you showed is useless. It's much more interesting to see the shaders themself. The result coming out all black indicates that the shaders are not run in the first place or that some uniforms are not properly set. We need to see the shader code, and ideally also the Irrlicht binding code to the shaders. – datenwolf Jan 06 '16 at 13:57
  • But the generated FRAG file are about 5200 lines of code :/ –  Jan 06 '16 at 14:06
  • 2
    Well, go ahead and post it. We need to see it. Don't use pastebin, just drop it into SO. To save yourself some formatting open it in some editor and apply one indentation (4 spaces or one tab) beforehand, so that it shows up properly. BTW: 5.2k LoC is quite a lot for a fragment shader. – datenwolf Jan 06 '16 at 14:08
  • 1
    Thanks for your help, here is link to Generated Blender VERT File [mat_Material.vert](http://adiaf.16mb.com/mat_Material.vert) and here is link to Generated Blender FRAG file [mat_Material.frag](http://adiaf.16mb.com/mat_Material.frag), and the original Irrlicht VERT file [opengl.vert](http://adiaf.16mb.com/opengl.vert), and finally the original Irrlicht FRAG file [opengl.frag](http://adiaf.16mb.com/opengl.frag) (need to click on those links to see the contents) –  Jan 06 '16 at 14:51

1 Answers1

3

Looking at the shader files you posted the problem is obvious: The uniforms used by the Blender Game Engine and the uniforms used by Irrlicht are very different (different name, different semantics). You can't simply drop an arbitrary shader file into an existing engine and expect it to "just" work. You have to adjust it so that it matches the host rendering code that loads it.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • ok, it's helpfull, i'm going to search how I could adjust this, I really need to solve that for my game creation project, thank you –  Jan 07 '16 at 06:36
  • @3DMaker: There are several things to consider here. First and foremost Blender's game engine is tightly integrated with Blender's own material system; the shader sources are generated on-the-fly by Blender. Also there are a number of conditional code paths in there (like if there's support for the OpenSubdiv surface subdivision library by Pixar, or if the Blender game engine detected that it's running on a AMD/ATI GPU). The Irrlicht shaders don't do any of that. And then there's the in/out variables being used. – datenwolf Jan 07 '16 at 06:52
  • @3DMaker: If you were to solve the problem properly, the best approach (silly as it may sound) would be to actually not only export GLSL sources, but also C++ source code for Irrlicht, that you then add to your Irrlicht project and use from there. In fact, shaders are normally tightly coupled to the OpenGL code that uses them, so it actually makes sense in a way, to export a full shader program into a C++ compilation unit / class (complete with GLSL sources) that you then instanciate in your program. – datenwolf Jan 07 '16 at 06:55
  • You right, it sounds too difficult to achieve, modifying Irrlicht SDK..., i guess i'm going to use the simple MTL format which is supported by Blender and understood by Irrlicht without problem –  Jan 07 '16 at 07:20