8

I'm having a bit of an issue getting started with UV mapping in Cycles. It works fine initially, but when I add the mapping node and set min/max to the default values to turn off repeating, I get the following stretch.

This is a bit boggling to me as I followed multiple tutorials where this exact same process works. See here

Images of the issue: http://imgur.com/a/0Ezqd

enter image description here

enter image description here

gandalf3
  • 157,169
  • 58
  • 601
  • 1,133
SirJay
  • 81
  • 2
  • @Aldrik Interesting. I tried out the node maps on that other question and while neither worked the question mentioned something about making the image texture larger than needed. So I increased the image canvas by 1px on all sides and the stretch went away. I assume it's now stretching the transparent pixel but it's not visible. – SirJay Aug 28 '13 at 15:49

2 Answers2

5

As mentioned by Róbert László Páli, this is an artifact of the way the mapping node works.

You can get around this using hjaarnio's technique:

Using this node setup that creates a map of where the image is:

Example image

Values in the 0-1 range are where the original image is, so if we use that as a mix factor:

enter image description here

It will use the Image texture only where the original image is mapped, and Base Color everywhere else.

Base Color can be a texture or even another shader as well:

enter image description here

gandalf3
  • 157,169
  • 58
  • 601
  • 1,133
3

Enabling the min and max values for the mapping does the following:

When the coordinate for the UV is above the one
(when a certain point is above the image on
the UV) then it changes that value to one.

So the sampler will sample a pixel from the coordinate one, which is the topmost pixel of the image (and also the zero value is sampled from there). So for every point that is UV-mapped above or below the image, the color will be from the top row of the image. The same applies to the other direction.

A dummy solution would be to add one pixel transparent black border to the image to achieve a decal on the mug. But you have to use the alpha channel to mix the image with the original color.