Re: [osg-users] setUseVertexAttributeAliasing and frame buffer objects not working together

2016-03-29 Thread Robert Osfield
Hi Chris,

It's hard to know what is causing problems in your case as you don't
provide enough information to know what might be amiss.  In general, one
wouldn't normally combine the built-in usage with vertex aliasing - the
later is used to get the OSG to built alteranatives to the built-ins that
are no longer available in OpenGL-ES 2.x onwards and OpenGL 3.0 core
profile onwards.

Robert.



On 29 March 2016 at 04:33, Chris Kuliukas  wrote:

> Wow, can't believe my luck at stumbling into the solution for this so
> quickly..
>
>
> Code:
> osgViewer::Viewer::Windows windows;
> viewer.getWindows(windows);
> for(osgViewer::Viewer::Windows::iterator itr = windows.begin();
> itr != windows.end();
> ++itr)
> {
> osg::State *s=(*itr)->getState();
> s->resetVertexAttributeAlias(false, 8); // <-- This line
> s->setUseModelViewAndProjectionUniforms(true);
> s->setUseVertexAttributeAliasing(true);
> }
>
>
>
>
> Here is a before / after: http://imgur.com/a/aWoKB
>
>
> It looks like if you use vertex attribute aliasing it compacts the uniform
> slots by default, which screws up all fixed transform stuff (which I guess
> expects them to be in their usual spots).
> s->resetVertexAttributeAlias(false, 8); prevents it from compacting the
> uniform slots, and it all works.
>
> 
> http://www.hrwallingford.com/facilities/ship-simulation-centre (
> http://www.hrwallingford.com/facilities/ship-simulation-centre)
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=66647#66647
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] setUseVertexAttributeAliasing and frame buffer objects not working together

2016-03-28 Thread Chris Kuliukas
Wow, can't believe my luck at stumbling into the solution for this so quickly..


Code:
osgViewer::Viewer::Windows windows;
viewer.getWindows(windows);
for(osgViewer::Viewer::Windows::iterator itr = windows.begin();
itr != windows.end();
++itr)
{
osg::State *s=(*itr)->getState();
s->resetVertexAttributeAlias(false, 8); // <-- This line
s->setUseModelViewAndProjectionUniforms(true);
s->setUseVertexAttributeAliasing(true);
}




Here is a before / after: http://imgur.com/a/aWoKB


It looks like if you use vertex attribute aliasing it compacts the uniform 
slots by default, which screws up all fixed transform stuff (which I guess 
expects them to be in their usual spots). 
s->resetVertexAttributeAlias(false, 8); prevents it from compacting the uniform 
slots, and it all works.


http://www.hrwallingford.com/facilities/ship-simulation-centre 
(http://www.hrwallingford.com/facilities/ship-simulation-centre)

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66647#66647





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] setUseVertexAttributeAliasing and frame buffer objects not working together

2016-03-28 Thread Chris Kuliukas
I'm also having trouble with this, very frustrating.


http://www.hrwallingford.com/facilities/ship-simulation-centre 
(http://www.hrwallingford.com/facilities/ship-simulation-centre)

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66646#66646





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] setUseVertexAttributeAliasing and frame buffer objects not working together

2012-12-05 Thread Stuart Miller
I was able to fix it by making sure setUseVertexAttributeAliases and 
setUseModelViewAndProjectionUniforms were not called in my code, which is 
curious. I'm not sure the purpose of these methods if my shaders are already 
automatically parsed to comply with the OSG attribute model, since setting 
either of them to true causes things to break in very different ways.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50709#50709





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] setUseVertexAttributeAliasing and frame buffer objects not working together

2012-10-19 Thread Stuart Miller
Hi all,
I'm trying to implement a deferred shading model based on some papers around 
the web but I'm running into issues when using both 
setUseVertexAttributeAliasing and rendering to a texture using FBO. I can 
render to an FBO fine with attribute aliasing off, and attribute aliasing 
appears to work fine with my shaders when not rendering to any FBOs, but using 
both at the same time causes my FBO textures to be either black or just an RGB 
gradient. Basically I'm doing this:

Code:

   ref_ptrosgViewer::Viewer pOsgViewer = new osgViewer::Viewer();
   pOsgViewer-setUpViewOnSingleScreen(1);
   pOsgViewer-setCameraManipulator(new osgGA::OrbitManipulator());
   pOsgViewer-setThreadingModel(osgViewer::ViewerBase::AutomaticSelection);

   pOsgViewer-realize();
   
