Trick: Changing Moho's Fixed 3D Light Direction! (+ Free Tool)

Have you come up with a good Moho trick? Need help solving an animation problem? Come on in.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
takuya
Posts: 38
Joined: Sun May 01, 2022 10:26 pm

Trick: Changing Moho's Fixed 3D Light Direction! (+ Free Tool)

Post by takuya »

Subject:
Hi everyone,

We all know one of the biggest frustrations with Moho's native 3D workspace: the light source is permanently locked to the bottom-right. If you want natural overhead daylight or rim lighting on a 3D prop, you are usually out of luck.

I was experimenting with this and figured out a geometric workaround. Since we cannot move the light source via the API, I tried doing the exact opposite. What if we perform a micro-orbit with the camera around the 3D object, while counter-rotating the object to keep its 2D silhouette exactly the same?

It actually works! It creates the illusion that the light source is moving around the 3D model.

Image

Doing this math manually across a timeline is a nightmare, so I wrote a pipeline utility to automate it. It calculates the camera orbit, safely renders the shading in the background, and automatically imports it back into your timeline as a clean PNG sequence inside a Switch Layer.

I’ve decided to release this tool (Shadow Baker 3D) 100% for free for the community.
(⚠️ Note: Because it relies on a background Python render engine calling Moho.exe, it is Windows ONLY at the moment).

You can download it for free here:
https://2dpipelinetools.gumroad.com/l/shadowbaker3d

I hope this helps anyone trying to get better cel-shaded looks or customized lighting on their 3D props without leaving Moho. Let me know if you try it out!

Cheers,
Takuya
User avatar
synthsin75
Posts: 10549
Joined: Mon Jan 14, 2008 2:20 pm
Location: Oklahoma
Contact:

Re: Trick: Changing Moho's Fixed 3D Light Direction! (+ Free Tool)

Post by synthsin75 »

Any reason you didn't use the silent image render from Moho's API?
https://mohoscripting.com/methods/mohol ... layerimage
takuya
Posts: 38
Joined: Sun May 01, 2022 10:26 pm

Re: Trick: Changing Moho's Fixed 3D Light Direction! (+ Free Tool)

Post by takuya »

Hi Wes,

Thank you so much for the tip!

I actually hadn't realized that `moho.layer:RenderLayerImage()` was available until you pointed it out. Seeing your suggestion, I immediately tested it out, hoping it could replace the external Python process with a 100% internal, silent Lua render.

However, after testing, I ran into a technical limitation with how it renders:
`RenderLayerImage` appears to be designed primarily for game engine texture/asset export (added in 14.4), so it renders the layer strictly in its fixed local texture space. Because of this, orbiting the scene camera (`fCameraPanTilt`) or changing the view angle does not affect the shading in the resulting output image—it always outputs the layer's local orthogonal view.

To capture the subtle shading changes created by orbiting the scene camera around the 3D model, I had to keep using Moho's command-line batch renderer via the background Python engine.

If `RenderLayerImage` could have an optional parameter or flag in a future update to respect the active scene camera's perspective and transform, it would be an absolute game changer—not just for game export, but for procedural in-app shading and baking utilities like this. I would love to see that if the dev team ever considers expanding that API!

On a related note, I recently updated the script's internal architecture (Python engine call and path resolution) to support macOS as well. However, since I don't own a Mac myself, I haven't been able to verify if the background CLI render works smoothly on macOS yet (experimental support). If any Mac users in the community happen to try it out, I'd really appreciate any feedback!

Thanks again for the great insight and suggestion!

Cheers,
Takuya
User avatar
synthsin75
Posts: 10549
Joined: Mon Jan 14, 2008 2:20 pm
Location: Oklahoma
Contact:

Re: Trick: Changing Moho's Fixed 3D Light Direction! (+ Free Tool)

Post by synthsin75 »

Ah, yeah, RenderLayerImage is specifically meant to get orthogonal view. I forgot about that.
Post Reply