Sops And Ndc?

Recommended Posts

Hi guys,

How to calculate an intersection of some vector in the point (SOP context) with the NDC plane (or with the plane which can represent the NDC)? Say I have some piece of geometry and some vectors on the points, for example normals. I want to continue that normals to intersection with NDC. I know there is no NDC in the SOP context but it is possible to create the plane which can represent it in some way. Any suggestions?

Share on other sites

Hi, hoknamahn

You can use toNDC() in OP context. Something like,

Pndc = toNDC(camera, P);
Nndc = toNDC(camera, P+N) - toNDC(camera, P);

Though I'm not sure if there is VOP node, you can use InlineVOP.

Cheers,

Sho

Share on other sites
Hi, hoknamahn

You can use toNDC() in OP context. Something like,

Pndc = toNDC(camera, P);
Nndc = toNDC(camera, P+N) - toNDC(camera, P);

Though I'm not sure if there is VOP node, you can use InlineVOP.

Cheers,

Sho

Is it well defined? Because I see in the help:

Transforms a position into normal device coordinates. This space is only well-defined for the Displacement, Surface, and Light contexts.

Share on other sites

Well, I don't know what does "well defined" mean...

But, when I used it long time ago to generate some attributes for sprite, it worked fine for me.

Just one thing I remember is the "P" needs to be object space even if the object is transformed.

I might be completely wrong though...

Share on other sites
Well, I don't know what does "well defined" mean...

But, when I used it long time ago to generate some attributes for sprite, it worked fine for me.

Just one thing I remember is the "P" needs to be object space even if the object is transformed.

I might be completely wrong though...

Okay I will check it. Thanks Sho.

Share on other sites
Okay I will check it. Thanks Sho.

Hi there,

Share on other sites
Hi there,

Oh, Jason, great data, thanks for the link.

I know it has been there for long, but first like >50% of it was too sophisticated and tech for a newbe, now I can re-explore some of the key-concepts. Thanks for this kicker.

Share on other sites

Sho is correct in that you have to be sure that global P is in world space when using the default toNDC() in the SOP context.

Reworked vel_blur slightly so that it will compile in H8.1:

void
toNDC(vector p; float zoom)
{
float z;
z = zoom / p.z;
p *= set(z, z, 1);
p += {0.5, 0.5, 0};
}

sop
vel_blur(matrix camera=1; float focal=50, aperture=42)
{
float zoom;
vector p0, p1;
vector screenV;

zoom = focal/aperture;
p0 = P;
p1 = P + v;
p0 *= camera;
p1 *= camera;
toNDC(p0, zoom);
toNDC(p1, zoom);

}

Share on other sites

Oh, good, old school, thanks. Sexy stuff.