0

I want to pass the info per face which includes the material and face index. I created an interface block in the vertex shader and assigned the values to it which I pass to Geometry Shader and than Fragment shader.

I get the vertex shader compile error for which I have no idea why its happening. I have attached my Shaders and settings code here.I am unable to figure out the error

//  Configuration setting for geometry shader

    glProgramParameteriEXT(g_programObj, GL_GEOMETRY_INPUT_TYPE_EXT, InPrimType);
    glProgramParameteriEXT(g_programObj, GL_GEOMETRY_OUTPUT_TYPE_EXT, OutPrimType);
    glProgramParameteriEXT(g_programObj, GL_GEOMETRY_VERTICES_OUT_EXT, OutVertexNum);    
    glLinkProgramARB( g_programObj);
    glGetObjectParameterivARB( g_programObj, GL_OBJECT_LINK_STATUS_ARB, &bLinked );
    if( bLinked == false ) {
        glGetInfoLogARB( g_programObj, sizeof(str), NULL, str );
        printf("Linking Fail: %s\n",str);   return false;
    }


// GL List here 

glBegin(GL_POINTS); 
        for (i = 0; i < faceNum; i++) {
            mesh->GetFaceNodes(i + 1, ver[0], ver[1], ver[2], ver[3]);
            glColor3f(1.50, 2.50, 3.50);
            glVertex4i(ver[0] - 1, ver[1] - 1, ver[2] - 1, i+1);
        }
        glEnd();
        glEndList();

Vertex Shader:

uniform samplerRect vertexTexture;
uniform int sizeNx;
uniform vec3 Cent;

varying out info
{
    vec3 material;
} outInfo;  

void main( void )
{
    int ix,iy;



    //I guess I am doing something wrong here
    outinfo.material.x = gl_Vertex.w;
    outinfo.material.y = gl_Color.y;
    outinfo.material.z = gl_Color.z;



    iy=gl_Vertex.x/sizeNx;      ix=gl_Vertex.x-iy*sizeNx;
    gl_Position.xyz = texture2DRect(vertexTexture,vec2(ix,iy)).rgb-Cent;
    gl_Position.w =1.0;

    iy=gl_Vertex.y/sizeNx;      ix=gl_Vertex.y-iy*sizeNx;
    gl_FrontColor.xyz = texture2DRect(vertexTexture,vec2(ix,iy)).rgb-Cent;
    gl_FrontColor.w = 1.0;

    iy=gl_Vertex.z/sizeNx;      ix=gl_Vertex.z-iy*sizeNx;
    gl_BackColor.xyz = texture2DRect(vertexTexture,vec2(ix,iy)).rgb-Cent;
    gl_BackColor.w  = 1.0;

    gl_PointSize=1.0;

}

Geometry Shader:

    #version 120 
    #extension GL_EXT_geometry_shader4: enable

    varying out vec4 color;

    varying in info
    {
        vec3 material;

    } inInfo[];  

    varying out info
    {
        vec3 material;

    } outInfo;  
// Doing calculations in geometry shader,so cant directly send the info from v.shader to f.shader.

Fragment Shader:

varying in info
{
    vec3 material;
    } inInfo; 

void main( void )
{
    if (color.z<0.0)
        gl_FragData[0] = vec4(inInfo.material.x ,inInfo.material.y, -(gl_FragCoord.z), inInfo.material.z);
    else
        gl_FragData[0] = vec4(inInfo.material.x ,inInfo.material.y, gl_FragCoord.z, inInfo.material.z);
}

This is all and this gives me error of Vertex shader compile error by this condition

glGetObjectParameterivARB(g_vertexShader, GL_OBJECT_COMPILE_STATUS_ARB, &bCompiled);
    if (bCompiled == false) {
        glGetInfoLogARB(g_vertexShader, sizeof(str), NULL, str);
        printf("Warning: Vertex Shader Compile Error\n\n"); return false;
    }
Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
Zachy
  • 1
  • 1
  • [Interface Blocks](https://www.khronos.org/opengl/wiki/Interface_Block_(GLSL)) are not supported in GLSL `#version 120`. See [OpenGL Shading Language 1.20 Specification](https://www.khronos.org/registry/OpenGL/index_gl.php) – Rabbid76 Jan 21 '20 at 06:29
  • Unity3D almost certainly does not support compatibility OpenGL stuff, so how is it related to this question? Also, you're using extremely outdated `ARB_shader_object` stuff with EXT_geometry_shader4 which has no support for that extension. Just use OpenGL 3.2+, not the extremely old stuff. – Nicol Bolas Jan 21 '20 at 06:37

0 Answers0