Skip to content

Instantly share code, notes, and snippets.

@rstecca
rstecca / MinimalSurfaceWithGrabPass.shader
Last active June 6, 2023 16:55
Minimal example of a Surface Shader using a Grab Pass
Shader "Custom/MinimalSurfaceWithGrabPass"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_SeeThrough ("See Through (not a transparency)", Range(0,1)) = 0.5
}
@rstecca
rstecca / .zshrc
Last active November 12, 2020 16:49
macOS .zshrc boilerplate (essential with current git branch)
#!/bin/zsh
export EDITOR="nvim"
export VISUAL="nvim"
export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
export HISTFILE="$ZDOTDIR/.zhistory" # History filepath
export HISTSIZE=10000 # Maximum events for internal history
export SAVEHIST=10000
@rstecca
rstecca / TextMeshProWarper.cs
Created October 28, 2020 16:30
TextMeshPro Warper
// Thanks to Kemble Software https://www.youtube.com/channel/UC-n80lsjMCS3OJR8kFrATLg
// Nice hack here: https://www.youtube.com/watch?v=FXMqUdP3XcE
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
[RequireComponent(typeof(TextMeshPro)), ExecuteInEditMode]
public class TextMeshProWarper : MonoBehaviour
@rstecca
rstecca / BlenderArrayToObjects.py
Last active December 30, 2020 16:40
Blender Python script to process Array Modifiers to create transformed Object clones rather than just geometry
import bpy
from mathutils import Vector, Matrix, Quaternion, Euler
from random import uniform
# Uses Array modifier data to generate OBJECTS rather than just geometry
# Find this Gist at https://gist.github.com/rstecca/7fe38e3846749c0118e6bd20cb83c39c
# github.com/rstecca
# Only works with Array Modifiers with ObjectOffset
# Tested in Blender 2.83.1
@rstecca
rstecca / manifest.json
Created May 16, 2018 10:20
Unity 2018.2 ECS manifest.json file
{
"dependencies": {
"com.unity.standardevents": "exclude",
"com.unity.purchasing": "exclude",
"com.unity.ads": "exclude",
"com.unity.analytics": "exclude",
"com.unity.package-manager-ui": "1.8.2",
"com.unity.collections":"0.0.8",
"com.unity.mathematics":"0.0.7",
"com.unity.incrementalcompiler": "0.0.38",
@rstecca
rstecca / BuildAndIncrementVersionNumber.cs
Created May 15, 2018 09:36
Increment version number on build (Unity/iOS)
/*
From Derek Arndt's tweet
https://twitter.com/derekarndt/status/993994998084354048
*/
using UnityEditor;
using UnityEditor.Build;
using System.Diagnostics;
public class BuildAndIncrementVersionNumber : IPostprocessBuild
@rstecca
rstecca / JsonTest.cs
Created May 15, 2018 08:41
Unity Tips: Json Utility minimal example
/*
JSON minimal example.
To understand how object members map to json and vicecersa.
Experiment by changing types and values.
twitter: @riccardostecca
*/
using System.Collections;
using System.Collections.Generic;
@rstecca
rstecca / MakeA3DObjectDraggable.cs
Last active September 29, 2021 11:32
How to make a 3D object draggable in Unity3D
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
/*
MAKE A 3D OBJECT DRAGGABLE
Riccardo Stecca
http://www.riccardostecca.net
@rstecca
rstecca / ViveControllersTest.cs
Last active May 6, 2018 16:43
C# one-line getters to catch Vive cotrollers
/* * * * * * * *
PUT THESE AS CLASS MEMBERS
* * * * * * * * */
SteamVR_Controller.Device _leftController;
private SteamVR_Controller.Device leftcontroller
{
get
{
return _leftController ?? ((SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.FarthestLeft) == -1) ? null : _leftController = SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.FarthestLeft)));
@rstecca
rstecca / DebugTriangleNormals.cs
Last active May 4, 2021 09:28
Unity Debug Mesh Normals in Editor
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class DebugTriangleNormals : MonoBehaviour {
#if UNITY_EDITOR
List<Vector3> trisCenters;