Skip to content

Instantly share code, notes, and snippets.

@partybusiness
partybusiness / GatheringEnergy.shader
Created Jul 12, 2021
Lines shoot into a single point. Inspired in part by an effect from Revolutionary Girl Utena.
View GatheringEnergy.shader
Shader "Unlit/GatheringEnergy"
{
Properties
{
_LineWidth("Line Width", float) = 1.5
_LineLength("Line length", float) = 10.0
_LengthMult("Length Multiplier", float) = 0.2
_InwardSpeed("Inward Speed", float) = 4.0
_Seed("Random Seed", float) = 0.0
_Slices("Radial Slices", int) = 9
View MoonSkybox.shader
Shader "Skybox/MoonSkybox"
{
//Displays a skybox with an overlayed texture that can be positioned as a moon
Properties
{
_MoonTex ("Moon Texture", 2D) = "white" {}
_SkyMap ("Sky Map", Cube) = "" {}
_MoonDirection ("Moon Direction", Vector) = (0.4, 0.8, 0, 0)
_MoonScale ("Moon Scale", Range(0.01, 1.0)) = 0.2
}
@partybusiness
partybusiness / OnePointPerspective.cs
Last active May 9, 2021
Some camera tricks with the camera projectionMatrix in Unity
View OnePointPerspective.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class OnePointPerspective : MonoBehaviour {
[SerializeField]
private Camera camcam;
@partybusiness
partybusiness / ConvertImagesToTest.cs
Last active Apr 15, 2021
Text image format converter
View ConvertImagesToTest.cs
#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
@partybusiness
partybusiness / AlphaCorrect.shader
Last active Mar 27, 2021
Post-processing correction when outputting a transparent rendertexture. For some reason, I was getting a squared alpha so if I just dropped the result back in the scene, it was too transparent.
View AlphaCorrect.shader
Shader "Post/AlphaCorrect"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
LOD 100
@partybusiness
partybusiness / Diagonal.shader
Created Mar 23, 2021
Some shaders that distort texture sampling in interesting ways.
View Diagonal.shader
Shader "Unlit/Diagonal"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
View CubeMaterial.shader
Shader "Unlit/CubeMaterial"
{
Properties
{
_Cube("Cubemap", CUBE) = "" {}
}
SubShader
{
Tags {
"RenderType"="Opaque"
View Mondrian.shader
Shader "Unlit/Mondrian"
{
//This relies on the source mesh having two UV maps
// first UV map will define a centre point for each face based on the 0.5, 0.5 position
// it will then display 3x3 pixels selected based on the second UV map.
// The width of the centre pixel is defined in screen space, no matter how far it is from the camera
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_LineWidth ("Line Width", float) = 20.0
@partybusiness
partybusiness / ColourCycling.shader
Last active Apr 15, 2021
A colour cycling shader for Unity, inspired by old graphical trick but implemented differently because I don't have indexed colours.
View ColourCycling.shader
Shader "Unlit/ColourCycling"
{
//cycles through y position in CycleColours based on r value of _CyclePaint
//g value of _CyclePaint allows for y offset when selecting from _CycleColours
//b value of _CyclePaint acts as a mask, it displays _MainTex as the background anywhere it's 0
//make sure all textures are set to point filter
//When making your colours for the r value don't make the mistake I first did and forget that 0 and 255 are equal when cycling
//one or the other has to not go all the way to the end so they're spaced correctly
Properties
@partybusiness
partybusiness / FourCornerGradientScreen.shader
Created Jan 1, 2021
Skybox has four-colour gradient aligned with screen-space rather than world space.
View FourCornerGradientScreen.shader
Shader "Unlit/FourCornerGradientScreen"
{
Properties{
_TopLeft("Top Left", Color) = (0.5,0.5,0.5,1)
_TopRight("Top Right", Color) = (0.5,0.5,0.5,1)
_BottomLeft("Bottom Left", Color) = (0.5,0.5,0.5,1)
_BottomRight("Bottom Right", Color) = (0.5,0.5,0.5,1)
}
SubShader{