Skip to content

Instantly share code, notes, and snippets.

View mattatz's full-sized avatar
👁️‍🗨️
Yes

mattatz mattatz

👁️‍🗨️
Yes
View GitHub Profile
@mattatz
mattatz / StencilSample.shader
Created January 8, 2015 03:28
Example of stencil shader to draw a simple outline for Unity.
Shader "Mattatz/StencilSample" {
Properties {
_Outline ("Outline Length", Range(0.0, 1.0)) = 0.2
_Color ("Color", Color) = (0.8, 0.8, 0.8, 1.0)
_OutlineColor ("Outline Color", Color) = (0.2, 0.2, 0.2, 1.0)
}
@mattatz
mattatz / Cone.cs
Last active March 15, 2022 23:53
Example of a cone mesh creator for Unity.
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (MeshFilter))]
public class Corn : MonoBehaviour {
public int subdivisions = 10;
public float radius = 1f;
public float height = 2f;
@mattatz
mattatz / UVTransform.shader
Created April 6, 2015 02:28
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)
}
@mattatz
mattatz / SobelFilter.shader
Last active January 19, 2024 10:41
Sobel filter shader for Unity.
Shader "Mattatz/SobelFilter" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_DeltaX ("Delta X", Float) = 0.01
_DeltaY ("Delta Y", Float) = 0.01
}
SubShader {
Tags { "RenderType"="Opaque" }
@mattatz
mattatz / LIC.shader
Last active April 3, 2022 14:09
Simple Line Integral Convolution shader for Unity.
Shader "Mattaz/LIC" {
Properties {
_VectorFieldTex ("Vector Field Texture", 2D) = "white" {}
_NoiseTex ("Noise Texture", 2D) = "white" {}
_FlowLength ("Flow Length", int) = 10
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
@mattatz
mattatz / Bezel.shader
Created October 9, 2015 03:00
Post effect shader for Unity : In multiple displays environment, this effect removes display's bezel area.
Shader "PostEffect/Bezel"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_HorizontalCount ("Horizontal Screen Count", Int) = 7
_VerticalCount ("Vertical Screen Count", Int) = 2
_Bezel ("Bezel Size", Vector) = (0.01, 0.01, -1, -1)
@mattatz
mattatz / BitwiseOperations.glsl
Created November 13, 2015 06:46
Bitwise operations without operators for glsl.
// BitwiseOperations.glsl
const int BIT_COUNT = 8;
int modi(int x, int y) {
return x - y * (x / y);
}
int or(int a, int b) {
int result = 0;
@mattatz
mattatz / LabColorspace.cginc
Created November 25, 2015 05:35
Conversion between RGB and LAB colorspace shader for Unity.
#ifndef __LAB_COLORSPACE__
#define __LAB_COLORSPACE__
/*
* Conversion between RGB and LAB colorspace.
* Import from flowabs glsl program : https://code.google.com/p/flowabs/source/browse/glsl/?r=f36cbdcf7790a28d90f09e2cf89ec9a64911f138
*/
float3 rgb2xyz( float3 c ) {
float3 tmp;
@mattatz
mattatz / TextureAnimation.shader
Last active March 28, 2024 22:37
Texture animation shader for Unity.
Shader "Mattatz/TextureAnimation"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Color ("Color", Color) = (1, 1, 1, 1)
_Cols ("Cols Count", Int) = 5
_Rows ("Rows Count", Int) = 3
_Frame ("Per Frame Length", Float) = 0.5
@mattatz
mattatz / RandomPointOnMesh.cs
Created December 25, 2015 08:22
Sample a point randomly on a given mesh script for Unity.
using UnityEngine;
using System.Collections;
namespace Utils {
public class RandomPointOnMesh {
public static Vector3 Sample (Mesh mesh) {
int[] triangles = mesh.triangles;
int index = Mathf.FloorToInt(Random.value * (triangles.Length / 3));