Skip to content

Instantly share code, notes, and snippets.

Shader that changes width of every second pixel by shifting UVs.
@partybusiness
partybusiness / WorldSpaceTextures.shader
Last active April 7, 2020 13:56
Shader that uses world-space coordinates to sample textures
Shader "Unlit/WorldSpaceTextures"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
@partybusiness
partybusiness / Stereo180Panorama_SideBySide.shader
Last active May 26, 2020 04:00
Stereoscopic shaders in Unity
Shader "Stereoscopic/Stereo180Panorama_SideBySide"
{
Properties{
[NoScaleOffset] _MainTex("Texture", 2D) = "white" {}
}
SubShader{
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
# Adding Mesh Function
#################################################
import bpy
def add_mesh(name, verts, faces, edges=None, col_name="Collection"):
if edges is None:
edges = []
mesh = bpy.data.meshes.new(name)
obj = bpy.data.objects.new(mesh.name, mesh)
col = bpy.data.collections.get(col_name)
@partybusiness
partybusiness / ColourFunctions.cginc
Last active August 4, 2020 23:05
Visual contrast testing in Unity
//functions from here:
//http://www.chilliant.com/rgb2hsv.html
float3 HUEtoRGB(in float H)
{
float R = abs(H * 6 - 3) - 1;
float G = 2 - abs(H * 6 - 2);
float B = 2 - abs(H * 6 - 4);
return saturate(float3(R, G, B));
}
@partybusiness
partybusiness / DrawLine.shader
Last active September 23, 2020 04:43
Line rendering shaders
Shader "Unlit/DrawLine"
{
Properties
{
_Color("Line Colour", Color) = (0.5,0.5,0.5,1)
_Width ("Line Width", float) = 2.0
_FadeWidth("Fade Width", float) = 0.1
}
SubShader
{
Shader "Unlit/SparkleMaterial"
{
//this will display a texture centred at the 0.5,0.5 point in the uvs of the mesh but scaled and rotated to match the screen
//_ImageSize sets the size of the texture in pixels
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_ImageSize("Image Size", float) = 30
}
SubShader
Shader "Skybox/SpaceWarp"
{
Properties{
_Color("Star Colour", Color) = (0.5,0.5,0.5,1)
_MidColor("Midground Colour", Color) = (0.5,0.5,0.5,1)
_BackColor("Background Colour", Color) = (0.5,0.5,0.5,1)
_FadeColor("Fade Colour", Color) = (0.5,0.5,0.5,1)
_GridSize("Grid Size", int) = 50
_MinStarSize("Min Star Size", Range(0.0, 1.0)) = 0.1
_MaxStarSize("Max Star Size", Range(0.0, 1.0)) = 0.3
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class JokerTeleport : MonoBehaviour
{
[SerializeField]
SkinnedMeshRenderer displayMesh;
@partybusiness
partybusiness / FourCornerGradientScreen.shader
Created January 1, 2021 23:45
Skybox has four-colour gradient aligned with screen-space rather than world space.
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{