I’ve been looking into recreating a Copy to Points style setup from Houdini where I loop over each point and check it’s attributes going in (on the copy and template geo) for a class or piece attribute that informs which geometry is selected to copy to that template point.
i.e. in the copy input, there would be two merged streams of meshes, each with a piece attribute, the first would be labelled as Apple, the second stream as Orange.
In the template geometry, say a line with 2 points, point 0 has the attribute ‘Apple’ and point 1 has the attribute 'Orange’.
The result of this being that points with that attribute then only apply copies with matching attributes.
I’ve had a look at the example files but couldn’t see a specific setup that addresses this. I’m also not very au fait with GLSL, however come from a vex side in Houdini and am trying to port some of my knowledge over. I wanted to get a bit of a sense check that this is even possible before I invest too much time in it.
not sure how optimal this is and others (@vincentDev@Guillaume.L) will probably have more answers, but you could check in the shader for the attribute and just move points out of the way if an attribute is not matched:
void main() {
const uint id = TDIndex();
if(id >= TDNumPoints())
return;
float count = mod(TDCopyIndex(),2);
if (TDIn_geoId(TDInputPointIndex()).r == count){
P[id] = TDIn_P(TDInputPointIndex()) + TDTemplate_P(TDCopyIndex());
}else{
P[id] = vec3(1000,0,0);
}
//updates existing point groups if any
TDUpdatePointGroups();
}
Here i give both geometries an attribute geoId (0 or 1) and check via a modulo on the copy index which one to place. The point positions of the other geometry are all placed in a known spot (vec3(1000,0,0)) and then deleted using a Delete POP.
So this could be one way, another way might be to just select out the points on the copy input first and have multiple GLSL Copy POPs to deal with every geometry separately.
As Markus says, the GLSL Copy POP was more intended for custom deformation per copy than different geo per copy.
We have logged internally the request for different geo per copy for the Copy POP since there has been some interest.
In the mean time using multiple Copy POPs, each one with the correct set of template points, is most likely the most efficient - it could probably be automated with a replicator.
With the setup Markus shared, the double amount of memory needed is allocated for each copy. It might be possible to make it more efficient memory wise by putting the denser geo in the copy input and using the Buffer page to sample other geos, at the cost of extra complication, though I haven’t tried it.
Hi Markus and Vincent, thanks both for the speedy reply! I’ve just given this a go and have got some promising results. I’ve shared the .toe file too.
I made some edits to it so that a noise is the driver of the geoId, which works well. I’ve also added a part that changes the colors via the input points.
One step closer to achieving some more Houdini style setups
Another Q I have (@snaut , @vincentDev ) is in regard to being able to offset the input copy geo’s parameters, again in Houd, I’d apply an attribute that represents an attribute/frame offset on the template side and feed that into something on the copy side, like the strength of a twist parameter say.
From looking at TD GLSL examples, this is something where I’d need to ‘bake’ the animation or deformation of the copy geo and then read through a sample of a TOP that contains this data - is this roughly correct or is there a way of doing this more similar to the copy SOP template method?
This is supported in SOPs but since it would be quite inefficient in POPs (the whole OP chain has to be recooked for each copy) it is not something we’re planning on adding soon - maybe in the future as a convenience.
As you say the most generic way would be to bake the variations prior to the copy and do some lookups (or custom deformation like a twist) in the GLSL Copy POP.
As an alternative a few POPs allow to map attributes to parameters - for example the noise POP or the transform POP, so that would work after the copy POP, if each copy as a different set of attributes. If there are specific POPs you would like to see this functionality added to we’ll take that into consideration.
Ah yes copy stamping - I realise that’s also what it was called in Houd before the methodology switched to for each loops.
I did wonder if it was something that wouldn’t efficiently port directly SOPS to POPS. I could imagine it being something that could be useful for cases where only a small amount of copies are required though, perhaps in making mograph-style effects over a few objects.
I’ll take a look at the attribute mapping to parameters in the Transform and Noise like you say. Right off the bat, the Twist POP could be one that may benefit from this functionality.