I want to export Points form Blender model

I make a geometry shader. The shader be able to vertices into grass. But when export a only point model, VertexPool is empty.


YABEE works with polygons and ignores vertices, which not assigned to them. You can try to export vertices through *.x format and then convert it with x2egg.

This is my gress.x file:

xof 0303txt 0032

Frame Root {
  FrameTransformMatrix {
     1.000000, 0.000000, 0.000000, 0.000000,
     0.000000, 0.000000, 1.000000, 0.000000,
     0.000000, 1.000000,-0.000000, 0.000000,
     0.000000, 0.000000, 0.000000, 1.000000;;
  }
  Frame gress2 {
    FrameTransformMatrix {
      -1.000000,-0.000000, 0.000000, 0.000000,
       0.000000,-1.000000, 0.000000, 0.000000,
       0.000000, 0.000000, 1.000000, 0.000000,
       0.000000, 0.000000, 0.000000, 1.000000;;
    }
    Mesh { //Plane_003 Mesh
      0;
      0;
      MeshNormals { //Plane_003 Normals
        0;
        0;
      } //End of Plane_003 Normals
      MeshMaterialList { //Plane_003 Material List
        0;
        0;
      } //End of Plane_003 Material List
      MeshTextureCoords { //Plane_003 UV Coordinates
        0;
      } //End of Plane_003 UV Coordinates
    } //End of Plane_003 Mesh
  } //End of gress2
  Frame gress1 {
    FrameTransformMatrix {
       1.000000, 0.000000, 0.000000, 0.000000,
       0.000000, 1.000000, 0.000000, 0.000000,
       0.000000, 0.000000, 1.000000, 0.000000,
       0.000000, 0.000000, 0.000000, 1.000000;;
    }
    Mesh { //Plane_003 Mesh
      0;
      0;
      MeshNormals { //Plane_003 Normals
        0;
        0;
      } //End of Plane_003 Normals
      MeshMaterialList { //Plane_003 Material List
        0;
        0;
      } //End of Plane_003 Material List
      MeshTextureCoords { //Plane_003 UV Coordinates
        0;
      } //End of Plane_003 UV Coordinates
    } //End of Plane_003 Mesh
  } //End of gress1
} //End of Root Frame

“grass1” and “grass2” are still empty.

Hmm… seems that *.x also not support separate vertices. Another variant - *.obj -> obj2egg

Indeed there are many vertices in the gress.obj file, but when I use obj2egg, the gress.egg is:

<CoordinateSystem> { Z-Up }

<Comment> {
  "obj2egg gress.obj -o gress.egg"
}
<VertexPool> vpool {
}
<Group> root {
}

When I use:

...
...
g = loader.loadModel('bridge')
g.reparentTo(render)
gress = loader.loadModel('gress.obj')
gress.reparentTo(render)
gress.ls()
...
...
...
shader = Shader.load(Shader.SLGLSL, 'vshader.glsl', 'fshader.glsl', 'gshader.glsl')
gress.setShader(shader)
...
...

I got:

ModelRoot /home/liu/code/panda/tut/4/gress.obj
  PandaNode 
    GeomNode points (1 geoms)
:display:gsg:glgsg(error): at 3388 of panda/src/glstuff/glGraphicsStateGuardian_src.cxx : invalid operation
[VGL] NOTICE: Pixel format of 2D X server does not match pixel format of
[VGL]    Pbuffer.  Disabling PBO readback.
:display:gsg:glgsg(error): at 3388 of panda/src/glstuff/glGraphicsStateGuardian_src.cxx : invalid operation
:display:gsg:glgsg(error): at 3388 of panda/src/glstuff/glGraphicsStateGuardian_src.cxx : invalid operation
:display:gsg:glgsg(error): at 3388 of panda/src/glstuff/glGraphicsStateGuardian_src.cxx : invalid operation
...
...

Seems that obj2egg is varies according to the Panda version.
With the dev version I also get empty vertex pool, but with another (don’t remember exactly, possible 1.8.1) - I get vertex pool with vertices

Could you perhaps get around the problem by triangulating your set of vertices and deleting the resultant NodePath when you’re done?

It seems like you’ll need to do what Thaumaturge suggested. When I try to load a model with vertices but no faces, Panda3d seems to ignore them and not create any geom nodes to store their positions in. You’ll probably need to make them a part of an actual model to ensure panda3d doesn’t optimise them away.

I update model:

and geomerty shader:

//GLSL

//gshader

#version 150

in VertexData {
	vec2 texCoord;
	vec3 normal;
} VertexIn[3];

out VertexData {
	vec2 texCoord;
	vec3 normal;
} VertexOut;

void main() {

	vec4 p00 = gl_in[0].gl_Position;
	if(p00.z > 0 && p00.z < 200) {
		if(p00.x/p00.z>-1.3 && p00.x/p00.z<1.3) {
			for(int i = 0; i < gl_in.length(); i++) {
				p00 = gl_in[i].gl_Position;
	  
				gl_Position =  (vec4(-1.6,0,0.0,0.0) + p00);  
				VertexOut.texCoord = vec2(0.02,0.52);
				EmitVertex();  
			  
				gl_Position =  (vec4(1.6,0,0.0,0.0) + p00); 
				VertexOut.texCoord = vec2(0.48,0.52); 
				EmitVertex();  

				gl_Position =  (vec4(-1.6,3.5,0.0,0.0) + p00); 
				VertexOut.texCoord = vec2(0.02,0.98); 
				EmitVertex();  
				gl_Position =  (vec4(1.6,3.5,0.0,0.0) + p00); 
				VertexOut.texCoord = vec2(0.48,0.98); 
				EmitVertex();
				EndPrimitive(); 
			}  
		}
	}
}

// 草坪的纹理来自 xsinick+Tristan.

May be it better performance.