Discussion:
[Opensg-users] single point geometry not visible
Victor Haefner
2014-11-10 14:52:02 UTC
Permalink
Hi,

I have a case where I want to display a single point geometry, but it just
doesn't show it.
The stats foreground shows that the point is there:

Drawables: (drawn)
points: 1
verts: 1

I worked around it by drawing two points at the same position, not a big
deal..
I just wanted to report it, anyone ever encountered this?

Best regards,
Victor
Carsten Neumann
2014-11-10 15:38:07 UTC
Permalink
Hello Victor,
Post by Victor Haefner
I have a case where I want to display a single point geometry, but it
just doesn't show it.
Drawables: (drawn)
points: 1
verts: 1
interesting, my first guess would have been frustum culling believing
that the geometry has an empty bounding volume and throwing it away, but
since it shows up as 'drawn' in the stats, that seems unlikely...
Post by Victor Haefner
I worked around it by drawing two points at the same position, not a big
deal..
... especially with this workaround. What vertex attributes does the
geometry have (if anything besides positions) and are you using indices?
Post by Victor Haefner
I just wanted to report it, anyone ever encountered this?
Would you happen to have a trace of GL calls issued (e.g. apitrace or
gDEBugger)? Thanks!

Cheers,
Carsten


------------------------------------------------------------------------------
Victor Haefner
2014-11-10 22:41:18 UTC
Permalink
Hi Carsten,
Post by Carsten Neumann
... especially with this workaround. What vertex attributes does the
geometry have (if anything besides positions) and are you using indices?
I use:
GeoPnt3fPropertyRecPtr Pos = GeoPnt3fProperty::create();
GeoVec3fPropertyRecPtr Norms = GeoVec3fProperty::create();
GeoUInt32PropertyRecPtr Indices = GeoUInt32Property::create();
GeoVec3fPropertyRecPtr cols = GeoVec3fProperty::create();
GeoUInt8PropertyRecPtr Type = GeoUInt8Property::create();
GeoUInt32PropertyRecPtr Length = GeoUInt32Property::create();

one position, normal and color, GL_POINTS and one index '0', and one length
'1'.
Post by Carsten Neumann
Would you happen to have a trace of GL calls issued (e.g. apitrace or
gDEBugger)? Thanks!
First try at apitracer, looks very good! :)

Best regards,
Victor
Carsten Neumann
2014-11-11 09:47:31 UTC
Permalink
Hello Victor,
Post by Victor Haefner
Hi Carsten,
Post by Carsten Neumann
... especially with this workaround. What vertex attributes does the
geometry have (if anything besides positions) and are you using indices?
GeoPnt3fPropertyRecPtr Pos = GeoPnt3fProperty::create();
GeoVec3fPropertyRecPtr Norms = GeoVec3fProperty::create();
GeoUInt32PropertyRecPtr Indices = GeoUInt32Property::create();
GeoVec3fPropertyRecPtr cols = GeoVec3fProperty::create();
GeoUInt8PropertyRecPtr Type = GeoUInt8Property::create();
GeoUInt32PropertyRecPtr Length = GeoUInt32Property::create();
one position, normal and color, GL_POINTS and one index '0', and one
length '1'.
Post by Carsten Neumann
Would you happen to have a trace of GL calls issued (e.g. apitrace or
gDEBugger)? Thanks!
thanks for sending the info, it confirms that the draw call is actually
issued and I suspect that this is a similar problem to the one you are
having with gl_Color.
Could you perhaps try creating your vertex shader with
ShaderProgram::createVertexShader(true) [1] and instead of using the
built-in vertex attributes in the GLSL code use:

gl_Vertex -> osg_Vertex
gl_Normal -> osg_Normal
gl_Color -> osg_Color

Since these are then generic vertex attributes they also need to be
declared at the top of the shader, i.e. you'd need a block like:

attribute vec4 osg_Vertex;
attribute vec4 osg_Normal;
attribute vec4 osg_Color;

Cheers,
Carsten

[1] alternatively you can call createDefaulAttribMapping() on your
vertex shader - that function also has the full list of names if you
need more than the three attributes above.
Carsten Neumann
2014-11-12 12:25:56 UTC
Permalink
Post by Carsten Neumann
Post by Carsten Neumann
Would you happen to have a trace of GL calls issued (e.g. apitrace or
gDEBugger)? Thanks!
thanks for sending the info, it confirms that the draw call is actually
issued and I suspect that this is a similar problem to the one you are
having with gl_Color.
hmm, digging some more it turns out the difference between having a
geometry where all properties contain just a single value vs. properties
with multiple values is that in the former case:

glVertexAttribN{f,d,i,ui}v family of functions is used to pass the
vertex data and in the latter case buffer objects are filled with the
data and glVertexAttribPointer is used to make the GL take vertex data
out of those buffers.

Also interesting is that it is sufficient to add a second position to
the positions property and leave everything else as is (including the
index) - that puts the positions into a buffer and seems to make
everything work. The other properties arrive at the shader even though
they are set with glVertexAttrib*. This is on linux x86_64 with nvidia
331.89.
I'm not sure if the spec makes position special in this regard, or if
OpenSG is missing a setting here, or if this is a driver bug?

Cheers,
Carsten
Victor Haefner
2014-11-17 21:09:48 UTC
Permalink
Hi Carsten,


Could you perhaps try creating your vertex shader with
Post by Carsten Neumann
ShaderProgram::createVertexShader(true) [1] and instead of using the
gl_Vertex -> osg_Vertex
gl_Normal -> osg_Normal
gl_Color -> osg_Color
this works like a charm for my color and normal issues on my ATI (see other
thread
https://www.mail-archive.com/opensg-***@lists.sourceforge.net/msg15200.html
)
..but previous versions of OSG 2 worked also with the default build ins..
Using the osg attributes is fine for me, but I cannot expect others who use
my tool to not use the old build ins, except maybe display a warning.
When I have more time I will search for the version where it stopped
working.

..regarding the single point issue, I don't think it is driver related, I
have the same problem on ATI and NVIDIA (both ubuntu 14.04).


thanks and best regards,
Victor

Loading...