Baking shadows to texture

I would like to use Rhino’s rendering capabilities to calculate shadows on objects and bake those shadows into a texture bitmap. This bitmap can then be used as texture, either in Rhino or other visualization platforms to show good looking scenes without the need for advanced rendering.

I have discovered the “Bake” command, which is very similar to what I am looking for, except it doesn’t include the shadows in the resulting bitmap.

Is there a way to bake shadows like this in Rhino? Either through vanilla Rhino, plugins or scripting - all suggestions are welcome!

Example scene

Notice the nice shadows.

Bake output

Notice the absence of shadows.

Example file

bake-shadows.3dm (308.6 KB)

Sorry, this isn’t possible in Rhino. I filed the request in the past for future reference and if you’d like to add a comment there. https://mcneel.myjetbrains.com/youtrack/issue/RH-28546

1 Like

Got it, thanks @BrianJ! Is there a workaround, or any way to achieve this through scripting? Does RhinoCommon provide access to an object’s render results?

I don’t know of a method myself in Rhino.

Hi,
Possible in Blender useing the Cycles render engine. You can bake a range of stuff to a single diffuse texture.
Also possible in 3DCoat as lightmap baking.

I’ll add my support for such a feature in Rhino Cycles.

Steve

1 Like

That’s great news @Steve_Howden, thanks! Do you know where I can read more about the Blender Cycles texture baking workflow? Any documentation or tutorial? I’m not super familiar with Blender.

Assuming I’m able to get the baked texture including shadows in Blender, Is there a way this texture can be exported and brought back into Rhino?

Wow. Idk that this feature of extracting textures exists in Rhino.

I was actually looking for this a while back.

Maybe the Mcneel team can change the name of the command to something else so that this doesn’t get confused with bake of
grasshopper. “ExtractTexture” or something like that.

1 Like

Hi Emil,

Here’s a pretty good tutorial:

If you’re not familiar with Blender, there are lots of getting started tutorials out there.
Cheers, Steve

1 Like

You should be able to get geometry into Blender using GitHub - jesterKing/import_3dm: Blender importer script for Rhinoceros 3D files

1 Like

Fantastic, thanks! :pray: I’ll check it out!

That’s great, cheers! The workflow might be something similar to this then:

  1. Export 3dm from Rhino
  2. Import 3dm to Blender using the blender 3dm importer
  3. Use Blender & Cycles to get the baked textures
  4. Export the textures as bitmap from Blender
  5. Import textures as bitmap to Rhino
  6. Geometry + texture in Rhino can be used to create 3D files including textures including shadows (for example in the context of rhino.compute). Win!

@nathanletwory @Steve_Howden do you think this procedure makes sense?

Hi Emil

Sort of right. When you say textures (plural) you might be exporting a variety of textures that had lighting applied in Blender. If you then plugged those textures into slots in Rhino materials and lit them in Rhino, you would get visual conflicts.

Much better to bake everything down to a single diffuse texture and apply that single texture to a material in Rhino.

When I say single texture, I mean single texture per object

1 Like

Yes, that makes sense. Thanks for clarifying that.

Actually, when I think about it, what I’m really after is the shadow/ambient occlusion effects. So ideally, the export from Blender would be a single texture per object containing only a greyscale bitmap of the shadows. That would allow me to apply the bitmap as a transparancy map, so that I can control and calibrate the object’s “real texture” (let’s say wood panel) from Rhino.

Not sure if it makes sense to do it like this - I would love feedback, See below for more info about the propsed workflow.

Setup

This scene contains two surfaces with a small distance between them. The upper surface will be used a transparancy texture calculated in Blender.

The real object

The real object. Stays in rhino and contains the wood panel texture.

The transparancy texture object

This geometry is a duplicate of the real object (or perhaps with a small offset to prevent Z fighting). It is imported to Blender (along with other objects) where the texture is caluclated. The texture is then applied in Rhino as a transparancy texture.

Combined results

The combined objects including their textures

You’ve got it. Just export the baked shadows or ambient occlusion you want and then composite in Photoshop to create new material or do as you describe with the extra object
Have fun, Steve

1 Like

Ok, thanks! :raised_hands: appreciate the feedback. I’ll give it a go!