Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I made two Polygons with different colors. Their names are p1 and p2.

p1Color = Red;
p2Color = Green;
w = 30;
h = 40;
l = 50;
p1 = Graphics3D[{p1Color, 
Polygon[{{0, 0, 0}, {0, h, 0}, {w, h, 0}, {w, 0, 0}}, 
  VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}, 
  Boxed -> False,
  Lighting -> {{"Ambient", p1Color}}, 
  RotationAction -> "Clip"];
p2 = Graphics3D[{p2Color, 
Polygon[{{0, 0, l}, {0, h, l}, {w, h, l}, {w, 0, l}}, 
  VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}, 
  Boxed -> False,
  Lighting -> {{"Ambient", p2Color}}, 
  RotationAction -> "Clip"];
{p1, p2, Show[{p1, p2}]}

The output is a list of three elements, p1, p2, and the output of Show[{p1,p2}]. The third element instead of lighting p1 an p2 with their indivdual colors mixes p2's colors with p1's colors.

Any particular reason why is this is so? How do I overcome the mixing here? How can I specify the exact colors in the output of Show?

share|improve this question
    
Keep track of your Lighting option, AbsoluteOptions[Show[{p1, p2}], Lighting] –  ssch Feb 18 '13 at 13:24
1  
You can use Show[p1,p2,Lighting->"Neutral"]. (If you don't specify an explicit Lighting option inside Show, Show takes the Lighting option value from p1.) –  kguler Feb 18 '13 at 13:24
add comment

1 Answer

You have to look at the lighting of your separate polygons. You light your first polygon with red light, while your green polygon is lit with green light.

Like kguler said, Show[] takes its options from the first argument, so your complete scene has a red lighting.

In:= AbsoluteOptions[Show[{p1, p2}], Lighting]
Out:= {Lighting -> {{"Ambient", RGBColor[1., 0., 0.]}}}

And a green polygon can't reflect red light, so it appears black (at least in my case with Mathematica 9 on Linux).

You can solve this issue by leaving out the option Lighting in your pictures p1 and p2, using the option

Lighting -> {{"Ambient", White}}

or by using kgulers solution:

Show[p1,p2,Lighting->"Neutral"]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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