Skip to content

Instantly share code, notes, and snippets.

@ArieLeo
ArieLeo / gist:d202c947455961a33ebf
Created December 22, 2015 06:23 — forked from SeventySevian/gist:3977847
Unity Pixelated shader
Shader "Seventy Sevian/Pixelated"
{
Properties
{
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Color ("Color", Color) = (1, 1, 1, 1)
_PixelCountU ("Pixel Count U", float) = 100
_PixelCountV ("Pixel Count V", float) = 100
}
@ArieLeo
ArieLeo / glitter.shader
Created December 22, 2015 06:23 — forked from nicloay/glitter.shader
unity glitter shader
Shader "Custom/GlitterShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_NoiseSizeCoeff("_NoiseSizeCoeff (Bigger => larger glitter spots)", Float) = 0.61
_NoiseDensity("NoiseDensity (Bigger => larger glitter spots)", Float) = 53.0
}
SubShader
@ArieLeo
ArieLeo / pbs.txt
Created December 22, 2015 06:27 — forked from aras-p/pbs.txt
PBS surface shader
Shader "Custom/SurfaceStandard" {
Properties {
_Color("Color", Color) = (1,1,1)
_MainTex("Diffuse", 2D) = "white" {}
[NoScaleOffset] _SpecGlossMap("Specular", 2D) = "white" {}
[NoScaleOffset] _BumpMap("Normal Map", 2D) = "bump" {}
_BumpScale("Scale", Float) = 1.0
[NoScaleOffset] _Occlusion("Occlusion", 2D) = "white" {}
[NoScaleOffset] _EmissionMap("Emission", 2D) = "black" {}
}
@ArieLeo
ArieLeo / using_vpos.shader
Created December 22, 2015 06:27 — forked from aras-p/using_vpos.shader
Using VPOS
// yeah it's not terribly nice
Shader "Foo" {
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
@ArieLeo
ArieLeo / gist:49a83d9bbd74d0ddb1d9
Created December 22, 2015 06:28 — forked from aras-p/gist:dea83b8309a75554067c
sampling shadowmap without comparison on d3d11
// Problem is that by default SamplerComparisonState sampler is coupled with the shadowmap.
// So if you want to sample it regularly, you'll have to find a suitable sampler from another used texture.
// For example, let's say _MainTex has a suitable sampler (set to bilinear, whatever).
UNITY_DECLARE_TEX2D(_MainTex); // will declare Texture2D _MainTex and SamplerState sampler_MainTex
UNITY_DECLARE_SHADOWMAP(_Myshadow); // will declare Texture2D _Myshadow and SamplerComparisonState sampler_Myshadow
// sample as a shadowmap with comparison (all platforms)
float s = UNITY_SAMPLE_SHADOW_PROJ(_Myshadow, float4(xy,depth,1.0));
@ArieLeo
ArieLeo / UVTransform.shader
Created December 22, 2015 06:41 — forked from mattatz/UVTransform.shader
Example of uv transform shader for Unity.
Shader "Mattatz/UVTransform" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_TexScale ("Scale of Tex", Float) = 1.0
_TexRatio ("Ratio of Tex", Float) = 1.0
_Theta ("Rotation of Tex", Float) = 0.0
_PlaneScale ("Scale of Plane Mesh", Vector) = (1, 1, 0, 0)
}
@ArieLeo
ArieLeo / Billboard-CastShadow.shader
Created December 22, 2015 06:43 — forked from sugi-cho/Billboard-CastShadow.shader
ビルボードで、影を落とす、受ける、球。
Shader "Unlit/Billboard-CastShadow"
{
Properties
{
_DC ("diffuse", Color) = (0.5,0.5,0.5,1)
_SC ("Specular color (RGB), roughness (A)", Color) = (0.5,0.5,0.5,0.5)
_Size ("size", Float) = 1
}
CGINCLUDE
#define UNITY_PASS_SHADOWCASTER
@ArieLeo
ArieLeo / ViewPortToPos.shader
Created December 22, 2015 06:43 — forked from sugi-cho/ViewPortToPos.shader
クリップ座標系から、ワールド座標へ変換するやつ。理解を深めた http://www.songho.ca/opengl/gl_projectionmatrix.html
Shader "Unlit/ViewPortToPos"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_VP ("viewport position", Vector) = (0.5,0.5,1,0)
}
SubShader
{
Tags { "RenderType"="Opaque" }
@ArieLeo
ArieLeo / v2fStandard-Deferred.shader
Created December 22, 2015 06:44 — forked from sugi-cho/v2fStandard-Deferred.shader
Generateされた、standard shaderを要らないpassを削って使いやすくしたもの(deferred pass のみ)。 影をいじりたかったら、cast shadow のpassを追加する必要あり。vertexいじらなかったら、影は不自然じゃなく落とせる。
Shader "Custom/Generated-SurfDeferred" {
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
}
CGINCLUDE
#include "HLSLSupport.cginc"
using UnityEngine;
using UnityEditor;
using System.Collections;
public class CreateTex3D : EditorWindow
{
[MenuItem("sugi.cho/Window/CreatePerlin3DTexture")]
public static void Init ()
{
EditorWindow window = EditorWindow.GetWindow (typeof(CreateTex3D));