Hi,

I have some problems while using geometry shader and TextureArray to optimize 
PSSM shadow, the test code is like following:
C++ code:
osg::TextureArray *ta = new osg::TextureArray;
ta->setTextureSize(1024, 1024, 3);     //3 layer texture
...
shadowCamera->attach(osg::Camera::COLOR_BUFFER, ta, 0, 0);  //
shadowCamera->attach(osg::Camera::COLOR_BUFFER, ta, 0, 1);
shadowCamera->attach(osg::Camera::COLOR_BUFFER, ta, 0, 2);

Geometry shader code:

#extension GL_EXT_geometry_shader4 : require

varying vec4 color;

void main()
{
    //Route to Layer 0
    for (int i = 0; i < 3; i++)
    {
        // You will recieve 3 positions since we set the input type to Triangles
        gl_Position = 0.5*gl_PositionIn[i] - vec4(0.5, 0.0, 0.0, 1.0);   
        gl_FrontColor = vec4(1.0, 0.0, 0.0,1.0);
        gl_Layer = 0;
        EmitVertex();
    }
    EndPrimitive();

    //Route to Layer 1
    for (int i = 0; i < 3; i++)
    {
        gl_Position = 0.5*gl_PositionIn[i];
        //Just to see a difference in Layer 1
        gl_FrontColor = vec4(0.0, 1.0, 0.0,1.0);
        gl_Layer = 1;
        EmitVertex();
    }
    EndPrimitive();
    //Route to Layer 2
    for (int i = 0; i < 3; i++)
    {
        gl_Position = 0.5*gl_PositionIn[i] + vec4(0.5, 0.0, 0.0, 1.0);
        //Just to see a difference in Layer 1
        gl_FrontColor = vec4(0.0, 1.0, 0.0,1.0);
        gl_Layer = 2;
        EmitVertex();
    }
    EndPrimitive();
}

during the testing , only the 1st layer of texture have avaliable context(scene 
with red color), other 2 layers are undefined. Has some one sucessed in layer 
rendering? please give some advise, thanks a lot!


Cheers,
xiakai

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=25314#25314





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to