GhGL Shaders - a bunch of shaders to share

Hi everyone,

I wanted to share a small collection of shaders that I recently put together into a single file. These shaders are a compilation of various versions I found online, contributed by talented individuals such as @stevebaer, @Mariusz_Hermansdorfe, and @jho. I’ve made some tweaks and modifications to them myself, and I’ve also created a few new ones with the help of chatgpt’s creative input. :smile:

Feel free to utilize these shaders in your projects, make adjustments according to your needs, and even contribute your own shaders to expand this collection. I’ll be adding more shaders in the upcoming days and weeks. I’ve found them to be more efficient in terms of execution speed compared to traditional methods.

To make use of these shaders, make sure you have the ‘ghgl’ (7.8.0) plugin installed via your package manager (Rhino 7)

Happy experimenting!


Shaders_combined.gh (192.5 KB)

10 Likes

Thank you very much for sharing all these shaders!

The Fresnel Shader created by @jho shows tris along the surface.
I see those tris in your GH either.
Is it possible to repair it?

Here a update.
Modified for usability and added a new bunch of shaders. Feel free

MESH

  • show Wireframe
  • show Vertices
  • show Shaded
  • show Normal
  • show Textured
  • show Textured Shading
  • show Zebra
  • show Heightmap
  • show Contour Fill
  • show Contour Lines
  • show Radial Gradient
  • show Conical Gradient
  • show Draft Angle
  • show Edge Draw
  • show Slope
  • show Aspect
  • show Toon 1
  • show Toon 2
  • show Half Tone
  • show Two Sided
  • show 3D Print Overhang
  • show Fresnel
  • show Sun Shading
  • show Vertex Symbols

CURVES

  • show 2 Directional Gradient - world
  • show Simple 1 Directional Gradient - screen

shaders.zip (9.2 MB)

required GHGL 7.8.0 plugin (install via package manager), OpenGL shader support in Grasshopper

Credits to @stevebaer, @Mariusz_Hermansdorfe, @laurent_delrieu, @jho , and @crz_06. My appologizes if I forgot someone. All were modified by @crz_06 and main sources: GitHub - mcneel/ghgl: OpenGL shader support in Grasshopper or https://discourse.mcneel.com

12 Likes

Thanks @crz_06
How to use a different vector instead of Z axis, in this case Camera direction

glmaps.gh (111.7 KB)

glmaps_edit_crz_06.gh (119.8 KB)
added variable vector. If you need real-time camera update change python accordingly or use external plugin to get you camera dir vector

1 Like

I case you didn’t know there is a ShowZBuffer command in rhino that toggles the display of a grayscale z-buffer bitmap with the same dimensions as the viewport.

Thank you , works as expected

Yes i know about it


is possible to export the toon shade as a render material? or bake the object with the material?
and the “showzbuffer” is like an AO of the object or what would you use it for?

Toon shading involves real-time lighting calculations, which don’t bake directly. You’d need to bake the visual effect into a texture map and apply that to the object. I am not sure if that can be done. I did see an example to export it as GLTF formats for web viewing

Regarding ShowZBuffer, it’s not like ambient occlusion (AO) directly. The Z-buffer visualizes depth information, showing how far or close objects are from the camera. You can use this data for post-processing effects, like depth-based shading or compositing. AO simulates the soft shadows from ambient light, while the Z-buffer is purely geometric depth. You could, however, use the Z-buffer in combination with AO for effects like depth of field or depth-based shading. I use for a fast way to visualize a heightmap, with either absolute or relative distance independent of camera