0 like 0 dislike
In the documentation, there's an image demonstrating the PlanarAligned Quads, showing particles orienting their normals to be those of the shape sampler. How is that done?

I've got the two custom axis fields defined in my spawner script, but the I'm not pulling the sampleNormal correctly, I guess.

Apologies for the greenhorn questions; the learning curve's steep for non-technical folks... To that end, would it be possible to annotate future feature documentation with popcorn files a user could deconstruct?

Thanks in advance!
by SevenCubed (200 points)

1 Answer

0 like 0 dislike

Hi !

So, quite a bit of lag to get an answer, sorry about that...

You mean that image here: https://wiki.popcornfx.com/index.php/CParticleRenderer_Billboard#PlanarAlignedQuad ?

so let's say you've setup two float3 particle fields "AxisSide" and "AxisNormal", which you're feeding to the planar-aligned billboard renderer.

In your spawn script, if you do this:

Position = MyShape.samplePosition();
AxisNormal = MyShape.sampleNormal();
AxisSide = cross(AxisNormal, scene.axisUp());

it won't work, because each call to "MyShape.sampleSomething()" without any additional parameter just picks a new random sample on the shape, without any way of knowing where you want that sample to be taken.

The usual way to tie together multiple sample calls is to use what we call parametric coordinates.

These are an opaque 'int3' vector, containing a bunch of stuff packed in 96 bits (whatever)

This represents a unique location on the shape, which you can then pass down to each sampling function to retreive the shape properties at that location. For example:

int3 pCoords = MyShape.samplePCoords(); // NOTE: If you're below v1.13, it's "sampleParametricCoords()"
Position = MyShape.samplePosition(pCoords);
AxisNormal = MyShape.sampleNormal(pCoords);
AxisSide = cross(AxisNormal, scene.axisUp());


int3 pCoords = MyShape.samplePCoords();
Position = MyShape.samplePosition(pCoords);
AxisNormal = MyShape.sampleNormal(pCoords);
AxisSide = MyShape.sampleTangent(pCoords).xyz; // only available if your shape is a mesh

Hope this helps !

PS: Yes bundling the effect files with the tutorials would definitely be a good thing ! we've started doing that for PopcornFX v2.0 (beta coming soon !)

by Julien (32.6k points)
Thank you VERY much! I had seen some entry about Pcoords but my attempts missed that tricky little cross product! Feels so good when things finally "click".

I appreciate the support! Looking forward to making all kinds of great stuff. =D