Page 1 of 1

GLSL geometry input/output primitive issue

Posted: Sat Jun 22, 2013 9:16 pm
by Tannz0rz
I've been trying to make use of geometry shaders recently and I've come to notice that only the "triangles" layout appears to work. All other layouts don't render the mesh visible at all. Mind you, I've tried simple pass-throughs for testing purposes.

Vert and frag programs for both:

Code: Select all

 
// Vert
void main()
{
    gl_Position = ftransform();
}
 
// Frag
void main()
{
    gl_FragColor = vec4(1.0);
}
 
As triangle:

Code: Select all

 
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
 
void main() 
{
    for(int i = 0; i < 3; i++) 
    {
        gl_Position = gl_in[i].gl_Position;
        
        EmitVertex();
    }
    
    EndPrimitive();
}
 
As line:

Code: Select all

 
layout(lines) in;
layout(line_strip, max_vertices = 2) out;
 
void main() 
{
    for(int i = 0; i < 2; i++) 
    {
        gl_Position = gl_in[i].gl_Position;
 
        EmitVertex();
    }
 
    EndPrimitive();
}
 
Even though these images should be unnecessary, they always make understanding easier:
Triangle
Line

And yes, I have properly set the compile targets and primitive type parameters in my "addHighLevelShaderMaterial" call. I've come to notice that even if I have the primitive type set to something aside from EPT_TRIANGLES and EPT_TRIANGLE_STRIP the triangle code still works. I've even tried a "points" pass-through (uses only 1 vertex) to no avail.

Running Irrlicht 1.8 on a Radeon Sapphire HD 5770.

Regards,
Tannz0rz

Re: GLSL geometry input/output primitive issue

Posted: Sun Jun 23, 2013 6:16 am
by Tannz0rz
I found the bit I've been looking for. Was this just a mistake or is it intentionally unimplemented?

Code: Select all

 
COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver* driver,
        s32& outMaterialTypeNr, const c8* vertexShaderProgram,
        const c8* vertexShaderEntryPointName,
        E_VERTEX_SHADER_TYPE vsCompileTarget,
        const c8* pixelShaderProgram,
        const c8* pixelShaderEntryPointName,
        E_PIXEL_SHADER_TYPE psCompileTarget,
        const c8* geometryShaderProgram,
        const c8* geometryShaderEntryPointName,
        E_GEOMETRY_SHADER_TYPE gsCompileTarget,
        scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType,
        u32 verticesOut,
        IShaderConstantSetCallBack* callback,
        video::IMaterialRenderer* baseMaterial,
        s32 userData)
    : Driver(driver), CallBack(callback), BaseMaterial(baseMaterial),
        Program(0), Program2(0), UserData(userData)
{
    #ifdef _DEBUG
    setDebugName("COpenGLSLMaterialRenderer");
    #endif
 
    //entry points must always be main, and the compile target isn't selectable
    //it is fine to ignore what has been asked for, as the compiler should spot anything wrong
    //just check that GLSL is available
 
    if (BaseMaterial)
        BaseMaterial->grab();
 
    if (CallBack)
        CallBack->grab();
 
    if (!Driver->queryFeature(EVDF_ARB_GLSL))
        return;
 
    init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram, geometryShaderProgram);
}
 
I'm assuming the "init" call is supposed to be:

Code: Select all

init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram, geometryShaderProgram, inType, outType, verticesOut);
EDIT: Rebuilt it with the correction and... it's doing the same thing. Looks like I still need some help.

Re: GLSL geometry input/output primitive issue

Posted: Thu Jun 27, 2013 7:39 pm
by Tannz0rz
Bump. Anyone have an answer?

Re: GLSL geometry input/output primitive issue

Posted: Thu Jun 27, 2013 8:12 pm
by Cube_
Sorry, I am a dummy when it comes to shading ^^; (btw bumping it is pretty unnecessary, since someone will stumble upon it eventually (oh and you should use the edit function when adding information instead of double posting)

Re: GLSL geometry input/output primitive issue

Posted: Mon Jul 01, 2013 3:40 pm
by CuteAlien
Bump once in a while is ok :-)