<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<font color="#330033">Hi all,<br>
<br>
</font><font color="#330033">I am trying to figure out RTT in
combination with shaders for implementing a gbuffer but I can't
get the different examples to work together.</font><br>
<font color="#330033">This is a working example for using my
shaders, but without RTT and also for setting the StateSet for the
model and not the camera.<br>
</font>
<p><font color="#330033">const char* vertSource =</font>
</p>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "#version 400\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "uniform mat4 MV;\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "uniform mat4 N;\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "uniform mat4 P;\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "layout(location = 0) in vec4 Vertex;\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "layout(location = 1) in vec3 Normal;\n"</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "smooth out vec3 p;\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "smooth out vec3 n;\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "void main(void) {\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "p = (MV * Vertex).xyz;\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "n = normalize(N * vec4(Normal, 0)).xyz;\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "gl_Position = P * vec4(p, 1);\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "}\n";</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">const char* fragSource =</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "#version 400\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "in vec3 p;\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "in vec3 n;\n"</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "layout(location = 0) out vec4 position;\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "layout(location = 1) out vec4 normal;\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "layout(location = 2) out float depth;\n"</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "void main(void) {\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "position = vec4(p,1);\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "normal = vec4(n,0);\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "depth = gl_FragCoord.z;\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> //"gl_FragColor = vec4(n,1);\n"</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> "}\n";</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">#define Test1</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">struct ProjectionMatrixCallback: public osg::Uniform::Callback {</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> ProjectionMatrixCallback(osg::Camera* camera) :</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> _camera(camera) {</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> }</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> virtual void operator()(osg::Uniform* uniform, osg::NodeVisitor* nv) {</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> uniform->set(_camera->getProjectionMatrix());</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> }</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::Camera* _camera;</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">};</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">struct NormalMatrixCallback: public osg::Uniform::Callback {</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> NormalMatrixCallback(osg::Camera* camera) :</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> _camera(camera) {</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> }</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> virtual void operator()(osg::Uniform* uniform, osg::NodeVisitor* nv) {</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::Matrixd viewMatrix = _camera->getViewMatrix();</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::Matrixd normalMatrix = osg::Matrix::inverse(viewMatrix);</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> uniform->set(normalMatrix);</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> }</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::Camera* _camera;</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">};</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">struct ModelViewMatrixCallback: public osg::Uniform::Callback {</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> ModelViewMatrixCallback(osg::Camera* camera) :</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> _camera(camera) {</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> }</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> virtual void operator()(osg::Uniform* uniform, osg::NodeVisitor* nv) {</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::Matrixd viewMatrix = _camera->getViewMatrix();</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::Matrixd modelMatrix = osg::computeLocalToWorld(nv->getNodePath());</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::Matrixd modelViewMatrix = modelMatrix * viewMatrix;</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> uniform->set(modelViewMatrix);</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> }</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::Camera* _camera;</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">};</font></pre>
<font color="#330033">
</font>
<p><font color="#330033">int main(int, char**)</font><font
color="#330033"> {</font></p>
<font color="#330033">
</font><font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osgViewer::Viewer viewer;</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::Node* model = osgDB::readNodeFile("cow.osgt");</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::ref_ptr<osg::Group> root = new osg::Group();</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> //create camera</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::Camera* camera = viewer.getCamera();</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> // create shader</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::ref_ptr<osg::Program> program = new osg::Program;</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> program-><span style=" font-style:italic;">setName</span>("shader");</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> program->addShader(new osg::Shader(osg::Shader::<span style="font-style: italic;">VERTEX</span>, vertSource));</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> program->addShader(new osg::Shader(osg::Shader::<span style="font-style: italic;">FRAGMENT</span>, fragSource));</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::StateSet* state = model->getOrCreateStateSet();</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> state->setAttributeAndModes(program.get(), osg::StateAttribute::<span style="font-style: italic;">ON</span>);</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> // add uniforms</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::Uniform* modelViewMatrix = new osg::Uniform(osg::Uniform::<span style="font-style: italic;">FLOAT_MAT4</span>, "MV");</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> modelViewMatrix->setUpdateCallback(new ModelViewMatrixCallback(camera));</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> state->addUniform(modelViewMatrix);</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::Uniform* normalMatrix = new osg::Uniform(osg::Uniform::<span style="font-style: italic;">FLOAT_MAT4</span>, "N");</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> normalMatrix->setUpdateCallback(new NormalMatrixCallback(camera));</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> state->addUniform(normalMatrix);</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> osg::Uniform* projectionMatrix = new osg::Uniform(osg::Uniform::<span style="font-style: italic;">FLOAT_MAT4</span>, "P");</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> projectionMatrix->setUpdateCallback(new ProjectionMatrixCallback(camera));</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> state->addUniform(projectionMatrix);</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> // turn lights off</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> state->setMode(GL_LIGHTING, osg::StateAttribute::<span style="font-style: italic;">OFF</span>);</font></pre>
<font color="#330033">
</font>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">
</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> // scene state run</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> root-><span style=" font-style:italic;">addChild</span>(model);</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> viewer.<span style=" font-style:italic;">setSceneData</span>(root.get());</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> viewer.setUpViewOnSingleScreen(0);</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033"> return viewer.<span style=" font-style:italic;">run</span>();</font></pre>
<font color="#330033">
</font>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><font color="#330033">}
Another working example with RTT camera but without shaders can be found here: <a class="moz-txt-link-freetext" href="https://github.com/xarray/osgRecipes/blob/master/cookbook/chapter6/ch06_04/read_depth.cpp">https://github.com/xarray/osgRecipes/blob/master/cookbook/chapter6/ch06_04/read_depth.cpp</a>
Can somebody help me combine these two or give me a minimal working example (which is documented :) ).
Thanks,
Michael
</font></pre>
</body>
</html>