Skip to content

Instantly share code, notes, and snippets.

@nickludlam
nickludlam / GetNoiseUV.hlsl
Created February 12, 2023 19:16
Function to sample a blue noise texture for use with each screen pixel
// Requires NDC from GetVertexPositionInputs() in the vert shader
float2 GetNoiseUV(float2 positionNDC) {
float2 blueTexSizeMultiplier = _BlueNoise_TexelSize.xy; // i.e. 1/32
float2 screenWidthHeight = _ScreenParams.xy + float2(0.5, 0.5); // i.e. 1920,1080 + half to center
return screenWidthHeight * blueTexSizeMultiplier * positionNDC;
}
@nickludlam
nickludlam / sync_mastodon_bookmarks.py
Last active January 26, 2023 19:49
Sync Mastodon bookmarks with an instance of the bookmarking website Linkding at https://github.com/sissbruecker/linkding
"""Sync Mastodon bookmarks to Linkding
This script will automatically fetch a user's bookmarks from a
Mastodon instance. If the bookmark is not yet present in the
Linkding bookmark site, it's created as an unread, along with
any other things like custom tags.
If the bookmarked Mastodon toot only contains one link, excluding
any others like user mentions and hashtags, then that link is
used for the bookmark URL, instead of the toot itself.
@nickludlam
nickludlam / AutoBuilder.cs
Last active November 21, 2021 14:33
A simple action to allow Fastlane to trigger Unity in batch mode, executing a specific method call that you can use to customise your build process
public static class AutoBuilder
{
static string defaultBundleIdentifier = "com.yourcompany.yourproduct";
static string[] GetScenePaths()
{
List<string> scenes = new List<string>();
for (int i = 0; i < EditorBuildSettings.scenes.Length; i++)
{
@nickludlam
nickludlam / UnityAppController.mm
Created August 16, 2021 08:46
A small amendment to application:didRegisterForRemoteNotificationsWithDeviceToken: so I can see the deviceToken in hex
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSUInteger dataLength = deviceToken.length;
if (dataLength > 0) {
const unsigned char *dataBuffer = (const unsigned char *)deviceToken.bytes;
NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)];
for (int i = 0; i < dataLength; ++i) {
[hexString appendFormat:@"%02x", dataBuffer[i]];
}
NSLog(@"APNS Test: deviceToken=%@", hexString);
@nickludlam
nickludlam / fix_unity_guids.rb
Created August 11, 2021 18:16
How to change Unity meta script references from a DLL to individual files
require 'tempfile'
require 'fileutils'
puts ARGV.inspect
base_path = "unity-project"
file_suffixes = ["*.unity", "*.prefab", "*.controller", "*.mat"]
$unity_loose_file_id = "11500000" # unity hardcoded value
source_data = """
‘vide’/‘420v’ 192x 144, { 1- 60 fps}, HRSI:4032x3024, fov:64.720, no bin, no vis, max zoom:189.00 (upscales @21.00), AF System:2, ISO:34.0-3264.0, SS:0.000014-1.000000, supports HDR, no wide color support, no multicam
’vide’/‘420f’ 192x 144, { 1- 60 fps}, HRSI:4032x3024, fov:64.720, no bin, no vis, max zoom:189.00 (upscales @21.00), AF System:2, ISO:34.0-3264.0, SS:0.000014-1.000000, supports HDR, supports wide color, no multicam
’vide’/‘420v’ 352x 288, { 1- 60 fps}, HRSI:3696x3024, fov:59.327, no bin, no vis, max zoom:189.00 (upscales @10.50), AF System:2, ISO:34.0-3264.0, SS:0.000014-1.000000, supports HDR, no wide color support, no multicam
’vide’/‘420f’ 352x 288, { 1- 60 fps}, HRSI:3696x3024, fov:59.327, no bin, no vis, max zoom:189.00 (upscales @10.50), AF System:2, ISO:34.0-3264.0, SS:0.000014-1.000000, supports HDR, supports wide color, no multicam
’vide’/‘420v’ 480x 360, { 1- 60 fps}, HRSI:4032x3024, fov:64.720, no bin, no vis, max zoom:189.00 (upscales @
@nickludlam
nickludlam / vector.py
Created January 31, 2021 01:36
Not sure where I got this from.
# vector.py
from math import sqrt
class Vector3(object):
"""
3-D vector implementation.
Purpose: Provide
* Core functionality to ray tracing implementation.
@nickludlam
nickludlam / source.json
Created January 26, 2021 21:21
The current Hutton owned systems
{"Narenses":{"x":-1.15625,"y":-11.03125,"z":21.875},"George Pantazis":{"x":-12.09375,"y":-16,"z":-14.21875},"Barnards Star":{"x":-3.03125,"y":1.375,"z":4.9375},"Hill Pa Hsi":{"x":29.46875,"y":-1.6875,"z":25.375},"Epsilon Indi":{"x":3.125,"y":-8.875,"z":7.125},"Haghole":{"x":-5.875,"y":0.90625,"z":23.84375},"Ross 671":{"x":-17.53125,"y":-13.84375,"z":0.625},"Karsinanari":{"x":-29.875,"y":-46.1875,"z":-8.03125},"LP 532-81":{"x":-1.5625,"y":-27.375,"z":-32.3125},"Wolf 1481":{"x":5.1875,"y":13.375,"z":13.5625},"Wolf 25":{"x":-11.0625,"y":-20.46875,"z":-7.125},"Trepin":{"x":26.375,"y":10.5625,"z":9.78125},"Alpha Centauri":{"x":3.03125,"y":-0.09375,"z":3.15625},"Luyten 145-141":{"x":13.4375,"y":-0.8125,"z":6.65625},"LP 525-39":{"x":-19.71875,"y":-31.125,"z":-9.09375},"Wolf 124":{"x":-7.25,"y":-27.15625,"z":-19.09375},"LP 245-10":{"x":-18.96875,"y":-13.875,"z":-24.28125},"Epsilon Eridani":{"x":1.9375,"y":-7.75,"z":-6.84375},"Stein 2051":{"x":-9.46875,"y":2.4375,"z":-15.375},"WISE 0855-0714":{"x":6.53125,"y":-2.15625
@nickludlam
nickludlam / travelling_trucker.py
Last active January 31, 2021 02:37
Looking at how to optimise the Travelling Trucker problem for The Hutton Orbital Truckers group
import sys
import time
import json
import random
import operator
from enum import Enum
import vector
import networkx as nx
Shader "Custom/XRayTransparency"
{
Properties
{
_RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0)
_RimPower ("Rim Power", Range(0.5,8.0)) = 3.0
}
SubShader
{