Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / Unity Fragment Shader Cheat Sheet .cs
Created October 17, 2021 19:27 — forked from quizcanners/Unity Fragment Shader Cheat Sheet .cs
To keep snippets of code for Shaders. Just some stuff that I often use but also often forget because brain=poo
//https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html
//https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/CGIncludes/UnityCG.cginc - Most interesting stuff ;)
//https://github.com/TwoTailsGames/Unity-Built-in-Shaders/tree/master/CGIncludes
//https://docs.unity3d.com/Manual/SL-Shader.html
//http://developer.download.nvidia.com/CgTutorial/cg_tutorial_appendix_e.html
//https://unity3d.com/how-to/shader-profiling-and-optimization-tips
//https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html
//http://www.deepskycolors.com/archive/2010/04/21/formulas-for-Photoshop-blending-modes.html
//http://www.iquilezles.org/blog/
//https://www.youtube.com/channel/UCcAlTqd9zID6aNX3TzwxJXg
@unitycoder
unitycoder / cheatsheet.shader
Created October 17, 2021 19:27 — forked from lonewolfwilliams/cheatsheet.shader
A cheatsheet and or boilerplate for CG / shaderlab in Unity
Shader "Unlit/ScreenFade"
{
Properties
{
//https://docs.unity3d.com/Manual/SL-Properties.html
//[HideInInspector]
//[NoScaleOffset]
//[Normal]
//[HDR]
//[Gamma]
@unitycoder
unitycoder / shaderBasicsCheatSheet.shader
Created October 17, 2021 19:27 — forked from enesser/shaderBasicsCheatSheet.shader
Shader Basics Cheat Sheet (Unity)
// *****************
// Types of Shaders:
// * Surface Shader:
// lit shaders that affect lighting of an object
// * Unlit Shader:
// vertex and fragment shader, control vertex properties
// * Image Effect Shader:
Shader "Name" {
Properties {
_Name ("display name", Range (min, max)) = number
_Name ("display name", Float) = number
_Name ("display name", Int) = number
_Name ("display name", Color) = (number,number,number,number)
_Name ("display name", Vector) = (number,number,number,number)
@unitycoder
unitycoder / StandardSurfaceShaderWithVertexColor.shader
Created September 16, 2021 08:31 — forked from phest/StandardSurfaceShaderWithVertexColor.shader
unity standard shader modified to display vertex colors
Shader "Custom/StandardSurfaceShaderWithVertexColor" {
Properties {
_MainTint("Global Color Tint", Color) = (1,1,1,1)
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert vertex:vert
@unitycoder
unitycoder / Matrix.hlsl
Created September 1, 2021 18:38 — forked from mattatz/Matrix.hlsl
Matrix operations for HLSL
#ifndef __MATRIX_INCLUDED__
#define __MATRIX_INCLUDED__
#define IDENTITY_MATRIX float4x4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
float4x4 inverse(float4x4 m) {
float n11 = m[0][0], n12 = m[1][0], n13 = m[2][0], n14 = m[3][0];
float n21 = m[0][1], n22 = m[1][1], n23 = m[2][1], n24 = m[3][1];
float n31 = m[0][2], n32 = m[1][2], n33 = m[2][2], n34 = m[3][2];
float n41 = m[0][3], n42 = m[1][3], n43 = m[2][3], n44 = m[3][3];
Shader "Test/SmoothZoomTexture"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
[KeywordEnum(Basic,Manual,Blend,Compare)]Mode("Mode", Int) = 0
_Blend("Blend", Range(0,1)) = 1
[Header(Mip Map)]
_MipMapMin("MipMap Min", Int) = 4
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
/// <summary>
/// A simple free camera to be added to a Unity game object.
///
/// Keys:
@unitycoder
unitycoder / BuildDisplayer.cs
Created August 4, 2021 10:35 — forked from llamacademy/BuildDisplayer.cs
Build Incrementor Scripts from https://www.youtube.com/watch?v=PbFE0m9UMtE. If you get value from LlamAcademy, consider becoming a Patreon supporter at https://www.patreon.com/llamacademy
using TMPro;
using UnityEngine;
[RequireComponent(typeof(TextMeshProUGUI))]
public class BuildDisplayer : MonoBehaviour
{
private TextMeshProUGUI Text;
private void Awake()
{
@unitycoder
unitycoder / ExtractTarGz.cs
Last active June 4, 2021 08:44 — forked from sruthi-kurup/ExtractTarGz.cs
Use pure C# to extract .tar and .tar.gz files (with hardcoded extract only these folders)
// source https://gist.github.com/Su-s/438be493ae692318c73e30367cbc5c2a
using System;
using System.IO;
using System.IO.Compression;
using System.Text;
namespace TarLib
{
public class Tar