4
$\begingroup$

I am trying to color a BSplineSurface in a complex way but not having any luck using ColorFunction. I can use ColorFunction if I using BSplineFunction and ParametricPlot3D but would prefer not to go that route. Here is an example of the surface I would like to color:

Graphics3D[{EdgeForm[], SeedRandom[4];
  BSplineSurface[Table[{x, y, 0.25 + UnitStep[30 - Abs[x] - 0.001] UnitStep[50 -Abs[y] - 0.001] (0.25/RandomReal[{0.1, 2}]^2)}, 
  {x, -30, 30, 5.}, {y, -50, 50, 5.}]]}, Boxed -> False]

I would like to be able to color the peaks with one color (red) and have that color fade away to gray in the flat parts.enter image description here

$\endgroup$
  • 1
    $\begingroup$ I think that you cannot, as it's a single graphics object. But you can construct a BSplineFunction, use Plot3D to plot it, and use ColorFunction in Plot3D. This'll build up the plot from many graphics objects (polygons), each of which will be separately coloured based on your ColorFunction $\endgroup$ – Szabolcs Jul 1 '14 at 17:49
6
$\begingroup$
SeedRandom[4];
pts = Table[{x, y, 0.25 + UnitStep[30 - Abs[x] - 0.001] UnitStep[50 - Abs[y] - 0.001]
            (0.25/RandomReal[{0.1, 2}]^2)}, {x, -30,  30, 5}, {y, -50, 50, 5}];

ParametricPlot3D[
 BSplineFunction[pts, SplineDegree -> 2][u, v], {u, 0, 1}, {v, 0, 1}, 
 PlotRange -> All, Boxed -> False, Axes -> False, Mesh -> None, 
 ColorFunction -> Function[{x, y, z}, Blend[{Gray, Red}, z]]]

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.