3

How can I get the point light to stop shining through the polygons? Faces that should be occluded by other faces are glowing green... :(

TestGrid = Table[0, {i, 5}, {j, 5}];
DrawCubby[color_, position_] :=
  {Polygon[{{position[[2]] - 1, 0, position[[1]] - 1}, {position[[2]],
       0, position[[1]] - 1}, {position[[2]], 0, 
      position[[1]]}, {position[[2]] - 1, 0, 
      position[[1]]}, {position[[2]] - 1, 0, position[[1]]}}],
   Polygon[{{position[[2]] - 1, 0, 
      position[[1]] - 1}, {position[[2]] - 1, 1, 
      position[[1]] - 1}, {position[[2]], 1, 
      position[[1]] - 1}, {position[[2]], 0, 
      position[[1]] - 1}, {position[[2]] - 1, 0, position[[1]] - 1}}],
   Polygon[{{position[[2]] - 1, 0, 
      position[[1]] - 1}, {position[[2]] - 1, 1, 
      position[[1]] - 1}, {position[[2]] - 1, 1, 
      position[[1]]}, {position[[2]] - 1, 0, 
      position[[1]]}, {position[[2]] - 1, 0, position[[1]] - 1}}],
   Polygon[{{position[[2]] - 1, 0, position[[1]]}, {position[[2]] - 1,
       1, position[[1]]}, {position[[2]], 1, 
      position[[1]]}, {position[[2]], 0, 
      position[[1]]}, {position[[2]] - 1, 0, position[[1]]}}],
   Polygon[{{position[[2]], 0, position[[1]] - 1}, {position[[2]], 1, 
      position[[1]] - 1}, {position[[2]], 1, 
      position[[1]]}, {position[[2]], 0, 
      position[[1]]}, {position[[2]], 0, position[[1]] - 1}}]
   };
Manipulate[
 Graphics3D[{Lighting -> {{"Point", Green, {a, b, c}, {0, 1, 0}}}, 
   MapIndexed[DrawCubby, TestGrid, {2}], PointSize[Large], Pink, 
   Point[{a, b, c}]}], {{a, .5}, 0, 2}, {{b, .5}, 0, 2}, {{c, .5}, 0, 
  2}]

1 Answers1

9

This was supposed to be a comment but I accidentally answered instead... I guess it's kind of an answer, albeit negative.

Objects in Mathematica don't cast shadows, it simply can't do ray tracing. To do it properly would take a lot of effort, see e.g. Is this the most effective and efficient programming style for prototyping (a ray tracer) in Mathematica? and a more limited question here: How to make a drop-shadow for a Graphics3D objects?

This link may actually be more useful: How to Render, raytrace, Export Graphics3D in Mathematica 11.0

Jens
  • 97,245
  • 7
  • 213
  • 499