Opacity Gradient from Attractor Point

I’m not sure if this is a simple application or not, but what I’d like to do is to have a gradient of opacity (from solid to transparent) based on an attractor point.
In looking for this, I’ve seen a color gradient from an attractor point (see below) but I’d like to do the same with opacity. If possible a combination of a color gradient and the opacity gradient is what I’d like to explore.

I’d very much appreciate any suggestions, guidance, or references.

My wild guess is that the only way to create transparency is by a material, so I made seperate meshes out of every face and created a corresponding material (color + transparency is based on an attractor point), but the material creation slows the script down.

190804_OpacityGradientMesh.gh (14.4 KB)

Thank you! I do get an error message on the C# script. Do you know why I’m getting this? I haven’t been able to figure it out.
I see the following errors:

  1. Error (CS1061): ‘Rhino.DocObjects.Material’ does not contain a definition for ‘ReflectionGlossiness’ and no extension method ‘ReflectionGlossiness’ accepting a first argument of type ‘Rhino.DocObjects.Material’ could be found (are you missing a using directive or an assembly reference?) (line 82)
  2. Error (CS1502): The best overloaded method match for ‘Grasshopper.Kernel.Types.GH_Material.GH_Material(System.Guid)’ has some invalid arguments (line 86)
  3. Error (CS1503): Argument 1: cannot convert from ‘Rhino.Render.RenderMaterial’ to ‘System.Guid’ (line 86)

I think that script relies on Rhino SDK features which are fairly recent. What version of Rhino are you running?

Thanks for the response. I’m using Rhino 5. Unfortunately, I’m still saving up for Rhino 6.
Is this operation possible in Rhino 5?

Post your own code, of course.

Thank you @danielbent for posting something to work with. No need for C# (or R6) though:

OpacityGradientMesh_2019Aug4a.gh (16.4 KB)


Thank you all. I appreciate the continual support on this forum. It’s really helping me learn.

Joseph, you are such a legend and omnipresent.