Discussion:
[Opensg-users] Using per-instance Vertex Attributes
Marcel Weiler
2014-06-04 08:57:57 UTC
Permalink
Hi all,

for instanced rendering I want to give the instanced Geometry core an
attribute that represents a per-instance position offset. I know how to
set the usual indices and positions, but how do I add custom vertex
attributes?
I tried setting the property to binding location 1 using Snippet
geo->setProperty(offsets, 1) but this causes the following warning:
Snippet
WARNING: GeoVectorProperty::activate: Non-Generic attribute nr. 1 unknown!

and this approach does not work (the instances are not rendered with an
offset).

I also tried misusing the colors property, but even though I set its
divisor to 1 it seemed to be advancing per vertex, not per instance.

Am I even on the right track here? Or do I have to set some properties
in the GeoInstancer?

Kind regards,
Marcel


---
Diese E-Mail ist frei von Viren und Malware, denn der avast! Antivirus Schutz ist aktiv.
http://www.avast.com
Gerrit Voß
2014-06-04 10:27:04 UTC
Permalink
Hi,
Post by Marcel Weiler
Hi all,
for instanced rendering I want to give the instanced Geometry core an
attribute that represents a per-instance position offset. I know how to
set the usual indices and positions, but how do I add custom vertex
attributes?
I tried setting the property to binding location 1 using Snippet
Snippet
WARNING: GeoVectorProperty::activate: Non-Generic attribute nr. 1 unknown!
and this approach does not work (the instances are not rendered with an
offset).
I also tried misusing the colors property, but even though I set its
divisor to 1 it seemed to be advancing per vertex, not per instance.
Am I even on the right track here?
yes, this should work.
Post by Marcel Weiler
Or do I have to set some properties in the GeoInstancer?
no, just the base geometry and the number of instances.
e.g. from the CSM example

core GeoInstancer
{
numInstances 4
baseGeometry USE BaseGeometry
}


first quick one (and sorry if you have), have you looked at/tried
Examples/CSM/Instancing/SimpleDivisor ?

If yes, there is something weird going on with the example. Using
vec4 vVertex = gl_Vertex + vec4(
gl_MultiTexCoord7);
results in wrongly scaled/projected instances. This can be fixed by
changing the vertex position computation to
vec4 vVertex = gl_Vertex + vec4(
gl_MultiTexCoord7.xwz, 0.);

The example uses attribut 15, but I quickly tried 1 and 3 and it works
as expected.

If you can, could also send me a .osg dump of the subgraph containing
the instancing (off-list is fine) and I can have a further look.

kind regards
gerrit

Loading...