[osg-users] Minimal Shader Storage Buffer Object example?
Marius Dransfeld
marius.dransfeld at gmail.com
Thu Jan 28 03:06:39 PST 2016
Hi,
I am trying to get a minimal SSBO example running. I took a look at the osgSSBO example and tried to extract the required steps to upload a float array to the shader:
Code:
osg::ref_ptr<osg::Geometry> fsQuad = osgDeferred::Util::createFullScreenQuad();
fsQuad->getOrCreateStateSet()->setAttributeAndModes(
osgDeferred::Util::loadProgram("assets/shader/FsQuad.vert",
"assets/shader/SSBO.frag"));
osg::ref_ptr<osg::ShaderStorageBufferObject> ssbo = new osg::ShaderStorageBufferObject();
osg::ref_ptr<osg::FloatArray> data = new osg::FloatArray();
data->push_back(1.0f);
data->push_back(0.0f);
data->push_back(0.0f);
data->push_back(1.0f);
data->setBufferObject(ssbo.get());
// ssbo->addBufferData(data.get());
osg::ref_ptr<osg::ShaderStorageBufferBinding> ssbb = new osg::ShaderStorageBufferBinding(0,
ssbo.get(), 0, sizeof(GLfloat) * 4);
fsQuad->getOrCreateStateSet()->setAttributeAndModes(ssbb.get())
SSBO.frag
Code:
#version 450 core
in vec2 vTexCoord;
out vec4 outColor;
layout(std430, binding = 0) coherent buffer ColorSSBO {
vec4 color;
};
void main() {
outColor = color;
//outColor = vec4(1,0,0,1);
}
This code does not work, i.e. the screen is black and not red.
Looking at the OpenGL commands I see
glGenBuffers(1, [1])
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 1)
and repeating every frame:
glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 0, 1, 0, 16);
But there is never any data uploaded.
Am I missing something? The osgSSBO example is running fine, at least I see a spinning ball of particles.
Thank you!
Cheers,
Marius[/code]
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66158#66158
More information about the osg-users
mailing list