Hi all,

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.

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();
SnippetSnippet          _comp->addUniformVariable("destTex",  (int)  
bottom_tex->getGLId());
                _comp->addUniformVariable("roll",  0.0f);

                _comp->setComputeProgram(_compute_program);
                TextureImageChunkRecPtr  tiChunk  =  
TextureImageChunk::create();
                tiChunk->setTexture(bottom_tex);
                tiChunk->setAccess(GL_WRITE_ONLY);
                tiChunk->setFormat(GL_RGBA32F);
                MFUnrecTextureImageChunkPtr  *  tiChunks  =  
computeAlgorithm->editMFTextureImages();
                tiChunks->push_back(tiChunk);
computeAlgorithm->setDispatchConfig(OSG::Vec3i(64, 64, 1));
                computeAlgorithm->setComputeShader(_comp);
                computeElement->setAlgorithm(computeAlgorithm);
                computeNode->setCore(computeElement);
                _scene->addChild(computeNode);

The ComputeShaderChunk _comp is declared as global variable so that I can change its uniform variables easily, and bottom_tex is the TextureObejctChunk of the plane's material.

Is this setup correct or are there any other things I need to consider when using compute shaders?

Kind regards,
Marcel


---
Diese E-Mail ist frei von Viren und Malware, denn der avast! Antivirus Schutz 
ist aktiv.
http://www.avast.com
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to