OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Post Process Effect Shader


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
guyv
Appreciator


Joined: 13 Feb 2009
Posts: 102

PostPosted: Fri Sep 15, 2017 8:27 pm    Post subject:
Post Process Effect Shader
Reply with quote

Hi,

Sorry to bother you guys... but I was wondering if you can help identify why my pass through vertex shader isn't working. In essence, if I enable the vertex shader, the scene disappears. If disable it, then the scene appears once again. No errors are generated by OSG after linking the shaders. I know that my fragment shader is working because if I set the gl_FragColor to red, then the scene is completely red.

Code:


VERTEX SHADER
=============
attribute vec4 osg_Vertex;
void main( void )
{
   gl_Position = osg_Vertex;
}

FRAGMENT SHADER
===============
uniform sampler2D tRttTexture;

void main( void )
{
   vec3 vColor = texture2D( tRttTexture, gl_TexCoord[0].st ).rgb;
   // Output color.
   gl_FragColor = vec4( vColor, 1.0 );
}



The shader is applied on a fullscreen quad using typical Ortho2D projection.

Here is the code that loads the shader which is applied to the post process geode containing a single geometry quad:

Code:

void loadShaders( )
{
    osg::StateSet* pStateSet = g_pPolyGeode->getOrCreateStateSet( );

    osg::ref_ptr<osg::Program> pProgram = new osg::Program;
    pProgram->setName( "PostProcessProgram" );

    osg::ref_ptr<osg::Shader> pVertShader = osg::Shader::readShaderFile( osg::Shader::VERTEX, osgDB::findDataFile( "shaders/osgprerender.vert" ) );
    if( pVertShader )
    {
        pVertShader->setName( "osgprerender.vert" );
        pProgram->addShader( pVertShader );
        pProgram->addBindAttribLocation( "osg_Vertex", 0 );
    }

    osg::ref_ptr<osg::Shader> pFragShader = osg::Shader::readShaderFile( osg::Shader::FRAGMENT, osgDB::findDataFile( "shaders/osgprerender.frag" ) );
    if( pFragShader )
    {
        pFragShader->setName( "osgprerender.frag" );
        pProgram->addShader( pFragShader );
    }

    // RTT texture.
    pStateSet->addUniform( new osg::Uniform( "tRttTexture", 0 ) );
    pStateSet->setAttributeAndModes( pProgram, osg::StateAttribute::ON );
}



What am I doing wrong? I tried different variation of the shader but nothing works. Here are the variations that I tried:

Code:


VARIATION #1
===========
void main( void )
{
   gl_Position = gl_Vertex;
}

VARIATION #2
===========
void main( void )
{
   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

VARIATION #3
===========
attribute vec4 osg_Vertex;
void main( void )
{
   gl_Position = gl_ModelViewProjectionMatrix * osg_Vertex;
}

VARIATION #4
===========
void main( void )
{
   gl_Position = ftransform();
}



Any help would be really appreciated...

Thank you!

Cheers,
Guy
Back to top
View user's profile Send private message
guyv
Appreciator


Joined: 13 Feb 2009
Posts: 102

PostPosted: Fri Sep 15, 2017 11:11 pm    Post subject:
Reply with quote

Please disregard this post since it is duplicated.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts override the texture with the gl_frag... GarfieldPig General 1 Sun Apr 14, 2019 8:31 am View latest post
No new posts culling / bounding calculation for sh... christoph General 3 Thu Mar 28, 2019 1:17 pm View latest post
No new posts why does the adding of lighting shade... mirro General 0 Mon Feb 11, 2019 3:03 am View latest post
No new posts Question about security of shader dev... Werner Modenbach General 5 Wed Jan 30, 2019 5:50 pm View latest post
No new posts Compiling vertext shader fails on Intel loopy General 7 Fri Dec 14, 2018 7:28 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP