Jump to content

Sops And Ndc?


hoknamahn

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?

Link to comment
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

Link to comment
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.

Link to comment
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... :)

Link to comment
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. :)

Link to comment
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);

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...