Possible define an image and assign to a material?

Hi Natan, OK thats what i figured the last time i tried it, it will not work in python. btw. why is the texture written to the temp dir at all if it is a memory texture ? I’ve found that i can access and change it ?


The RDK writes one or more versions of any texture that is used. If you add a procedural texture to a material you’ll find that you get an image in tmp for that procedural as well - it is also just a memory/on-the-fly texture.

Thanks, i know that it writes a ton of images. I need to clear these folders often, otherwise i would run out of disk space.


I’m one of those lazy users which find it useful when I search the forum and get hits in the source code. :wink:

Thank you for the useful code example which made me end up in this thread. :+1:

// Rolf

Hi guys, thanks for the info, but I realize that this is a bit over my skills.

So a quick question: What is the simplest way to save an image from python when I have a image defined the way I want it?

(I start off with:
bmpOut = System.Drawing.Bitmap(NewWidth, NewHeight)
And then I set the pixles)

Is bmpOut.Save(saveImagePath) a way to do it?
(Sorry for asking obvious questions, but it’s a bit new for me :slight_smile: )


1 Like

Thanks, I’ll figure that out and should be up and running with an OK solution soon.
…when I have a few hours to spare…

But first I shall attend my Finnish Yoga class for some friday relaxation:


Loosing up those hard to reach back muscles are important after a long week in front of the monitor


1 Like

All relaxed and managed to make a 5 color gradient saved as png next to the Rhino model.
So that’s the big step towards the goal.
Thanks for the help so far @nathanletwory !
(And Cheers!)

Small update for those interested:

Here’s what I’m wokring on:
A “shader” that generates a 5 color gradient to illustrate altitude on terrains.
The 5 colors are customizable and so are the “steps” in the colors. I want those so it easy to follow a contour.

Here you can see the same gradient with out steps:

And shown from top on a peaky landscape:

And a with/without comparison:

Now I just need to iron out a few material generating issues, but it serves my purpose so I can live with a few hickups for a while :slight_smile:



In v7 there is a gradient hatch created by @stevebaer - maybe it can be used for this type of shading as well?

Thanks, that would probably have been good enough if it was available in V6, but now that I started the journey I sat my eyes on a higher goal and that is to add steps and also subtle contourlines that brightens or darkens the underlying color.
So as always, A BIG Thank You for all your help Nathan, you really help me out a lot!!!

With Raytraced you could make a custom material and have a color ramp driven by that height (:

For fun

terrain_height.3dm (655.7 KB)
terrain_height.gh (15.0 KB)

here a slightly cleaned up GH with some groupings and namings. Maybe a bit easier to understand: terrain_height.gh (15.7 KB)

1 Like

I love it, here I work my butt off at night time and you just cook an interactive tool together for fun… :smiley: Thanks for sharing, I’ll dig into it and see what I can learn. And come over to Norway for a weekend, I have some beers here with your name on it!

1 Like

To give you a bit more work, I suppose that perhaps ideally, you would have a shader that is both elevation and slope dependent. On flatter parts, up to a certain elevation, you would have more greens than on steeper parts.

1 Like

Ah, yes, for renderings a slope based material blend with procedurals would be nice… for sure!
Something like this:


Then also take from the geometry input node the normal and factor that into the equation as well.

I leave that as an excercise to all readers (:

1 Like

Too bad I don’t have time to read this (ø:

GhGL could do this, but it would only work for OpenGL display and not for rendering.

You know me, I prefer realtime anyway, but I’m good anyway now that the script is working well :slight_smile:

@nathanletwory Thanks alot for your in-memory texture sample.

I’m having some trouble getting it to update the texture each time I run the command. It seems to generate a custom texture the first time, then reload the same one even if the supplied bitmap has changed.

If I modify the mapping channel, it seems to update once, but then reloads that new bitmap when its called again.

//rtex.SetProjectionMode(TextureProjectionMode.WcsBox, RenderContent.ChangeContexts.Ignore);
rtex.SetProjectionMode(TextureProjectionMode.MappingChannel, RenderContent.ChangeContexts.Ignore);

The RDK writes one or more versions of any texture that is used. If you add a procedural texture to a material you’ll find that you get an image in tmp for that procedural as well - it is also just a memory/on-the-fly texture.

Where would this sample be saving these images? Maybe if I clear this folder, as @clement suggested.

I’d like to use this sample as a workaround to the memory issues with Displaybitmaps noted here