[osg-users] Adding a shader cancels shadows!

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Thu May 22 15:50:05 PDT 2008


Hi Art and Mail,

it is right that you have to combine the shaders yourself. But beware! 
If you are using a vertex shader you'll have to write the projection 
part for the shadow mapping yourself. Just search the archives or drop 
me a line if you are not finding anything. I have those shaders still 
somewhere.

cheers
psy
> Hi Mail,
>
> as far as I know the osgShadow do use already shaders for its implementation. Hence if you add a shader you autmaticly cacnels the shadows.
>
> To solve that you could try to merge the osgShadow shader code and your own. However you have also to take care about all the uniforms which osgShadow sets.
>
> Best regards,
> Art
>
>
> --- Mael Blanchard <maelblanc at gmail.com> schrieb am Do, 22.5.2008:
>
>   
>> Von: Mael Blanchard <maelblanc at gmail.com>
>> Betreff: [osg-users] Adding a shader cancels shadows!
>> An: "osg-users" <osg-users at lists.openscenegraph.org>
>> Datum: Donnerstag, 22. Mai 2008, 15:05
>> Hi,
>>
>> I had a *GLSL shader* in a scene with shadows, that use a
>> *osg::**
>> shadowedScene* and it doesn't work. What is the
>> problem?
>> Can I combine my GLSL shader and a shadowed scene??
>>
>> I test it in the *osgshadow.cpp* example, i had this sample
>> of code
>> (with the basic shader of phong, with no texture) :
>>
>> ...
>>   while(arguments.read("--with-shader")) {
>> withShader = true; }
>>   if(withShader)
>>   {
>>    osg::ref_ptr<osg::Program> programObject = new
>> osg::Program;
>>
>>    std::string  repShad =
>> "C:\\SHADERS\\";
>>
>>    osg::ref_ptr<osg::Shader> phongVertexObject =  
>> new osg::Shader(
>> osg::Shader::VERTEX );
>>    osg::ref_ptr<osg::Shader> phongFragmentObject =
>> new osg::Shader(
>> osg::Shader::FRAGMENT );
>>
>>    loadShaderSource( phongVertexObject.get(),   repShad +
>> "phong.vert" );
>>    loadShaderSource( phongFragmentObject.get(), repShad +
>> "phong.frag" );
>>
>>    programObject->addShader( phongVertexObject.get() );
>>    programObject->addShader( phongFragmentObject.get()
>> );
>>
>>   
>> scene->getOrCreateStateSet()->setAttributeAndModes(programObject.get(),
>> osg::StateAttribute::ON);
>>   }
>> ...
>>
>> My shader works, but it *cancels shadows*!! :( Help me!
>>
>> Thanks in advance,
>> Mael._______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>     
>
>
>       __________________________________________________________
> Gesendet von Yahoo! Mail.
> Dem pfiffigeren Posteingang.
> http://de.overview.mail.yahoo.com
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>   



More information about the osg-users mailing list