开发者

Shadows in mathematica Graphics3D

开发者 https://www.devze.com 2023-03-26 07:30 出处:网络
If I understood the Mathematica documentation correct ( haven\'t found examples either ) Graphics3D does not produce shadows of 3D objects, alt开发者_C百科hough Graphics3D has a Lighting-> option.

If I understood the Mathematica documentation correct ( haven't found examples either ) Graphics3D does not produce shadows of 3D objects, alt开发者_C百科hough Graphics3D has a Lighting-> option.

Question: Have you ever tried to produce Mathematica 3D objects with shadows? If so have you solved this in Mathematica? Or have you exported the graphics to other 3D ( scene-graph ) viewers like for example J-Reality?


The shading model used by MMA, the so-called Phong shading, determines the pixel intensities based on a simple relationship between local surface orientation, light source direction(s), camera direction and diffuse and specular properties of the surface. No other aspect of the geometry is taken into account, which means that objects do not influence the pixel values of other objects even if they are between the object and the light source.

This means that the model doesn't generates shadows. It is not able to.

You could simulate shadows yourself by projecting your object's polygons on the ground plane or wall planes as applicable. That shouldn't be too difficult, but shadows on non-planar surfaces will be pretty hard.

Example:

polys = (PolyhedronData["GreatRhombicTriacontahedron", "Faces"] // 
      Normal // N) /. {x_, y_, z_}?VectorQ -> {x, y, z + 6}; 
     (* raise it slightly above ground plane*)

shadow = polys /. {x_, y_, z_}?VectorQ -> {x - z, y, 0};
         (* projection from a directional light source at 45 deg elevation *)

Graphics3D[{polys, EdgeForm[], FaceForm[Darker@Gray], shadow}, 
 Lighting -> {{"Directional", White, {{1, 0, 1}, {0, 0, 0}}}}, 
 Boxed -> False]

Shadows in mathematica Graphics3D

Of course, you need to make sure that the lighting sources (point, spot, directional...) and your shadow projection are consistent.

0

精彩评论

暂无评论...
验证码 换一张
取 消