Skip to content

Instantly share code, notes, and snippets.

View noisecrime's full-sized avatar

NoiseCrime noisecrime

View GitHub Profile
@aras-p
aras-p / z.shader
Created January 8, 2015 13:31
View space Z shader
Shader "Aaa" {
SubShader {
Cull Off ZTest Always ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
@aras-p
aras-p / foo.md
Last active January 27, 2021 06:32
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
@aras-p
aras-p / using_vpos.shader
Last active February 3, 2018 12:39
Using VPOS
// yeah it's not terribly nice
Shader "Foo" {
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
Shader "GUI/Text Shader" {
Properties {
_MainTex ("Font Texture", 2D) = "white" {}
_Color ("Text Color", Color) = (1,1,1,1)
}
SubShader {
Tags {
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
@aras-p
aras-p / gist:d345e7292b62e7844508
Created August 21, 2014 12:28
mecanim per animation speed
Here's what the animation folks say:
"There is a speed per node in blend tree editor"
Now, if you need to change these speeds at runtime, then that feature is on their roadmap; for now you could do a workaround:
1. create a blend tree with 2 times the same clip
2. with different speeds (set in the editor)
3. then at runtime change the blend parameter of that blend tree; it will control the speed of the clip at runtime
@aras-p
aras-p / gist:ac4339c040afabea6ee7
Created August 18, 2014 09:13
fog macros WIP
// ------------------------------------------------------------------
// Fog helpers
//
// multi_compile_fog Will compile fog variants.
// UNITY_FOG_COORDS(texcoordindex) Declares the fog data interpolator.
// UNITY_TRANSFER_FOG(outputStruct,clipspacePos) Outputs fog data from the vertex shader.
// UNITY_APPLY_FOG(fogData,col) Applies fog to color "col". Automatically applies black fog when in forward-additive pass.
// Can also use UNITY_APPLY_FOG_COLOR to supply your own fog color.
// In case someone by accident tries to compile fog code in one of the g-buffer or shadow passes:
@aras-p
aras-p / gist:dea83b8309a75554067c
Created August 13, 2014 09:37
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));
using System.Collections.Generic;
using System.Reflection;
namespace UnityEngine.EventSystems
{
[AddComponentMenu("Event/Standalone Input Module")]
public class StandaloneInputModule : PointerInputModule
{
private float m_NextAction;
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active April 10, 2025 02:30
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@stramit
stramit / CoroutineTween.cs
Last active August 16, 2016 23:34
CoroutineTween.cs
/*
* This code is provided as is without warranty, guarantee of function,
* or provided support
*/
using System.Collections;
using UnityEngine.Events;
namespace UnityEngine.UI.CoroutineTween
{