Image Texture Mapping

i have a script of multiple cuboids stacked one on top of another, like u can see in the image.

Here’s the grasshopper file-

image mapping.gh (4.3 KB)

I am trying to map an image over front faces of these cuboids. i want the whole image to be projected individually on each box and whatever part of image falls on that part of face to be applied on its face and not the whole image like this -

here’s the attached jpeg im trying to project-

I want, I want, I want.

can we do it using image sampler?

It’s cleaner with the Vectorize plug-in.

can u attach this grasshopper(gh.) file

Run the PackageMager command from with in Rhino. Search for Vectorize. Install and restart Rhino.

You can rebuild the script from the image.

Hello

I am not sure what you ask is what you want. Image Sampler is used to get a color at a specific position of the image.

As you seem to want an image projected you want, you surely need a texture. The most simple is to use Rhinoceros and set texture coordinates to the boxes.
In Grasshopper I don’t know a tool that can set texture mapping to Brep. For mesh you can use Nautilus or Flexibility (it projects on a box, not along a direction) or Human.
Flexibility is more simple.
In Nautilus you must have a sort of master mesh with UV, I used the bounding box, the use the coordinates to set UV between [0,1]

image mapping LD.gh (17.1 KB)

It’s possible to import the image and make a colored mesh out of it.

image mapping VR 02.gh (49.4 KB)

I don’t know why you would want to do this though. For one, the quality of the image is then is dependent on the import sampling resolution:

and the higher you set the resolution, the longer the script takes to execute. For a per-pixel calculation, it took 2 minutes. :joy:

Much to my chagrin, I found out at the very end od the script, that when you merge meshes they lose their vertex color assignments meaning this whole script was for naught.

:person_facepalming:

Here, the vector version:

image mapping VR 01.gh (22.2 KB)

Hello
indeed Mesh Join keeps colors on Vertex WHEN all meshes have colors on vertexes.
Here you can see that some meshes have no colors

So you surely have to put a default color on some meshes. it must be the same things with UV coordinates.

Mesh Join works here, all meshes have colors on vertexes

Don’t be stubborn,

I had a drafted reply with my suggestion to use that ‘import image’ component and stopped myself for the same reasons.

Thank you for informing me of this. I tested and can verify it is true. Even in writing that the joining of meshes rid the meshes of their vertex colors, I thought there must be some caveat to this. I have updated my script above, and also provided Import Image with a smaller sampling resolution so that the file does not surprise you with a two minute loading time.

This was my first time using the Mesh Spray and Mesh Split Plane components. I have to say, as I was contemplating how to split the image mesh, I was looking through the Mesh > Utilities and Intersect > Shape Panels and was underwhelmed by my options. Initially I set out to split the meshs by Mesh Intersection. When this failed, I turned to using Mesh Split Plane. In hindsight, perhaps my attempt with Mesh Intersection would have worked if I had not been trying to intersect open meshes in the same plane, i.e. intersected the image mesh with box meshes.

Mesh Split Plane is troublesome because unlike, say, the components Trim with Region and Trim with Region(s), Mesh Split Plane does not have a counterpart that allows splitting of a mesh by multiple planes. It forced me to split the image mesh by planes in a loop. A Mesh Split Plane(s) component would be useful, especially if instead of Above and Below outputs, the component would deliver an Index map of the planes used to create a particular split-piece of a mesh.

I am slowly learning about how the points and vertices of a mesh are different things and that vertices unlike points also store information on color, UV coordinates, and normals. In your script, in the UV remapping of vertices, the UV from Mesh to Meshes component outputs invalid meshes:

Why does this happen and why is it unproblematic? Also, say if I wanted to apply two different images to the boxes; a logo on the front, and different logo on the back. How would I go about doing this?

is there a way, where i can bake the image i see in custom preview into rhinoport? i have to send each individual box to the manufacturer. how do i do it? i cant use vectorize because i might later need to print an image which may not be properly vectorized by vectorize plugin

Hello
I am not sure I understand, because at the end there is no need to use Grasshopper for that.
In rhinoceros an object could have a texture. I don’t see others ways except having some fine meshes with colors on vertexes !

So if you want mesh from Grasshopper, graft input of “UV from Mesh to Meshes” then bake the output of mesh union
Make a material in Rhino with the Image you need, then assign this material to the objects


But all this process can be done more easily in Rhinoceros
Make the box with array, then apply a planar mapping !!

If you want better answers try to be more precise and also learn how the tools works.

What formats are accepted by manufacturer ?
Did you see that mapping is goin through the object ? Is it a problem ?
Manufacturer of what ? Is it 3d printing, just image printing … ?

I’ll have to dig on the invalid mesh. I think it is not a problem because it is an empty mesh (no vertices, no faces …). In my tool MeshTo is exploded at unwelded edges.
Box have 48 vertices and 36 faces. The output of “UV from mesh to meshes” generates meshes with a total of 36 faces. So all faces are there ! But I suspect that in the original mesh some points are shared among faces and some aren’t !!

I am not sure but at first I’ll make a unique image with 2 logos then apply UV.

@CM_Adithya
image mapping.gh (28.6 KB)

Another option is to create a new “picture” material in rhino, just add your image and leave the material there, takes 2 seconds:

This makes it ‘retrievable’ within grasshopper via query model materials, you can use a hint to match yours:


To bake just select the custum preview button and hit insert on your keyboard (or right-click>bake) to bake each mesh with the inhereted texture.

Good Sir, by what black art did’st thou impart such bold affect upon thy net?


image mapping VR 03.gh (32.9 KB)

This is how I had intially attempted to solve the problem! But it didn’t work until I replaced Mesh Surface with Mesh Brep as you have used.

I would like to know why one works and the other does not.

Ha! It cannot be known :face_holding_back_tears:
I meshed it the same way you did and also used Simple Mesh and it didn’t work—yet the Mesh Brep still produced the same-but-not-the-same mesh :man_shrugging:

@laurent_delrieu, any idea? :face_holding_back_tears:

I have tried to project the image onto surfaces which are in different planes. but im getting invalid meshes onto which the image is not being projected properly as you can see in the image. i have attached my gh.file here -

sneax.gh (38.1 KB)

@Volker_Rakow can you pls look into this?