Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
# Simulator for depth comparison error (i.e. z-fighting)
# Nathan Reed, June 2015
# Written for Python 3.4; requires numpy
import math
import numpy as np
import optparse
# Parse command-line options
parser = optparse.OptionParser()
@unitycoder
unitycoder / ExampleInterface.cs
Created January 9, 2023 13:01 — forked from James-Frowen/ExampleInterface.cs
Unity3d, How to show an interface field in Inspector
namespace JamesFrowen
{
public interface ISomeInterface
{
void SomeMethod();
}
[System.Serializable]
public class SomeInterfaceWrapper : InterfaceWrapper<ISomeInterface>
{
@unitycoder
unitycoder / PixelDot.shader
Created January 10, 2023 09:47 — forked from EntranceJew/PixelDot.shader
Renders a screen-aligned, distance-independent, resolution-independent, pixel-perfect quad in Unity. Use it with the built-in quad mesh. You don't have to rotate or scale the mesh renderer, the shader will take care of it.
Shader "FX/PixelDot"
{
Properties
{
[NoScaleOffset] _MainTex ("Texture", 2D) = "white" {}
_Color ("Color", Color) = (1, 1, 1, 1)
_Size ("Pixel Size", Range(1, 64)) = 1
}
SubShader
{
//PIXELBOY BY @WTFMIG EAT A BUTT WORLD BAHAHAHAHA POOP MY PANTS
// - edited by @Nothke to use screen height for #LOWREZJAM
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
[AddComponentMenu("Image Effects/PixelBoy")]
public class PixelBoy : MonoBehaviour
{
public int h = 64;
@unitycoder
unitycoder / FogComponent.cs
Created February 9, 2023 07:59 — forked from cs-altshift/FogComponent.cs
Simple Fog Shader
using UnityEngine;
[RequireComponent(typeof(Camera))]
public class FogComponent : MonoBehaviour
{
public Shader myFogShader;
public Color fogColor = Color.red;
private Material myFogMaterial;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class TestRendererFeature : ScriptableRendererFeature
{
private TestRenderPass testRenderPass;
public Material fogMaterial;
public Color fogColor;
@unitycoder
unitycoder / SeededRandomNumberGenerator.cs
Created February 9, 2023 07:59 — forked from cs-altshift/SeededRandomNumberGenerator.cs
C# Allocation-free Seeded Random Number Generator
using System;
namespace AltShift.Maths.Randomization
{
// No-alloc version coded from Random source code
// https://referencesource.microsoft.com/#mscorlib/system/random.cs
public unsafe struct SeededRandomNumberGenerator
{
private const int MSEED = 161803398;
private const int MZ = 0;
@unitycoder
unitycoder / ExtendedColors.cs
Created February 9, 2023 08:00 — forked from cs-altshift/ExtendedColors.cs
Extended Colors for Unity
using UnityEngine;
namespace AltShift.Productivity
{
// Extracted from: https://www.december.com/html/spec/colorpercompact.html
public static class ExtendedColor
{
public static Color _100_euro = new Color(0.53f, 0.78f, 0.49f);
public static Color _20_pound = new Color(0.64f, 0.4f, 0.51f);
public static Color _6_ball = new Color(0.11f, 0.39f, 0.33f);
@unitycoder
unitycoder / ScreenSpaceNormals.shader
Created February 9, 2023 08:00 — forked from cs-altshift/ScreenSpaceNormals.shader
Screen-space normals shader for Unity - Compatible with URP
Shader "Unlit/Screen Space Normals"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
@unitycoder
unitycoder / CC-Glass.shader
Created February 9, 2023 08:00 — forked from cs-altshift/CC-Glass.shader
Crying Suns Command-Center Glass Shader
Shader "Crying Suns/Command Center Glass"
{
Properties
{
[PerRendererData] _MainTex ("Main Texture (ignored)", 2D) = "white" {}
[NoScaleOffset] _ReflectionTex ("Reflection Texture", 2D) = "black" {}
_ReflectionAlpha ("Reflection Alpha", Range(0, 1)) = 0.25
_ReflectionScale ("Reflection Scale", Range(0, 1)) = 1
[HideInInspector] _SunCenteredViewportPos ("Sun Centered Viewport Position", Vector) = (0, 0, 0, 0)
[HideInInspector] _SunAngle ("Sun Angle", Float) = 0