Skip to content

Instantly share code, notes, and snippets.

View smkplus's full-sized avatar
😍
Curios

Seyed Morteza Kamali smkplus

😍
Curios
View GitHub Profile
@smkplus
smkplus / spriteGlitch.shader
Created April 20, 2017 15:14 — forked from KeyMaster-/spriteGlitch.shader
A glitch effect shader for Sprites in Unity3D
//Copyright (c) 2014 Tilman Schmidt (@KeyMaster_)
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//The above copyright notice and this permission notice shall be included in
@smkplus
smkplus / foo.md
Created July 25, 2017 17:40 — forked from aras-p/foo.md
Controlling fixed function states from materials/scripts in Unity

(typing off the top of my head, might not compile)

Since Unity 4.3:

In the shader, instead of writing Cull Off, write Cull [_MyCullVariable], the value will be fetched from the material or global float/int variable _MyCullVariable then.

You could have it be part of material, e.g. inside Properties block:

[Enum(Off,0,Front,1,Back,2)] _MyCullVariable ("Cull", Int) = 1
@smkplus
smkplus / VertexBlendMasked
Created August 4, 2017 06:57 — forked from Petethegoat/VertexBlendMasked
Shader for Unity that vertex blends two textures with a mask. Imperfect.
Shader "Custom/VertexBlendMaskedCleanEdges" {
Properties
{
_Over ("Over", 2D) = "white" {}
_Under ("Under", 2D) = "white" {}
_Mask ("Mask", 2D) = "white" {}
_Bias ("Edge Bias", Range(0.5, 30.0)) = 4.0
_Edge ("Edge Sharpness", Float) = 10.0
_Fall ("Blend Falloff", Float) = 1.0
}
@smkplus
smkplus / ImageEffectBase.shader
Created December 12, 2017 08:47 — forked from sugi-cho/ImageEffectBase.shader
use vertex shader in surface shader
Shader "Custom/ImageEffectBase" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
half4 _MainTex_TexelSize;
@smkplus
smkplus / UnityDiffuseLightmap.shader
Created April 19, 2018 17:04 — forked from jimfleming/UnityDiffuseLightmap.shader
Example depicting applying Unity lightmapping data to a simple diffuse shader.
Shader "Diffuse Lightmap" {
Properties {
_MainTex ("Texture 1", 2D) = "white" {}
}
SubShader {
Tags { "RenderType" = "Opaque" }
Pass {
Shader "Custom/Cook-Torrance" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_BumpMap("Normal Map", 2D) = "bump" {}
_Metallic("Metallic", Range(0,1)) = 0.5
_MetallicTex("Metallic", 2D) = "white" {}
_Roughness("Roughness", Range(0.000000001,1)) = 0.5
_RoughnessTex("Roughness", 2D) = "white" {}
_Fresnel("Fresnel Value", Float) = 0.028
@smkplus
smkplus / SimpleInkPaint.shader
Created April 18, 2019 18:13
Unity Simple Ink Paint Shader
Shader "Unlit/SimpleInkPaint"
{
Properties{
_MainTex("MainTex", 2D) = "white" // メインテクスチャ
_Brush("Brush", 2D) = "white" // ブラシテクスチャ
_BrushScale("BrushScale", FLOAT) = 0.1 // ブラシサイズ
_ControlColor("ControlColor", VECTOR) = (0, 0, 0, 0) // ブラシの色
_PaintUV("Hit UV Position", VECTOR) = (0, 0, 0, 0) // ブラシで塗りたい位置
}
@smkplus
smkplus / SimpleInkPaint.cs
Created April 18, 2019 18:14
Unity Simple Ink Paint Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------------
// simple ink paintスクリプト
// ColliderとRendererは必要
[RequireComponent(typeof(Renderer))]
[RequireComponent(typeof(Collider))]
public class SimpleInkPaint : MonoBehaviour {
@smkplus
smkplus / ConvertToSprite.cs
Last active August 3, 2019 08:24 — forked from nnm-t/ConvertToSprite.cs
Convert Texture2D To Sprite
using UnityEngine;
public static class SpriteExtensiton
{
/// <summary>
/// Convert Texture2D To Sprite
/// </summary>
/// <param name="texture"></param>
/// <returns></returns>
public static Sprite Texture2DToSprite(this Texture2D texture)
@smkplus
smkplus / Colors
Created October 25, 2019 06:20 — forked from louisvalet/Colors
I heard you needed colors
using UnityEngine;
public static class Colors
{
public static readonly Color AbsoluteZero = new Color32( 0, 72, 186, 255 );
public static readonly Color Acajou = new Color32( 76, 47, 39, 255 );
public static readonly Color AcidGreen = new Color32( 176, 191, 26, 255 );
public static readonly Color Aero = new Color32( 124, 185, 232, 255 );
public static readonly Color AeroBlue = new Color32( 201, 255, 229, 255 );
public static readonly Color AfricanViolet = new Color32( 178, 132, 190, 255 );