6
$\begingroup$

I am trying to get a 3D disk with gradient lighting that is darker at the center and gradually goes white at the edges. I managed to get the correct lighting but could not make it a circular shape instead of a rectangle.

Graphics3D[{EdgeForm[], Opacity[0.6], 
  Texture[RadialGradientImage[{Red, White}]], 
  Polygon[{{-6.2, -6.2, 1.1}, {6.2, -6.2, 1.1}, {6.2, 6.2, 
     1.1}, {-6.2, 6.2, 1.1}}, 
   VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}, 
 Lighting -> {"Spot", White}, Boxed -> False]     

enter image description here

$\endgroup$

3 Answers 3

6
$\begingroup$
Clear["Global`*"];
cf[x_] := Blend[{Red, White}, x];
RegionPlot3D[x^2 + y^2 <= 1 && -0.02 < z < 0.02
 , {x, -1, 1}, {y, -1, 1}, {z, -1, 1}
 , Mesh -> {0, 0, 1}
 , MeshStyle -> Directive @@ {Thick, Lighter@Pink}
 , ColorFunction -> Function[{x, y, z}, cf[(x^2 + y^2)^(1/5)]]
 , ColorFunctionScaling -> False
 , MaxRecursion -> 4
 , PlotPoints -> 80
 , Lighting -> {"Spot", White}
 , Boxed -> False
 , Axes -> False
 , SphericalRegion -> True
 , PlotRangePadding -> Scaled[.1]
 ]

enter image description here


Notes

  1. Actual on-screen resolution is better than shown in the gif file above.

  2. The ring at the boundary can be removed by commenting out the Mesh commands.

  3. More PlotPoints are required to display thinner disks properly.

$\endgroup$
2
  • $\begingroup$ How to record the animation of turning the plot object to gif?@Syed $\endgroup$
    – metroidman
    Jan 28 at 5:58
  • $\begingroup$ I use ScreenToGif. @metroidman $\endgroup$
    – Syed
    Jan 28 at 6:08
7
$\begingroup$
ParametricPlot3D[
 {u Sin[Pi/2] Cos[v], u Sin[Pi/2] Sin[v], u Cos[Pi/2]}, {u, 0, 1}, {v, 0, 2 Pi},
 Axes -> False,
 Boxed -> False,
 Lighting -> AmbientLight[White],
 Mesh -> None,
 PlotPoints -> 60,
 PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}},
 TextureCoordinateFunction -> ({#1, #2} &),
 PlotStyle -> Texture[RadialGradientImage[{Red, White}]]]

enter image description here

$\endgroup$
5
$\begingroup$
SliceDensityPlot3D[
 Norm[{x, y, z}], {"ZStackedPlanes", 1}, {x, y, z} ∈ Ball[], 
 ColorFunction -> (Blend[{Red, Blend[{Red, White}, .8]}, #1] &)]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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