From procedural texture to image texture (How To)

Here is a way to transform procedural texture to a texture file.

In this description a procedural texture is a function that transform a coordinate in euclidean space (X, Y, Z) to a colors (Red, Green, Blue and why not Alpha).

  1. Unwrap the object(s) you want to texture, this object could be also an object that is just used as support of UV mapping (used with Texture Matching)

1bis) You can edit the UV map in UV editor in order to optimize the placement of objects.

  1. Extract the render mesh(es) using ExtractRenderMesh

  2. Open the Grasshopper Script
    Set render mesh(s) the the Mesh Component, if there are many meshes, use Mesh Join
    Choose the number of pixels for the texture file (512, 1024 …)
    Click on do the work
    The component will output a list of points (XYZ)
    image
    image

  3. Transform these point to colors
    image

  4. Give a path for a texture file, just PNG output at the moment, if extension is not png it will be changed to PNG
    Click on “Do The Work”
    image

  5. Apply the texture to your material

  6. You have now a procedural texture in a texture file that can be exported


    the 2048 pixels version (a bit long ~ 1 minute)

A project I am doing with some camo. Here the component to be used to “support” the unwrapping

And the object with the raw texture (I have to soften it a bit)

texture_mesh_legacy.gh (183.1 KB)

In this link you’ll find some nice textures

14 Likes

Wrapping texture on meshes was something I always seen on other softwares but completely miss on on rhino.
I can see many situations where this might come handy by creating ultra-light models with alpha channel and disabled filtering.
Thanks for sharing this, Laurent!
Top!

1 Like

I had some fun working a bit more on the texture part. In order go fastest I took a noise method inside a C# component.
I use this one

My camouflage texture maker has some possibilities. Four colors, it could pixelate outputs.



The main advantage is that if the Unwrapping/Texture matching is well done there is no seams visible.

@nathanletwory it could be interesting to do the same with texture generator in Rhinoceros/Cycle/Grasshopper. Do you know if it is possible to get the color in physical space (xyz) not UV space? At the moment all the tools in Rhinoceros works well, thanks for that. I had some problem with Texture Matching but I wasn’t able to repeat simply the error in order to post the problem!

3 Likes

You’d determine the UV coordinate based on the XYZ coordinate. Lets ask @Jussi_Aaltonen what the SDK tools in Rhino are to do this, he maintains the texture baking code in Rhino.

It’d be quite interesting to bake Cycles textures indeed. Cycles has bake functionality where for one or more objects the entire raytracing process is baked to texture but that I haven’t hooked up. So in addition to the normal albedo pass you’d get everything you’d choose - shadows, highlights, etc. That is commonly used to speed up rendering in especially animations and game models.

2 Likes

That’s called WCS mapping. And in the C++ SDK you can access this via CRhRdkTexture::ProjectionMode.