Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#323 Normal Vector Coloring using Explicit Pm3d Coloring

open
nobody
None
5
2014-03-17
2012-03-06
Douglas
No

Now that we have explicit color in pm3d, there is one last ingredient to make it easy to color a figure based on the normal vector (this is how Mathematica makes it's beautiful 3d plots and helps convey details like shape and curve more effectively than a height-map). It must be possible for gnuplot to determine the normal vector for each tile it places down for the pm3d plot, which allows us to do something like this...

plot '++' u 1:2:3:(color(nvx($1,$2),nvy($1,$2),nvz($1,$2))) w pm3d lc rgb var

An external routine could compute the functions nvx,nvy,nvz and put them in the fourth, fifth, and sixth data columns, but it would be better to be able to feed in a 3D data set and leave the coloring to gnuplot.

Since I am not a developer, I don't know what hidden conventions this would break, but it seems possible and extraordinarily useful, since now we have a platform for beautiful 2D plots, but have to go into the hideously complicated and difficult-to-adjust Mathematica to get 3D plots that convey shape effectively.

To anyone who takes this up or gives a good reason not to, thank you!

Discussion

<< < 1 2 3 4 5 > >> (Page 3 of 5)
  • Ethan Merritt
    Ethan Merritt
    2012-04-18

    It's pretty, yes. But is there actually any useful information added? Here's your "problematic" plot rendered in gnuplot's traditional hidden3d mode. To my eyes this is arguably more clear than the pretty normal-based coloring.

    I'm not disputing that there may be some real world cases where the value of the surface normal encodes important information. If we're going to pursue this as a code feature, I'd much rather test+optimize on a such a real world case so that we can evaluate it in terms of effective presentation rather than prettiness.

     
  • Ethan Merritt
    Ethan Merritt
    2012-04-18

    compare hidden3d and pm3d color-by-normal

     
    Attachments
  • Douglas
    Douglas
    2012-04-19

    I've now added a new option "set pm3d corners2color shade" which does a very simple shading algorithm on top of the palette heightmap. I've attached a screenshot and the patch file which (I hope) will make this happen. Here's the script for the screenshot:

    set xrange [-8:8]
    set yrange [-8:8]
    set samples 100, 100
    set isosamples 100
    set pm3d
    set pm3d corners2color shade
    splot cos(x)+cos(y) w pm3d

     
  • Douglas
    Douglas
    2012-04-19

    In my enthusiasm for the shaded version, I missed your last comment. I agree that finding a "killer app" for this feature important, and I'll try to brainstorm. In the meantime, here's a useful example: placing the shaded pm3d above the non-shaded flat plane, as is often used in the demos. To me, this is the best of both worlds: a nicely-rendered 3d image indicating curvature, and the pixel-by-pixel accuracy of the flat plane. By shading the palette in the surface, you also help the eye connect the heightmap at the bottom to the curvature at the top. I can't re-create it here because the normal shading currently also affects results at the base. But here's the script based on the new patch, and I have attached the result:

    set xrange [-8:8]
    set yrange [-8:8]
    set samples 100, 100
    set isosamples 100
    set pm3d
    set pm3d corners2color shade
    splot cos(x)+cos(y) w pm3d

    set xrange [-8:8]
    set yrange [-8:8]
    set samples 100, 100
    set isosamples 100
    set pm3d
    set pm3d corners2color shade
    set pm3d implicit at bs
    splot cos(x)+cos(y) w pm3d

     
  • Douglas
    Douglas
    2012-04-19

    color-by-shading at surface, and color-by-palette at base

     
  • Douglas
    Douglas
    2012-04-19

    The new patch and screenshot show what I'm looking for. Palette-based shading in the base, palette+normal-vector shading on the surface. In my opinion, this suffices as a killer app. This form of display indicates the most to my eye about what exactly is going on here.

     
  • Douglas
    Douglas
    2012-04-19

    A couple updates. The patch now accepts three parameters:

    set pm3d corners2color shade STRENGTH, LONGITUDE, LATTITUDE

    where STRENGTH determines the strength of the shading (default 0.5), and LONGITUDE AND LATTITUDE determine the orientation of the "sun" (defaults zero, pointing from the left).

    I have also attached two pictures which I think provide a good example of why such a tool is needed. The script that generated the pictures is

    set xrange [-3:3]
    set yrange [-3:3]
    set samples 100, 100
    set isosamples 100
    set pm3d corners2color shade
    splot '++' u 1:2:(sqrt(9-$1**2-$2**2)) w pm3d

    Without the color-by-shading, it's nearly impossible to see the rough surface, but with the shading, it's now obvious.

     
<< < 1 2 3 4 5 > >> (Page 3 of 5)