Suppose I have the given Mathematica code,

Graphics3D[{Texture[ExampleData[{"ColorTexture", "GloriesPattern"}]], Sphere[{0, 0, 0}]}, Boxed -> False]

which gives me a nice coloured texture around the unit sphere as below:


But, when I try using this code:

Graphics3D[{Texture[ExampleData[{"Texture", "Grass"}]], Green, Sphere[{0, 0, 0}]}, Boxed -> False]

it gives me a black&white texture as below:


Is there a way with which I can even provide specific colors to such kind of example texture data?


3 Answers 3


The image you get from ExampleData[{"Texture", "Grass"}] is a grayscale image. The colors you see are due to the default "5-point" lighting. If you set Lighting -> "Neutral", you get:

Graphics3D[{Texture[ExampleData[{"Texture", "Grass"}]], 
  Sphere[{0, 0, 0}]}, Boxed -> False, Lighting -> "Neutral"]

enter image description here

If you want to convert this grayscale image to a colored one, you can use Colorize with whatever ColorFunction you want:

Graphics3D[{Texture[Colorize[ExampleData[{"Texture", "Grass"}], 
 ColorFunction -> "AvocadoColors"]], 
  Sphere[{0, 0, 0}]}, Boxed -> False, Lighting-> "Neutral"]

enter image description here

img = ExampleData[{"Texture", "Grass"}];
colors = DominantColors[img]
img = ColorReplace[img, Thread[colors -> {Green, Pink}]];
Graphics3D[{Texture[img], Green, Sphere[{0, 0, 0}]}, Boxed -> False]

enter image description here

  • $\begingroup$ Why are there some small white or light greyish patches in the output texture? $\endgroup$
    – codebpr
    Feb 20 at 14:35

You could also use AmbientLight as well.

  Texture[ExampleData[{"Texture", "Grass"}]], Green, 
  Sphere[{0, 0, 0}]}, Boxed -> False]

And from there choose what Lighting you like.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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