pOsgViewer-getCamera()-getGraphicsContext()-getState()-setUseModelViewAndProjectionUniforms(true);
   
pOsgViewer-getCamera()-getGraphicsContext()-getState()--setUseVertexAttributeAliasing(true);
   std::string filename = blah.3DS;
   ref_ptrNode pModel = osgDB::readNodeFile(filename);

   unsigned int textureWidth = 1024;
   unsigned int textureHeight = 1024;

   // Initialize the GBuffer
   // Create osg::Texture2D objects to store the image data and map them to 
GBuffer types
   ref_ptrTexture2D pNormalTex = new Texture2D();
   pNormalTex-setTextureSize(textureWidth, textureHeight);
   pNormalTex-setInternalFormat(GL_RGBA);
   pNormalTex-setFilter(Texture2D::MIN_FILTER, Texture2D::LINEAR);
   pNormalTex-setFilter(Texture2D::MAG_FILTER, Texture2D::LINEAR);

   ref_ptrCamera pNormalCam = new Camera();

   pNormalCam-setClearColor(Vec4(1.0, 1.0, 1.0, 1.0));
   pNormalCam-setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
pNormalCam-setGraphicsContext(pOsgViewer-getCamera()-getGraphicsContext());
   pNormalCam-setRenderTargetImplementation(Camera::FRAME_BUFFER_OBJECT);
   pNormalCam-setRenderOrder(Camera::PRE_RENDER);
   pNormalCam-setViewport(0, 0, pNormalTex-getTextureWidth(), 
pNormalTex-getTextureHeight());
   pNormalCam-attach(Camera::COLOR_BUFFER, pNormalTex.get(), 0, 0, false);
   attachShader(pNormalCam, GBUFFER_NORMAL);
   pNormalCam-addChild(pModel.get());

   ref_ptrosg::Group pGroup = new Group();
   pGroup-addChild(pNormalCam.get());
   pGroup-addChild(pModel.get());
   pOsgViewer-setSceneData(pGroup.get());

   pOsgViewer-run();



attachShader() just looks like this:

Code:

bool ShadedScene::attachShader(Camera* pCam, GBufferTypes programType)
{
   if (pCam == NULL)
   {
  return false;
   }

   ref_ptrShader pVertShader = new Shader(Shader::VERTEX);
   ref_ptrShader pFragShader = new Shader(Shader::FRAGMENT);
   ref_ptrProgram pShaderProgram = new Program();
   pShaderProgram-addShader(pVertShader.get());
   pShaderProgram-addShader(pFragShader.get());

   StateSet* pCamSs = pCam-getOrCreateStateSet();
   if (pCamSs == NULL)
   {
  return false;
   }
   pCamSs-setAttributeAndModes(pShaderProgram.get(), StateAttribute::ON);

   switch (programType)
   {
   case GBUFFER_NORMAL:
  pVertShader-setShaderSource(normalVertShader);
  pFragShader-setShaderSource(normalFragShader);
  break;
   default:
  break;
   }

   return true;
}



My shaders:

Code:
static std::string normalVertShader = uniform mat4 
osg_ModelViewProjectionMatrix;\n
   uniform mat3 osg_NormalMatrix;\n
   varying vec3 vVaryingNormal;\n
   void main(void)\n
   {\n
  vVaryingNormal = osg_NormalMatrix * gl_Normal;\n
  gl_Position = osg_ModelViewProjectionMatrix * gl_Vertex;\n
   }\n;

static std::string normalFragShader =
   #version 120\n
   varying vec3 vVaryingNormal;\n
   void main(void)\n
   {\n
  gl_FragColor.rgb = vVaryingNormal;\n
   }\n;




I'm using OSG trunk rev13134 for what I'm working on but I also had similar 
issues back when using 3.0.1. I'm not sure if I'm missing something or what. 
Some of this stuff is doable without attribute aliasing but it's more 
complicated - i.e. accessing the texture coordinates for a model doesn't seem 
particularly straightforward and I've not seen a simple way to do it when 
loading in a 3D model. Just curious if I'm missing something glaringly obvious. 
What I posted is a stripped-down version of what I'm working on but it covers 
everything I'm actually doing in relation to OSG.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50649#50649





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org