|
楼主 |
发表于 2011-6-17 09:26:18
|
显示全部楼层
回复 2# FreeSouth
我想自己写个shader来自定义阴影效果,先是将shadowMap.cpp中预定义的fragment拷贝了出来:
- static const char fragmentShaderSource[] =
- "uniform sampler2DShadow osgShadow_shadowTexture; \n"
- "uniform vec2 osgShadow_ambientBias; \n"
- "\n"
- "void main(void) \n"
- "{ \n"
- " gl_FragColor = gl_Color * (osgShadow_ambientBias.x + shadow2DProj( osgShadow_shadowTexture, gl_TexCoord[0] ) * osgShadow_ambientBias.y); \n"
- "}\n";
复制代码
然后在程序中:
- osg::ref_ptr<osgShadow::ShadowMap> sm = new osgShadow::ShadowMap;
- osg::Shader* irShader = new osg::Shader(osg::Shader::FRAGMENT, fragmentShaderSource);
- sm->clearShaderList();
- sm->addShader(irShader);
复制代码
运行结果中没有阴影效果,而注释掉sm->addShader(irShader)就有了阴影效果。
这到底是什么情况? |
|