Skip to content

Instantly share code, notes, and snippets.

View hogjonny's full-sized avatar

Jonny K Galloway hogjonny

View GitHub Profile
@hogjonny
hogjonny / HDR_to_RGBM.py
Last active March 15, 2024 11:31
Converts an input .HDR file, to a RGBM format output as a 8-bit (per-channel), RGBA .tga file. Iteration 1, didn't work so well (looked horrible) so I made some adjustments. This now takes input args, so it can be run from the commandline.
#!/usr/bin/python
#coding:utf-8
# -- This line is 75 characters -------------------------------------------
"""
This script will convert a .HDR (radiance) into a RGBM file,
then save it back out as a 8bit (per-channel) .tga
"""
__author__ = 'HogJonny'
# -------------------------------------------------------------------------
# fast easy work around for rendering hardware2/viewport2.0 sequence frames in Maya 2016
# you still need to setup for animation in the 'Render Settings'
# Change 'Frame/Animation ext:' pull down, so that each frame will be written out
# with name frame padding, etc.
import maya.cmds as cmds
# Settings
startFrame = int(cmds.playbackOptions(q=True, min=True))
endFrame = int(cmds.playbackOptions(q=True, max=True))
@hogjonny
hogjonny / substancePythonBatch.py
Created February 25, 2015 18:13
Basic python formatting for a working example of accessing Allegorithmic Substance BatchTools via script.
#!/usr/bin/env python
#coding:utf-8
# -- This line is 75 characters -------------------------------------------
__author__ = 'HogJonny'
import os, sys
import subprocess
#!/usr/bin/env python
#coding:utf-8
#--------------------------------------------------------------------------
def synthesize(inst, name, value, readonly=False):
'''
This is a convenience method for OOP
synthesizes the creation of attr with convenience methods:
x.attrbute
x._attribute # attribute storage
@hogjonny
hogjonny / fileDDS.py
Created December 18, 2014 23:24
Simple DDS file loader ... load a DDS file as a QImage
#!/usr/bin/env python
#coding:utf-8
__author__ = 'jgalloway@bluepointgames.com'
## reference: https://gist.github.com/bjorn/4635382
# -- This line is 75 characters -------------------------------------------
# example code
@hogjonny
hogjonny / hogGenGradient.py
Last active December 17, 2020 19:55
Working on code to convert an image to an 8-bit heightmap along with a colorRamp.\n 1. Use a !!! duplicate !!! of your image image to create index palette, save the palette (.act file)\n 2. Run through this script\n 3. Now use the sorted palette to index palette-ize your original image\n 4. Now switch the palette to 'grayscale' ... this you save…
#!/usr/bin/env python
'''
hogGenGradient.py
~~~
A script built on PIL to convert an image to 8-bit heightmap and a
luminance sorted gradient map.
Requirements: PIL, numpy
Tested mainly in Python 2.7 (also limited tests in 2.6.4)
@hogjonny
hogjonny / headerFooter.py
Last active December 22, 2015 20:59
Some simple formatting for nicely logging blocks of data (takes string block, or iterable data type ... fallback is the attrs on object passed in.)
#!/usr/bin/env python
#coding:utf-8
# -- This line is 75 characters -------------------------------------------
# headerFooter.py
# author: hogjonny [at] gmail [dot] com
# -------------------------------------------------------------------------
'''
Some string formatting and generator functions,
useful for logging, etc.
@smukkejohan
smukkejohan / chaossearh.py
Created February 20, 2012 22:26
Python port of Paul Bourke's random strange attractor generator using lyapunov exponents
# Python port of Paul Bourke's http://local.wasp.uwa.edu.au/~pbourke/fractals/lyapunov/gen.c
# By Johan Bichel Lindegaard - http://johan.cc
import math
import random
from PIL import Image, ImageDraw
import argparse
import os
parser = argparse.ArgumentParser(description='Search for chaos.')
@rduplain
rduplain / gist:1249199
Created September 28, 2011 20:41
Get a module's docstring in Python without executing it.
import code
def get_module_docstring(filepath):
"Get module-level docstring of Python module at filepath, e.g. 'path/to/file.py'."
co = compile(open(filepath).read(), filepath, 'exec')
if co.co_consts and isinstance(co.co_consts[0], basestring):
docstring = co.co_consts[0]
else:
docstring = None
return docstring