How to create a material in grasshopper from an image

How to create a material in Grasshopper with an image, also I need to adjust mapping scaling, rotation

Using native components, this is not possible yet.

What you can do is create the material in Rhino and the reference it in Grasshopper.

Just write the material name into a text panel and plug it into the Material input of the Custom Preview

1 Like

Thankyou for the reply,

I’m already using that way, but there is a problem that, I had to redo 'the select one material ’ process everytime I update texture mapping. I m not getting a live preview until baked, i specifically need the road texture applied to full stretch along the road following curves of road also. Is there any solution.

Hello
you will find some discussions on this forum if you search with “texture” keyword

Here a simple way of doing using some C#, could be Python. I am not sure it is the last Material but it works.
You will find some way of changing texture like here

material.gh (9.8 KB)
You can add easily others texture not just the diffuse but the bump …

private void RunScript(System.Drawing.Color Colour, double Reflection, double Smoothness, string filename, Transform transform, ref object Mat)
  {
    Reflection = Math.Min(Math.Max(Reflection, 0), 1);
    Smoothness = Math.Min(Math.Max(Smoothness, 0), 1);
    Rhino.DocObjects.Material material = new  Rhino.DocObjects.Material();
    //material.SetBitmapTexture(fileName);
    material.ReflectionColor = Colour;
    material.DiffuseColor = Colour;
    material.AmbientColor = System.Drawing.Color.Black;
    material.EmissionColor = System.Drawing.Color.Black;
    material.Reflectivity = Reflection;
    material.ReflectionGlossiness = Smoothness;

    Rhino.DocObjects.Texture text = new Rhino.DocObjects.Texture();
    text.ApplyUvwTransform = true;
    text.UvwTransform = transform;
    text.FileName = filename;
    material.SetTexture(text, Rhino.DocObjects.TextureType.Diffuse);


    var renderMaterial = Rhino.Render.RenderMaterial.CreateBasicMaterial(material);
    Mat = new GH_Material(renderMaterial);
  }
5 Likes

Thank you very much @laurent_delrieu for the custom component

1 Like

2 posts were split to a new topic: Rhino.DocObjects.Texture.UvwTransform is not working

Thank you very much @laurent_delrieu
I would appreciate anyone who can help
I know this is an old question
But I needed the subject now urgently
I don’t know Grasshopper and I need to have a bump map on a certain surface
How do I use my image to make the texture I need?
including bumps
Thank you again,
Chaya

But do you know Rhinoceros and the basics of texturing ? It is far from clear why you need Grasshopper. With so little information I am not sure someone could help you.

@laurent_delrieu Thank you very much for the quick reply
Rhinoceros I know perfectly well
What are the basics of texturing?

Hi @a.irfan,

In Rhino 8 you can use ‘Import Material’ to create a material from an image file.

In Rhino 9 WIP you have much more control.

4 Likes

Thank you very much!
Could you please send the first picture in a higher quality
Some of the letters are blurry…
thanks

Nothing blurry here…

right,
now it’s ok
The problem was probably mine

This topic will be helpful for you

1 Like