Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

share|improve this question
1  
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 –  Szabolcs Jul 1 at 17:49
    
Are you the same person as here? –  Szabolcs Jul 1 at 17:50
    
Yes. I was not able to log-in to the account for some reason. –  BeauGeste Jul 1 at 18:17
    
It's better to prepend your comment with @szabolcs if you want him to get a notification –  belisarius Jul 1 at 18:44
    
@BeauGeste Please try to merge your accounts using this page –  rm -rf Jul 1 at 20:56

1 Answer 1

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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