3
$\begingroup$

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}]
$\endgroup$
8
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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