简体   繁体   English

mathematica Graphics3D中的阴影

[英]Shadows in mathematica Graphics3D

If I understood the Mathematica documentation correct ( haven't found examples either ) Graphics3D does not produce shadows of 3D objects, although Graphics3D has a Lighting-> option. 如果我理解Mathematica文档是正确的(也没有找到示例)Graphics3D不会产生3D对象的阴影,尽管Graphics3D有一个Lighting->选项。

Question: Have you ever tried to produce Mathematica 3D objects with shadows ? 问题:您是否曾尝试使用阴影生成Mathematica 3D对象? If so have you solved this in Mathematica? 如果是这样,你在Mathematica中解决了这个问题? Or have you exported the graphics to other 3D ( scene-graph ) viewers like for example J-Reality? 或者您是否已将图形导出到其他3D(场景图)查看器,例如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. MMA使用的阴影模型,即所谓的Phong阴影 ,基于局部表面取向,光源方向,相机方向和表面的漫反射和镜面反射特性之间的简单关系来确定像素强度。 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]

在此输入图像描述

Of course, you need to make sure that the lighting sources (point, spot, directional...) and your shadow projection are consistent. 当然,您需要确保光源(点,点,方向......)和阴影投影是一致的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM