Grasshopper

algorithmic modeling for Rhino

Case: You have hundreds of objects, each with a different color. You want to render them, so you create one material per object or per color.

Problem: You can't manually modify hundreds of materials after the fact. You can't use features of advanced render plugins. If you are working on the new RDK or V5, you have a material editor with hundreds of materials, making it uncomfortable to use.
Solution: Create a bitmap image that contains all the colors, then modify the mesh coordinates of each object so that they point to the right pixel of the bitmap texture. This way you can create a single material with the bitmap as the diffuse color and assign this material to every object (or layer containing the objects). Each object will render as a different color.
The attached user object will generate a png image and will bake mesh objects with the correct texture coordinates and object color. You have to input a folder name, a list of mesh objects and a list of colors. The component is disabled by default, so to run it you have to right click on it and select "enabled".
Example:

Now placing the bitmap (after deleting a few pixels in photoshop) into the luminosity slot:


EDIT: updated it so it works with the latest GH release 0.8.0066

Views: 10521

Attachments:

Replies to This Discussion

Brilliant!!!
Can you show in more detail how you did this?  I downloaded the user component, but the inputs have no directions really, just a series of different variables t -x - y, can you give more explanation what to input?

Hi Andrew, sorry, only just saw your message. t is the path (string) into which to save the resulting texture (e.g. C:\Users\userName\Desktop).  m are the meshes to color, and c are the colors to apply to those meshes. Once these things are entered, use the "enable selection" button to activate this component. it will ask you for a file name, which must end with .png. The meshes you input will be baked into the document, and if you select them and set their render texture (via v-ray or other render material) to the png that you specified, each mesh will be colored appropriately.

 

Hope this helps!

 

Andrew

If you place the mouse over the middle part of the component or over the toolbar button and not move it, a tooltip will appear explaining the inputs.

Really nice method, I wonder how it will work with Vray.

Cheers

Victor

Hi

I am trying to use the attached user object in grasshopper, but I am having some problems that I hope some of you might be able to solve for me. I have importet an analysis from ecotect performed on a dubbled curved mesh with 401 faces and therefore the same amount of couleurs. The problem is when I connect the mesh and the couleurs to the user object and enable it, instead of creating one png image it creates a lot more, my guess is 401 png's. So what am I doing wrong?

Please Help..

The most probable cause is that your inputs are split into individual paths. Mesh and colors inputs must be a flat list of data.

 

In case you are using Brazil for Rhino as the renderer, there's a new shader for rendering mesh vertex colors, so it might be easier now to bake meshes with vertex color information.

Hi ;) This thing looks great ;) But i´ve got some problems with it :( How do i have to map the objects without getting a gradient to export them into other programs? And when i apply the mapping the texture coordinates are wrong and i get different colours as expected :( Whats your workflow with "modify the mesh coordinates of each object so that they point to the right pixel of the bitmap texture"?

And is it possible to give the objects a display colour / material with a specific colour instead of this texture so i can select and group the objects by coulour- picking? I would like to get a "clean" colour for every single object without gradients. Perfectly would be a set of 6 Materials for example.

Attachments:

Really clever.. Thanks for sharing.. (for me it had worked perfectly with boxes all the same size... )

Brilliant, and still works perfectly 5 years later!

Hi Vincente,

thanks for uploading this, great workaround!

I have one question: I setup my image with single colours via gradient and everything renders fine.

But now I would like to replace the single colours for textures (carpet tiles)

I could setup a texture by blowing up the single pixels output from you setup times eg. 256, and replace the squares with textures according to the gradient values.

Can your script be modified to not read a single pixel per mesh, but like in my case like 256x256 pixel?

I jumped into editing the source but I am afraid I can't edit it correctly by myself.

cheers,

daniel

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2022   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service