2
$\begingroup$

I tried using Window Texture coordinate, but it changes scale if I zoom in or out. The Camera Texture coordinate works in with orthographic camera but gets distorted if I use perspective camera.

I want the texture to have a fixed scale and not be distorted like on orthographic mode.The left one is orthographic and the right is perspective using camera texture coordinate

$\endgroup$
  • $\begingroup$ What version and render engine? $\endgroup$ – Jackdaw Feb 9 '19 at 12:26
  • $\begingroup$ 2.8 cycles, its the same in 2.7 cycles. $\endgroup$ – Rc12 Feb 9 '19 at 12:36
  • $\begingroup$ @Rc12 I have added a new answer, which may fit your requirements even better. Please take a look at it. [Sorry for beeing a year too late.] $\endgroup$ – Leander May 1 at 16:57
0
$\begingroup$

You can use the Window mapped Texture Coordinates. But you need to scale the X axis to get 1:1 ratio on your texture. The UV coordinates are 0-1 in screen space.

Window UV

enter image description here

Or if you need to scale the texture depending on the distance from the camera. This is a bit simplified material that have an arbitrary power node to adjust the otherwise hard to achieve FoV calculations.

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ If you zoom in or out using window coordinate the texture changes in scale. I want the texture to be projected from the camera and have constant scale. If you use camera coordinate in orthographic mode it acts like window but doesnt change scale. $\endgroup$ – Rc12 Feb 9 '19 at 12:48
  • $\begingroup$ @Rc12 Changes scale? Can you elaborate? The texture is fixed to the window - it does not change scale. $\endgroup$ – Jaroslav Jerryno Novotny Feb 9 '19 at 12:54
  • $\begingroup$ The texture IS constant but is bound to the window size. Do you need it to be scaled with the object distance or the pixel distance? $\endgroup$ – Jackdaw Feb 9 '19 at 12:55
  • $\begingroup$ I want the texture to be fixed on the object. So If I zoom out, the texture on the object is same as when I am zoomed in. When using window I have more lines when zoomed in but less when zoomed out. I want it be be scaled with object distance. $\endgroup$ – Rc12 Feb 9 '19 at 13:01
  • $\begingroup$ Then you will need to scale the texture based on the object distance and the camera Field of Vision. It will be a complex setup that not only is a material since the camera position and FoV is not available in the material nodes (yet?) $\endgroup$ – Jackdaw Feb 9 '19 at 13:13
2
$\begingroup$

Use the UV Project modifier:

enter image description here

Then in nodes you use UV mapping. This setup is independent of render resolution ratio.

| improve this answer | |
$\endgroup$
2
$\begingroup$

Use the Texture Coordinates of your Camera

camera coordinates node setup

Add a texture coordinate node and choose the camera output. If all coordinates had the same depth values, then the texture won't be distorted. You can simply reduce the length of the coordinates so that their z value equals 1 by dividing the coordinate by their z value.

Use a Vector Math node for the division and you have scale and ratio invariant view coordinates.


You will notice, that the texture still changes when altering its scale. This is because the Z coordinate is 1 and it's beeing scaled. If you don't want that, then multiply the Z coordinate with 0 with a vector math multiplication node (set X and Y to 1 though, because we don't want to change them).

vectormath mutliplication


The setups above will still zoom in and zoom out. They don't change when the camera is moved, but change when the cameras focal length decrease or increases.

However, since we have the relation of the camera coordinates and the window coordinates we can counteract this by multiplying the coordinates with the quotion of a single dimension of window / camera.

The following node setup will produce axis-equal window coordinates independently of camera position, rotation, or focal length.

scale and angle invariant

It works perfectly in cycles, but causes some artifacts in EEVEE in the center due to zero division.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.