2022-05-07 02:27:06 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "IK9lYTykdbtt"
},
"source": [
2022-05-08 04:10:39 +00:00
"<h1>BlendererOnline</h1>\n",
"<small><i>Uses some codes of <a href='https://urlzs.com/4hkfp' target='_blank' rel='noopener'>BlenderRender</a> by <a href='https://urlzs.com/ToHpE' target='_blank' rel='noopener'>aniquetahir</a>.</i></small>\n",
2022-05-07 03:03:51 +00:00
"\n",
2022-05-08 04:10:39 +00:00
"<p>Render Blender files online, for free. </p>"
2022-05-07 02:27:06 +00:00
]
},
{
"cell_type": "code",
2022-05-08 04:10:39 +00:00
"execution_count": 3,
2022-05-07 02:27:06 +00:00
"metadata": {
"id": "F5vZwPfYenN8"
},
"outputs": [],
"source": [
"#@title Configuration\n",
"class formatting:\n",
" clear = '\\033[0m'\n",
" class color: \n",
" purple = '\\033[95m'\n",
" cyan = '\\033[96m'\n",
" cyan_dark = '\\033[36m'\n",
" blue = '\\033[94m'\n",
" green = '\\033[92m'\n",
" yellow = '\\033[93m'\n",
" red = '\\033[91m'\n",
" class font:\n",
" bold = '\\033[1m'\n",
" underline = '\\033[4m'\n",
"\n",
"## Define screen functions. \n",
"def clear(): from IPython.display import clear_output; return clear_output()\n",
"\n",
"class info: # screen messages\n",
" def status(message): print(formatting.font.bold + 'Status: \\t' + formatting.clear + message)\n",
" def err(message): print(formatting.font.bold + formatting.color.red + 'Error: \\t' + formatting.clear + formatting.clear + message)\n",
" def warning(message): print(formatting.font.bold + formatting.color.yellow + 'Warning: \\t' + formatting.clear + formatting.clear + message)\n",
" def success(message): print(formatting.font.bold + formatting.color.green + 'Success: \\t' + formatting.clear + formatting.clear + message)\n",
"\n",
"def check_compatibility(): \n",
" try: from google.colab import files\n",
" except: raise TypeError(\"No! Please run this in \" + formatting.font.bold + 'Google CoLab' + formatting.clear + '. ')\n",
"\n",
2022-05-07 04:58:09 +00:00
"def getExtension(fileName): \n",
" import os\n",
" fileName_split = os.path.splitext(fileName)\n",
"\n",
" return fileName_split[1].lower()\n",
"\n",
2022-05-07 02:27:06 +00:00
"def UploadBlendFile(): # Make sure that the file is actually a Blender file. \n",
" check_compatibility()\n",
2022-05-07 04:58:09 +00:00
"\n",
" import pathlib; from google.colab import files\n",
2022-05-07 02:27:06 +00:00
" uploaded_file = files.upload()\n",
" \n",
" return uploaded_file\n",
"\n",
2022-05-08 03:50:53 +00:00
"def checkValidUpload(what): # Make sure that the user has that file uploaded when specifying the name. \n",
2022-05-08 04:10:39 +00:00
" import os\n",
" if not(os.system('cat ' + str(what))):\n",
" info.warning('File does not exist.')\n",
" return (not(os.system('cat ' + str(what))))\n",
2022-05-08 03:50:53 +00:00
"\n",
"def properlySetFrames(frame_start, frame_end): \n",
" if frame_start == frame_end: return frame_end\n",
" else: return False\n",
2022-05-07 04:58:09 +00:00
"\n",
2022-05-07 02:27:06 +00:00
"class configuration: \n",
" #@markdown ### Input\n",
2022-05-07 04:58:09 +00:00
" \n",
2022-05-08 03:50:53 +00:00
" upload_new = 0 #@param {type:\"slider\", min:0, max:1, step:1}\n",
" if upload_new == True: UploadBlendFile()\n",
2022-05-07 04:58:09 +00:00
"\n",
2022-05-08 03:50:53 +00:00
" # user preferred file name\n",
2022-05-08 04:10:39 +00:00
" blend_fileName = 'test.blend' #@param {type: \"string\"}\n",
" blend_fileName = blend_fileName.strip()\n",
" if blend_fileName != None: \n",
" if getExtension(blend_fileName) != '.blend' : blend_fileName = (str(blend_fileName) + '.blend'); checkValidUpload(blend_fileName)\n",
2022-05-07 02:27:06 +00:00
"\n",
2022-05-07 04:58:09 +00:00
" #@markdown ### Processing\n",
2022-05-07 02:27:06 +00:00
" renderer = \"CYCLES\" #@param [\"CYCLES\", \"BLENDER_EEVEE\", \"BLENDER_WORKBENCH\"]\n",
2022-05-08 03:50:53 +00:00
" device = \"CPU\" #@param [\"CPU\", 'CUDA', 'OPTIX', 'HIP', 'METAL']\n",
"\n",
" #@markdown ### Animation\n",
2022-05-07 04:58:09 +00:00
" frame_start = 1 #@param {type: \"number\"}\n",
2022-05-08 03:50:53 +00:00
" frame_end = 1 #@param {type: \"number\"}\n",
"\n",
" frame = properlySetFrames(frame_start, frame_end)\n",
"\n",
" #@markdown ### Output\n",
" output_fileFormat = 'JPEG' #@param ['TGA', 'RAWTGA', 'JPEG', 'IRIS', 'IRIZ', 'AVIRAW', 'AVIJPEG', 'PNG', 'BMP']\n"
2022-05-07 02:27:06 +00:00
]
},
{
"cell_type": "code",
2022-05-08 04:10:39 +00:00
"execution_count": 5,
2022-05-07 02:27:06 +00:00
"metadata": {
"colab": {
2022-05-08 04:10:39 +00:00
"base_uri": "https://localhost:8080/"
2022-05-07 02:27:06 +00:00
},
"id": "8szOTQ7TTgNm",
2022-05-08 04:10:39 +00:00
"outputId": "f4464c1a-6a83-44fd-edcc-212eb4bfc9ea"
2022-05-07 02:27:06 +00:00
},
"outputs": [
{
"output_type": "stream",
2022-05-08 04:10:39 +00:00
"name": "stdout",
2022-05-07 02:27:06 +00:00
"text": [
2022-05-08 04:10:39 +00:00
"\u001b[1mStatus: \t\u001b[0mStarting render of file test.blend…\n",
"src/tcmalloc.cc:283] Attempt to free invalid pointer 0x7fc749c1e040 \n"
2022-05-07 02:27:06 +00:00
]
}
],
"source": [
"import os\n",
"\n",
"class formatting:\n",
" clear = '\\033[0m'\n",
" class color: \n",
" purple = '\\033[95m'\n",
" cyan = '\\033[96m'\n",
" cyan_dark = '\\033[36m'\n",
" blue = '\\033[94m'\n",
" green = '\\033[92m'\n",
" yellow = '\\033[93m'\n",
" red = '\\033[91m'\n",
" class font:\n",
" bold = '\\033[1m'\n",
" underline = '\\033[4m'\n",
"\n",
"class info: # screen messages\n",
2022-05-08 03:50:53 +00:00
" def status(message): print(formatting.font.bold + 'Status: \\t' + formatting.clear + message)\n",
" def err(message): print(formatting.font.bold + formatting.color.red + 'Error: \\t' + formatting.clear + formatting.clear + message)\n",
" def warning(message): print(formatting.font.bold + formatting.color.yellow + 'Warning: \\t' + formatting.clear + formatting.clear + message)\n",
" def success(message): print(formatting.font.bold + formatting.color.green + 'Success: \\t' + formatting.clear + formatting.clear + message)\n",
2022-05-07 02:27:06 +00:00
"\n",
2022-05-08 04:10:39 +00:00
"def check_fieldsFilled(): # Make sure that the user has run the previous cell. \n",
2022-05-08 03:50:53 +00:00
" try: \n",
" clear()\n",
" except: \n",
" raise ImportError(formatting.font.bold + 'Please run the configurations cell before rendering. ' + formatting.clear + 'No default values are to be passed by this cell. ')\n",
" return False\n",
" else: \n",
2022-05-08 04:10:39 +00:00
" if configuration.blend_fileName == None: \n",
" raise ImportError(formatting.font.bold + 'Input Blender file name is missing. ' + formatting.clear + 'It is a required field. ')\n",
" else: \n",
" return True\n",
2022-05-07 02:27:06 +00:00
"\n",
"def install(what, isCritical = False):\n",
2022-05-07 03:03:51 +00:00
" if what == \"required\":\n",
" install(\"blender\", True)\n",
" install(\"libboost-all-dev\")\n",
" install(\"libgl1-mesa-dev\")\n",
2022-05-08 04:10:39 +00:00
" clear()\n",
2022-05-07 03:03:51 +00:00
" else:\n",
" info.status('Installing ' + what + '…')\n",
" try:\n",
" if os.system('apt install ' + what + ' -y') > 0: \n",
" if os.system('apt-get install ' + what + ' -y') > 0: \n",
" if os.system('apt install --fix-broken ' + what + ' -y'): raise\n",
" except:\n",
" errorMsg = (what + ' could not get installed. ')\n",
" if isCritical: raise SystemError(errorMsg + 'Unfortunately, this module is required. ')\n",
" else: info.err(errorMsg)\n",
" else: \n",
" os.system('apt clean && apt autoremove -y')\n",
" info.success('Installed '+ what + '.')\n",
2022-05-08 03:50:53 +00:00
"\n",
"def render(): \n",
2022-05-08 04:10:39 +00:00
" def checkInvalidUploadProceed(): # Make sure user is sure that the file does exist. \n",
2022-05-08 03:50:53 +00:00
" clear()\n",
2022-05-08 04:10:39 +00:00
" if not(checkValidUpload(configuration.blend_fileName)): \n",
2022-05-08 03:50:53 +00:00
" confirm_tries = 2; confirm_count = 0; \n",
" while confirm_count < confirm_tries: \n",
" try:\n",
" input('This will cause errors. Do you want to continue? \\n[\\tYes (⏎)\\t]')\n",
" except KeyboardInterrupt: \n",
" return False\n",
" else: \n",
" confirm_count = confirm_count + 1\n",
" if confirm_count == 2: return True\n",
2022-05-08 04:10:39 +00:00
" else: return True\n",
2022-05-08 03:50:53 +00:00
"\n",
"\n",
" def start_render(): \n",
" # Command line arguments from here: https://urlzs.com/MiUkt\n",
" # Simplified here: https://urlzs.com/au5z7\n",
"\n",
" info.status('Starting render of file ' + configuration.blend_fileName + '…')\n",
"\n",
2022-05-08 04:10:39 +00:00
" if not(configuration.frame): \n",
2022-05-08 03:50:53 +00:00
" !blender -b {configuration.blend_fileName} -o ./output_ -E {configuration.renderer} -F {configuration.output_fileFormat} -x 1 -s {configuration.frame_start} -e {configuration.frame_end} --cycles-device {configuration.device}\n",
" else: \n",
" !blender -b {configuration.blend_fileName} -o ./output_ -E {configuration.renderer} -F {configuration.output_fileFormat} -x 1 -f {configuration.frame} --cycles-device {configuration.device}\n",
2022-05-07 02:27:06 +00:00
"\n",
2022-05-08 04:10:39 +00:00
" if checkInvalidUploadProceed(): \n",
" start_render()\n",
"\n",
2022-05-07 02:27:06 +00:00
"def main():\n",
2022-05-08 04:10:39 +00:00
" check_fieldsFilled();\n",
2022-05-08 03:50:53 +00:00
" install(\"required\");\n",
2022-05-08 04:10:39 +00:00
" render();\n",
2022-05-07 02:27:06 +00:00
"\n",
"main()"
]
},
{
"cell_type": "code",
2022-05-08 03:50:53 +00:00
"execution_count": null,
2022-05-07 02:27:06 +00:00
"metadata": {
2022-05-08 04:10:39 +00:00
"id": "Hk2D1RK3WqVV"
2022-05-07 02:27:06 +00:00
},
2022-05-08 04:10:39 +00:00
"outputs": [],
2022-05-07 02:27:06 +00:00
"source": [
2022-05-07 03:03:51 +00:00
"\n",
2022-05-08 03:50:53 +00:00
"\n",
"!blender -b $filename -o ./test_ -E $renderer -x 1"
2022-05-07 02:27:06 +00:00
]
},
{
"cell_type": "code",
2022-05-08 03:50:53 +00:00
"execution_count": null,
2022-05-07 02:27:06 +00:00
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 557
},
"id": "ilwDQe4gb3O5",
"outputId": "8d38304b-87c8-4887-94ae-8104865d8148"
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA8AAAAIcCAYAAAA5Xcd7AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGnRFWHRGaWxlAC9jb250ZW50L0d1ZGFrby5ibGVuZA+BJn4AAAAYdEVYdERhdGUAMjAxOC8wOS8xOSAyMDo1MDoyNzEN4xkAAAAQdEVYdFRpbWUAMDA6MDA6MDA6MDHswybCAAAACXRFWHRGcmFtZQAwMDHBURUiAAAADXRFWHRDYW1lcmEAQ2FtZXJhaP/v6QAAAAt0RVh0U2NlbmUAU2NlbmXlIV2WAAAAE3RFWHRSZW5kZXJUaW1lADEzOjE5LjkwzN+ZMQAAIABJREFUeAHs3VmzZll62PV95iHPOTlPlZVV1V3d1bNk2RKyZazwBQGOYAgIDNxgAxEOTIRvCF/AFUTf8xlwcMHnIDDcGMuj5lYP1TXnnHnmMc/h/1tvpizbWLQsdatl1a48td+999preNYzP89ae+4//uVfvvj57cfTF3c+na4szk8vp2m61Hnu4mI6X5ifLs/PTxf9d/zyYlpamJvmzrs/NzfNz03TUb8vKn+5ci8rf9bFUr/Pzs+nQ78rs9h5ufoOX55P16pru3eWu3/a32F1Xl9amJaq7GXP93p2e3lhqpXpuPoc6l3t+Xn39E2dL05fjna3qm95qfaq57xn+7WrPe8u18eD6lus/Ep9mrp32rOzzrtn1dazqpwOOr3s962VxekH+8fTRn2t9GjjjdWl6bhn3lmu3EXlH5+8nG5U9unx2fTi5Gx6Vr/na3+5hvYre6W2drpX0Wmpv8vu93yzMWx3f2lOX86nSxV4VKcv195GY7jee5eXFqeNP1udbx9OawvTdFJ9J7W7UR2HARfMXJ8HiBMNdDzv98FZYzy+mOY+u5ie/aO5aWFvflpdXp1eLC5Nh7t79f1iulH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Y7l+b/USeLpP4XhR3zhROGwWq2er8amHYwM+rnbmSBiKTmUpV89SNjgAKFjXK28uVyp7EOBudL1eGfh+VJ0Eh7opvK/7/U5wfVgdqwFkr7noUQZDikew4/C4XH+a2ukwGBw0LnVfbSwvwxXK5FrP56pzI+/O3nE4ULv3Elq7nW9m5B+leGtrpT/6OuUfLR52PqkMelsOE9QL1zfrc0UH3r0MblcX3wnWV5vvR8PZcDO4vwSvynM+XFxuTG8fTDtLKUpwspcZBssZxlez0d75YpX5+xeOJ785TW/+B/X1a9P0f/2duemd3YXpaWWeBKMnGUNX68di49uJVhjv5rImG4tzP/zrDy4vzqXSBqT1uc0Mp/2MX7CLD3VWHrItHR9ONxvf7tqlaT88/nEde8Hn/ZXV6VdWNnMgrE5v1NDGyfFQHtAABRJfrEvTfr+P6x9e8azruYy+z8KW7f4+vpjB9CQY/+b5wfRPXh5NWxnBv3ry/eb+aPrV4/9j+kJjmVZ+LcfJd6O9DOD9z6rl16f9o+81l78yLb78bvi4PW0f/f2cNwfTw8N/EN/5rDYfN+efVvb9nFgPYwTPpx+c/c60dvHRtLT0cHp29lvTk/3vRN+H09z60+mD7UywAPo4/KJwL7zCN85B/IpifynehL/sh2/rCQGK+mUGQjBfTtknE/aaD7yJMYoHPO4ehwCnEOff1QzQo+Z7oboOuncSjuOl8JzjDO1hWi9Suq7Xj0bcEd7Xh9WYLZmyGs1wpJ6n0KPFMDSai0f1vjo3cqiwWe9mrL8fnl0O/qvNxmp1P6/vz8Oje+sr05P42XHX2RqDvla/WSXvHk3Ll86nG1l3S7eqxOR+s0Z+rvPl/lgwGGPOxNUY7kN02yW+tBMTOKi+3Z0chD+cn76wuzJ9IWfMemPeqM8zeVg14eZxsNkkjxrHXPQw//J0e
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"execution_count": 8,
"metadata": {
"tags": []
},
"output_type": "execute_result"
}
],
"source": [
2022-05-07 02:32:06 +00:00
"from IPython.display import Image\n",
2022-05-07 02:27:06 +00:00
"Image(filename='./test_0001.png')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Kvv_WzdIf1CA"
},
"outputs": [],
2022-05-08 03:50:53 +00:00
"source": [
""
]
2022-05-07 02:27:06 +00:00
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"name": "BlenderRender.ipynb",
2022-05-08 03:50:53 +00:00
"provenance": []
2022-05-07 02:27:06 +00:00
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 0
2022-05-08 03:50:53 +00:00
}