Hello,

On Sun, 2014-05-04 at 15:33 +0200, Carsten Neumann wrote:
>       Hello Marcel,
> 
> On 05/04/2014 02:34 PM, Marcel Weiler wrote:
> > I am trying to use compute shaders in OpenSG but can't make them work.
> > The compute shader should modify the texture of a plane, but it never
> > gets activated.
> 
> do you mean there is no OpenGL call to launch the compute shader or is 
> the texture simply unchanged?
> 
> > My current setup is as follows: I load the OSGContribComputeBase Library
> > using OSG::preloadSharedObject("OSGContribComputeBase") Snippet before I
> > call osgInit(argc, argv). Then I set up my scene. The root has two
> > children: a node with a geometry core which consists of a plane with a
> > texture (ChunkMaterial with MaterialChunk, TextureObjectChunk and
> > TextureEnvChunk) and node with an AlgorithmComputeElement core which
> > holds the compute shader. The compute shader setup looks as follows
> > Snippet
> >
> >             NodeRecPtr  computeNode  =  Node::create();
> >             AlgorithmComputeElementRecPtr  computeElement  =  
> > AlgorithmComputeElement::create();
> >             ComputeShaderAlgorithmRecPtr  computeAlgorithm  =  
> > ComputeShaderAlgorithm::create();
> >             _comp  =  OSG::ComputeShaderChunk::create();
> >             _comp->addUniformVariable("destTex",  (int)  
> > bottom_tex->getGLId());
> 
> This looks suspect. I haven't used compute shaders (through OpenSG or 
> otherwise), but normally texture uniforms are set to the texture unit 
> the texture is bound to, not the OpenGL id.
> Shouldn't bottom_tex be added to MFTextureImages of computeAlgorithm 
> (this makes sure the texture is activated before executing the shader)?
> 
> The id returned by getGLId() is _not_ an OpenGL object name, it is 
> simply an id OpenSG uses to access the actual OpenGL object on different 
> contexts. You can use that id together with a context (i.e. OSG::Window) 
> to get the "real" OpenGL object name (Window::getGLObjectId()).

Carsten is right, it should be the texture image unit, I would guess 0
in this case, the MFTextureImages index in general. One further note,
as the compute node is part of the tree you have to make sure it is
not culled away. Either put the compute node  as a group above the
plane / element you want to render (this is what
Examples/CSM/NewShader/Compute does) or set the compute nodes BBox to
inifite and static.

kind regards
  gerrit



------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to