Skip to content

Instantly share code, notes, and snippets.

@lampysprites
lampysprites / space_topbar.py
Last active January 12, 2023 04:32
Add Armory run button to blender top panel
## armory/blender/arm/props_ui.py
def draw_space_topbar(self, context):
box = self.layout.row(align=True)
if state.proc_play is None and state.proc_build is None:
box.operator("arm.play", icon="PLAY", text="")
else:
box.operator("arm.stop", icon="MESH_PLANE", text="")
box.operator("arm.open_editor", icon="DESKTOP", text="")
box.operator("arm.open_project_folder", icon="FILE_FOLDER", text="")
@lampysprites
lampysprites / space_userpref_changes.py
Created January 10, 2022 09:30
Browse Addon files in blender
## EDIT space_userpref.py
# e.g. on windows, C:\Program Files\Blender Foundation\Blender 2.93\2.93\scripts\startup\bl_ui\space_userpref.py
# on windows, edit as admin
# CLOSE BLENDER AND BACKUP THAT FILE BEFORE STARTING!!
## before "class USERPREF_PT_addons(...)"
class USER_OT_AddonBrowse(bpy.types.Operator):
bl_idname = "user.browse_addon"
bl_label = "Browse Files"
@lampysprites
lampysprites / mtl_pixel.py
Last active May 28, 2021 19:21
Convert blender materials to pixel shadeless
import bpy
## For materials that have an image and a principled bsdf (like .obj imports fo instance)
## it will re-connect and set up everything to pixely emission with binary alpha
## IMPORTANT
## it will fuck up everything else that has an image texture and bsdf
## add some if's that make sence in your case
for mat in bpy.data.materials:
try:
@lampysprites
lampysprites / affine.py
Last active March 7, 2021 16:04
Screen space affine texture mapping in Blender
import bpy
import bmesh
# THIS SCRIPT WILL RENDER THE ANIMATION USING THE SCENE'S OUTPUT SETTINGS
# DURING THE RENDER BLENDER WILL APPEAR TO FREEZE
# TO SEE THE EFFECT, SET UP MATERIAL TEXTURES LIKE THIS:
#+-------------+ +------------------+ +-----------------+
#|UV MAP | |SEPARATE XYZ | |DIVIDE |
#| UV *|-----| X *|----------|* Value Value *|\
@lampysprites
lampysprites / wobble.py
Created January 7, 2021 20:15
Blender script for rounding vertices to camera pixels (aka playstation wobble)
import bpy
import bmesh
# PROOF OF CONCEPT VERSION
#
# THIS SCRIPT "PROJECTS" THE EDGES OF CAMERA PIXELS INTO 3D SPACE, SO THAT YOU CAN IMITATE
# "PLAYSTATION WOBBLE" BY SHRINKWRAPPING YOUR MESHES TO BOTH OF THEM THE SAME TIME
#
# TO CREATE A BIGGER MESH, CHANGE THE DEPTH VARIABLE BELOW
#