7
$\begingroup$

Mathematica is able to manage two kinds of reflections :

  • With a simple color directive (Blue, RBGColor[...]...), one can specify the diffuse reflection.

  • With the directive Specularity[Yellow,...], one can specify the specular reflection.

    That gives nice effects :

enter image description here

(Note that the light source is White.)

Here is the code :

region00=DiscretizeRegion[
Polygon[{{-1,-1,0},{1,-1,0},{1,1,0},{-1,1,0}}],
MaxCellMeasure->0.0003,
MeshCellStyle->{1-> Black, 2-> Directive[Specularity[Yellow,100],Blue]}];

lightSourcePosition={0,0.8,0.2};
lightSource=DiscretizeRegion[Ball[lightSourcePosition,0.02],  
  MaxCellMeasure->0.2,MeshCellStyle->{1-> Gray, 2-> Gray,3-> Gray}];

Show[region00,
lightSource,
(*Graphics3D[{Red,Sphere[lightSourcePosition,0.02]}],*)  
Axes-> True,AxesLabel->{"X","Y","Z"},Lighting-> 
{{"Point",White,lightSourcePosition}},ImageSize-> 800,  
ViewCenter->{0.5`,0.5`,0.5`},ViewPoint->{0.027,-3.14,1.2},  
ViewVertical->{-0.017,-0.49,14.5}]

enter image description here

But when I set MaxCellMeasure->0.0002, colors are lost :

enter image description here

Sometime only the specular reflection color is lost.

Any workaround ?

$\endgroup$
  • $\begingroup$ maybe a candidate for the tag "Bug" $\endgroup$ – andre314 Oct 7 '17 at 20:09
  • $\begingroup$ I don't thinks so. It is meaningfull to keep perfomance for complicated MeshRegions. For graphical purposes, the classical GraphicsComplex should be prefered. $\endgroup$ – Henrik Schumacher Oct 7 '17 at 20:12
  • $\begingroup$ @HenrikSchumacher I use Region because I want to use the new fonctionnality RegionUnion on 3D meshRegion. It's new to Mathematica 11.2 $\endgroup$ – andre314 Oct 7 '17 at 20:26
  • $\begingroup$ That's fine. Still, you can convert your MeshRegion to a GraphicsComplex with Graphics3D[GraphicsComplex[MeshCoordinates[region00],MeshCells[region00, 2]]] and use classical graphics directives on that. $\endgroup$ – Henrik Schumacher Oct 8 '17 at 11:15
11
$\begingroup$

I think that the option PlotTheme for large MeshRegions is automatically set to "LargeMesh" for performance reasons. Try the following:

region00 = 
 DiscretizeRegion[
  Polygon[{{-1, -1, 0}, {1, -1, 0}, {1, 1, 0}, {-1, 1, 0}}], 
  MaxCellMeasure -> 0.000003, 
  MeshCellStyle -> {1 -> Black, 2 -> Directive[Specularity[Yellow, 100], Blue]},
  PlotTheme -> "SmoothShading"]  

enter image description here

$\endgroup$
6
$\begingroup$

One can also set the system option for "LargeMeshThreshold" to be greater than the number of mesh cells (default threshold is 1000):

SetSystemOptions["RegionOptions" -> {"LargeMeshThreshold" -> 2000}];
Show[region00, lightSource, Axes -> True, 
 AxesLabel -> {"X", "Y", "Z"}, 
 Lighting -> {{"Point", White, lightSourcePosition}}, 
 ImageSize -> 600, ViewCenter -> {0.5`, 0.5`, 0.5`}, 
 ViewPoint -> {0.027, -3.14, 1.2}, 
 ViewVertical -> {-0.017, -0.49, 14.5}]

Mathematica graphics

$\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.