Skip to content

Instantly share code, notes, and snippets.

@pharan
pharan / SpineMeshUVResizeCalculator.cs
Last active August 30, 2018 09:53
How to calculate how much to trim unused space on backing image for a Spine mesh, and output new UVs that map to the trimmed image.
using System;
public static class SpineMeshUVResizeCalculator {
public struct MeshUVData {
public float[] uvs;
public float imageWidth;
public float imageHeight;
public float trimLeft;
public float trimRight;
@pharan
pharan / BlendModeMaterialsAsset.cs
Last active September 16, 2018 07:50
Initial implementation of slot blend mode processing on the attachment level for Spine-Unity.
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
@pharan
pharan / Spine-Special-Skeleton-Grayscale.shader
Last active February 10, 2022 14:27
"Spine/Special/Skeleton Grayscale" shader
// - Unlit
// - Premultiplied Alpha Blending (Optional straight alpha input)
// - Double-sided, no depth
Shader "Spine/Special/Skeleton Grayscale" {
Properties {
_GrayPhase ("Phase", Range(0, 1)) = 1
[NoScaleOffset] _MainTex ("MainTex", 2D) = "white" {}
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
@pharan
pharan / Atlas.cs
Last active November 9, 2018 21:47
NumberStyle-specified version of the Atlas.cs Spine atlas loader.
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of