Jump to content

resolution independent tex projections?


mrice

Recommended Posts

I'm trying to set something up where I can project textures via cameras or lights that arent tied to the render cam's resolution.

The projections work fine when I render from the projecting camera or light but break when rendered from another cam.

The issue I *think* I'm having is that when I render from the main camera, the NDC coordinates used in the shader (either a light shader or surface shader) are now relative to the rendering camera and not the projector.

Is there a straightforward way to do this?

If you can't understand what I'm talking about I can upload a scene.

MIchael

Link to comment
Share on other sites

I managed to get it working :blink:

Yup. You got it. Well done!

I don't know what they intended with that "space:lightndc" choice in the TransformVOP's space menu, but it certainly doesn't transform to the light's NDC space (in fact, it's not documented that I'm aware of, so it's probably bogus). End result is that you have to either do what you did:

vector Pndc = toNDC(transform("space:light",Ps));

or, using the old transform functions:

vector Pndc = toNDC(wo_space(Ps));

Actually, I'm not sure if the "space:light" space is documented either...

Also, I should mention that now that we have the teximport() function to extract resolution information from a texture map, you can now fit the map into the projection frustum such that it doesn't distort. So for example:

A rectangular projection with a square map, when treated with the old vanilla NDC method, will distort:

post-148-1232751548_thumb.jpg

But now you can relate the light's projection rectangle with that of the texture map, allowing you to fit the map into the projection without distortion:

1. Scaled to fit (blue is just to show the original footprint):

post-148-1232751563_thumb.jpg

2. Fit horizontally:

post-148-1232751574_thumb.jpg

and so on...

Here's a quick demo of how that can be done:

ProjLight.tar.gz

Cheers!

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...