Everything is explained in this video

These are the codes and commands for the texture baking on google colab.

First thing first, make sure you watched the video and subscribe.

Now these are the commands to download and install blender and connect google drive to your google colab.

!wget https://download.blender.org/release/Blender2.92/blender-2.92.0-linux64.tar.xz
!tar xf blender-2.92.0-linux64.tar.xz
!apt install libboost-all-dev
!apt install libgl1-mesa-dev
from google.colab import drive
drive.mount('/gdrive')

Now you a python script for baking the texture.

import bpy

# The String Variable To Store The Name Of Our Specific Object
objTex = input("Enter The Object Name : ")

# Deselect All Objects
for x in bpy.data.objects:
    x.select_set(False)

# Select That Specific Object And Set It As Active Object
bpy.context.view_layer.objects.active = bpy.data.objects[objTex]
bpy.data.objects[objTex].select_set(True)

print("Baking DIFFUSE Texture For " + objTex + " ...")

# Baking The Texture
bpy.ops.object.bake(type='DIFFUSE')

# Baked Image File Name
imgFileName = bpy.path.abspath("//Texture-Diffuse.png")

print("Baking Done. Saving Image To : " + imgFileName)

# Saving The Image
img = bpy.data.images["Texture"]
img.save_render(imgFileName)

The commands for running blender on google colab notebook.

filename = '/gdrive/MyDrive/BlenderRender/07/BakeTexture.blend'
!sudo ./blender-2.92.0-linux64/blender -b $filename -P '/gdrive/MyDrive/BlenderRender/07/BakeTextures.py' 

Remember to change the file names to yours so you don’t get errors.

That’s it. If you have any question. Ask

Check out our Free Assets

Leave a Reply

Your email address will not be published.