Skip to content

Instantly share code, notes, and snippets.

View lcrs's full-sized avatar
🍅

lwws lcrs

🍅
View GitHub Profile
@lcrs
lcrs / hook.py
Created April 19, 2017 22:21
Initial hook.py including right click/copy clip path thing
#!/bin/env python
#******************************************************************************
#
# Filename: hook.py
#
# Copyright (c) 2008 Autodesk Canada Co.
# All rights reserved.
#
# Use of this software is subject to the terms of the Autodesk license
# agreement provided at the time of installation or download, or which
@lcrs
lcrs / UVless.py
Last active November 29, 2017 21:55
# Creates perspective projection in a shader without UVs on the geo
# Select the camera to project from, run this, two nodes appear in /mat
# [email protected]
import hou, math
cam = hou.selectedNodes()[0]
world2cam = cam.worldTransform()
world2camvex = str(world2cam).replace('[', '{').replace(']', '}')
aspect = float(cam.evalParm('resx')) / float(cam.evalParm('resy'));
haperture = cam.evalParm('aperture')
@lcrs
lcrs / track2particles.nk
Created April 25, 2018 15:19
2d track to 3d particle emitter via projection on card
set cut_paste_input [stack 0]
version 10.5 v3
push $cut_paste_input
Tracker4 {
tracks { { 1 31 1 }
{ { 5 1 20 enable e 1 }
{ 3 1 75 name name 1 }
{ 2 1 58 track_x track_x 1 }
{ 2 1 58 track_y track_y 1 }
{ 2 1 63 offset_x offset_x 1 }
# Retime a tracked object to better fit a target curve
# Select two Transform nodes: the first with a jerky tracked curve, the
# second with a smooth target curve
# Group effort by Lewis Saunders, Unai Martínez Barredo, Erwan Leroy
# Make a function to calculate the distance between two points
def distance(a, b):
return pow((a[0]-b[0])**2 + (a[1]-b[1])**2, 0.5)
# Find the closest point to p on the line ab
set cut_paste_input [stack 0]
version 11.2 v1
CheckerBoard2 {
inputs 0
format "2048 1024 0 0 2048 1024 1 2048x1024"
name CheckerBoard1
selected true
xpos -40
ypos -153
}
#!/usr/bin/python
# pass: /path/to/scene.hip ropname startframe endframe howmany threadseach
# e.g.:
# /works/useful/poast/hrender-multi.py /Volumes/fast/nissan/eye/eye_v08.hip mantra1 1 118 16 1
import sys, os, time
hipfile = sys.argv[1]
rop = sys.argv[2]
start = int(sys.argv[3])
@lcrs
lcrs / progress.py
Last active November 21, 2020 01:18
#!/usr/bin/python
# Prints a progress bar and stats for a folder filling with files
# Pass the path and the total expected count, like:
# ./progress.py /path/to/somewhere/ 900
# |UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU | 62% 157/250 0.2fps 6.4spf eta0:09:57
# TODO:
# o Data rate stats
# o Take a fragment of shell script for custom counting
import os, sys, time, datetime
// Create a basis from points of triangle.
matrix3 basis_from_triangle(vector p1, p2, p3)
{
// Axes vectors. May not be orthogonal.
vector X, Y, Z;
Z = p2 - p1;
X = p3 - p1;
Y = normalize(cross(Z, X)) * length(p2 - p3);
return set(X, Y, Z);
}
@lcrs
lcrs / perc-dup-chek.py
Created February 2, 2019 20:32
check for matching images using perceptual hashing
from PIL import Image
import imagehash, os, sys
basenames1 = os.listdir(sys.argv[1])
basenames2 = os.listdir(sys.argv[2])
list1 = []
list2 = []
for (dirn, basen, lis) in ((sys.argv[1], basenames1, list1), (sys.argv[2], basenames2, list2)):
for fil in basen:
@lcrs
lcrs / matchboxlist.py
Last active February 23, 2019 16:51
List matchbox shaders and their descriptions
#!/usr/bin/python
import os, glob, xml.etree.ElementTree as et
html = open('/tmp/matchboxlist.html', 'w')
xmls = glob.glob('/opt/Autodesk/presets/2019.2.1/matchbox/shaders/LOGIK/*.xml')
xmls.sort()
for xml in xmls: