[SOLVED] OpenGL Buffer object

How would one go about sending a buffer object to the GPU in Panda3D? Like a VBO.
Perhaps even choose how to bind it from frame to frame.
One you can use like this in GLSL:

layout (location = 0) in vec4 buffer

Is it possible to use PyOpenGL in pandas context?
This would complete Panda pretty nicely for me. I couldn’t find any way of doing this so I’ve been learning PyOpenGL and I suppose that’s nice. I really really like panda and PyOpenGL can be hell at times.

You can’t pass buffer objects right now I think, however, if you don’t have a huge amount of data you can just use an array of data, e.g. PTAFloat, so:

myData = PTAFloat.empty_array(100)
myObject.setShaderInput("data", myData)

And in your shader:

uniform float data[100];

Thanks for the help! I will consider this. : )

I think tobspr might have been thinking about UBOs or SSBOs, which aren’t currently supported in Panda.

A VBO is basically a GeomVertexArrayData object in Panda, a list of which is stored under a Geom (which more or less represents a VAO in OpenGL).

There’s a whole section in the manual dedicated to explaining how to create a VBO in Panda3D, specifically “Advanced operations with Panda3D’s internal structures”.

They are bound in Panda3D by name, and as such there is no need to use layout(location) since Panda3D chooses the correct bind point automatically. You should just make sure to give them the same name as you gave to Panda3D in the GeomVertexFormat, or alternatively, one of the special names p3d_Vertex or p3d_Normal, etc. This page documents some specially recognised names for VBO binding points:
panda3d.org/manual/index.ph … der_Inputs

Sorry for my misleading information, I thought you were talking about UBO’s / SSBO’s … :stuck_out_tongue:

I suspected the Geoms where VAOs.

You mean if I name a GeomVertexArrayData say “hello”, I can access its data in GLSL vertex shader?

in vec4 hello;

I never really got geoms to work but that’s not pandas fault. I tried accessing with “layout (location = whatever)” but I’ll give this a shot. Thanks everyone for your help!

Yes, if you call that column “hello” in your GeomVertexFormat.

Geom is the fundamental class for presenting geometry in Panda3D - all vertex data is stored in VBOs in Panda. If you can see any model at all in Panda, that implies that you got Geoms working. :slight_smile:

In any case, I would suggest that you get a development build of Panda3D, since GLSL support has been improved since 1.8.1.

Tried this and found out it’s a little bit tricky (I am using developer version of Panda, 1.9). Just thought I should add this for completeness sake in case anyone finds this and wonders what’s going on.

If one wants to add columns with custom names (as explained in panda3d.org/manual/index.php … rtexFormat) for use in GLSL shaders, one has to have atleast one column named ‘vertex’ or it wont work.

This does not work:

vertex_array = GeomVertexArrayFormat()
vertex_array.addColumn(
	InternalName.make('whatevs'), 3,
	Geom.NTFloat32, Geom.COther)

This works:

vertex_array = GeomVertexArrayFormat()
vertex_array.addColumn(
	InternalName.make('vertex'), 3,
	Geom.NTFloat32, Geom.COther)
vertex_array.addColumn(
	InternalName.make('whatevs'), 3,
	Geom.NTFloat32, Geom.COther)

whatevs can now be called in GLSL shader:

in vec3 vertex;
in vec3 whatevs;

This is only important if one needs more than one column. Otherwise why not just use ‘vertex’?
Also why care at all? I’m personally trying to do a GPU particle system.

I’ll wager a guess that Panda3D uses it to generate the bounding volume for culling. It needs to know the position of all the vertices before it can know where the Geom is in 3-D space with respect to the camera, and thus when it is in view and should or should not be rendered.

Try overriding Panda’s bounding volume generation mechanism with a call like the following:

node.setBounds(OmniBoundingVolume())
node.setFinal(True)

(Alternatively, you can call setBounds on the Geom object itself, which alleviates the need for the setFinal call.)

Of course, if you still want to take advantage of Panda3D’s frustum culling, you should pass some other bounding volume definition rather than OmniBoundingVolume(), which is effectively telling Panda that the Geom occupies all of space and should always be rendered.