diff --git a/src/osgPlugins/glsl/ReaderWriterGLSL.cpp b/src/osgPlugins/glsl/ReaderWriterGLSL.cpp index 61fcafbaa..45560b95e 100644 --- a/src/osgPlugins/glsl/ReaderWriterGLSL.cpp +++ b/src/osgPlugins/glsl/ReaderWriterGLSL.cpp @@ -62,7 +62,17 @@ class ReaderWriterGLSL : public osgDB::ReaderWriter osgDB::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary); if(!istream) return ReadResult::FILE_NOT_HANDLED; ReadResult rr = readShader(istream, options); - if(rr.validShader()) rr.getShader()->setFileName(file); + if(rr.validShader()) + { + osg::Shader* shader = rr.getShader(); + shader->setFileName(file); + if (shader->getType() == osg::Shader::UNDEFINED) + { + // set type based on filename extension, where possible + if (ext == "frag") shader->setType(osg::Shader::FRAGMENT); + if (ext == "vert") shader->setType(osg::Shader::VERTEX); + } + } return rr; }