0
$\begingroup$

I'm interested in using VertexTextureCoordinates in a GraphicsComplex but the behavior is unexpected so I'm looking for suggestions or clarification if this is a bug.

Consider a simple example: a 1D texture mapping [0, 1] -> {red, blue}, and a mesh with VertexTextureCoordinates in the range [0, 1].

Graphics[{
  Texture[{{1, 0, 0}, {0, 0, 1}}],
  Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, 
  VertexTextureCoordinates -> {{0}, {0}, {1}, {1}}]
}] 

What I expect is a rectangle whose color varies linearly from red to blue. Instead, what I get is:

enter image description here

The documentation for VertexTextureCoordinates reads:

For a 1D texture, coordinates correspond to:

{0}: the first element of the texture

{1}: the last element of the texture

But here, the image output above seems to be purple at the specified vertices (corresponding to vertex coordinate = 0.5, rather than 0 or 1).

This is on Mathematica 14.0 on an arm64 Mac.

$\endgroup$
1
  • $\begingroup$ I'm assuming here that textures wrap at the edges (which explains why some of the examples in the documentation work the way they do). So, you're seeing the interpolation between your two colors at the edges. For your specific case, the VertexColors option might be more appropriate. Or you could also just use LinearGradientImage. $\endgroup$ Commented May 18 at 19:54

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.