5
$\begingroup$

I want to apply Lighting to some ListPlot3Ds with Texture applied, but it's not taking as it does with Plot3D. As an example,

p[x_, y_] := PDF[MultinormalDistribution[{25, 25}, {{25, -12.5}, {-12.5, 25}}], {x, y}];

(* too dark *)
Plot3D[p[x, y], {x, 0, 50}, {y, 0, 50}, PlotPoints -> 50, 
 PlotStyle -> Blend[{Blue, Red}, 0.5], ViewPoint -> {-1.8, -2.2, 1}, 
 AxesEdge -> {{-1, -1}, {-1, -1}, {-1, 1}}, PlotRange -> {0, All}, 
 MeshFunctions -> (Sqrt[#3] &), Mesh -> 50]

enter image description here

(* better with Lighting *)
Plot3D[p[x, y], {x, 0, 50}, {y, 0, 50}, PlotPoints -> 50, 
 PlotStyle -> Blend[{Blue, Red}, 0.5], ViewPoint -> {-1.8, -2.2, 1}, 
 AxesEdge -> {{-1, -1}, {-1, -1}, {-1, 1}}, PlotRange -> {0, All}, 
 MeshFunctions -> (Sqrt[#3] &), Mesh -> 50, Lighting -> "Neutral"]

enter image description here

Yet if I do the same on my Textured ListPlot3D, it doesn't work:

texture = 
  ListDensityPlot[Table[0.5, {y, 0, 50}, {x, 0, 50}], Mesh -> None, 
   InterpolationOrder -> 0, Frame -> False, PlotRangePadding -> None, 
   ImagePadding -> None, ColorFunction -> (Blend[{Blue, Red}, #] &), 
   ColorFunctionScaling -> False];

(* too dark *)
ListPlot3D[Table[p[x, y], {y, 0, 50}, {x, 0, 50}], 
 DataRange -> {{0, 50}, {0, 50}}, PlotStyle -> Texture[texture], 
 TextureCoordinateFunction -> ({#1, #2} &), 
 TextureCoordinateScaling -> True, PlotStyle -> cf[0.5], 
 ViewPoint -> {-1.8, -2.2, 1}, 
 AxesEdge -> {{-1, -1}, {-1, -1}, {-1, 1}}, PlotRange -> {0, All}, 
 MeshFunctions -> (Sqrt[#3] &), Mesh -> 50, Lighting -> "Neutral"]

enter image description here

I tried Glow as in this answer but it wasn't looking great.

Any way to mix Texture and Lighting?

$\endgroup$

2 Answers 2

7
$\begingroup$

Use Lighting -> "Neutral" as a styling directive in PlotStyle:

ListPlot3D[Table[p[x, y], {y, 0, 50}, {x, 0, 50}], 
 DataRange -> {{0, 50}, {0, 50}}, 
 PlotStyle -> Directive[Lighting -> "Neutral", Texture[texture]], 
 TextureCoordinateFunction -> ({#1, #2} &), 
 TextureCoordinateScaling -> True, ViewPoint -> {-1.8, -2.2, 1}, 
 AxesEdge -> {{-1, -1}, {-1, -1}, {-1, 1}}, PlotRange -> {0, All}, 
 MeshFunctions -> (Sqrt[#3] &), Mesh -> 50]

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ So simple (but still would have never found it) - thanks! $\endgroup$
    – Chris K
    May 21 at 19:00
4
$\begingroup$

EDIT

Using ListPlot3D:

So I modified the texture that was a purple sheet mostly.

texture = 
 ListDensityPlot[
  Table[0.5 Sin[0.25 x] Cos[0.25 y], {y, 0, 50}, {x, 0, 50}], 
  Mesh -> None, InterpolationOrder -> 0, Frame -> False, 
  PlotRangePadding -> None, ImagePadding -> None, 
  ColorFunction -> (Blend[{Blue, Red, White}, #] &), 
  ColorFunctionScaling -> True]

and applied it:

ListPlot3D[Table[p[x, y], {y, 0, 50}, {x, 0, 50}], 
 DataRange -> Automatic, PlotStyle -> Texture[texture], 
 TextureCoordinateFunction -> ({#1, #2} &), 
 TextureCoordinateScaling -> True, ViewPoint -> {-1.8, -2.2, 1}, 
 AxesEdge -> {{-1, -1}, {-1, -1}, {-1, 1}}
 , PlotRange -> {0, All}
 , MeshFunctions -> (#3 &)
 , Mesh -> 1
 , Lighting -> "Neutral"
 , ImageSize -> Medium
 ]

enter image description here


Original answer

Not exactly ListPlot3D but close:

ListSurfacePlot3D[
 Flatten[#, 1] &@Table[{x, y, p[x, y]}, {y, 0, 50}, {x, 0, 50}], 
 Mesh -> None, MaxPlotPoints -> 50, 
 TextureCoordinateFunction -> ({#1, #2} &), 
 TextureCoordinateScaling -> True,
 AxesEdge -> {{-1, -1}, {-1, -1}, {-1, 1}}, PlotRange -> {0, All}, 
 PlotStyle -> Texture[ExampleData[{"ColorTexture", "CheetahFur"}]]
 , BoxRatios -> {1, 1, 0.3}
 , ImageSize -> Large
 , Lighting -> "Neutral"
 ]

enter image description here

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