Skip to content

Instantly share code, notes, and snippets.

View peeweek's full-sized avatar

Thomas Iché peeweek

View GitHub Profile
@t-mat
t-mat / mrr2.hlsl
Last active March 7, 2024 15:10
Martin Roberts' R2 sequence for dithering in HLSL
// Martin Roberts' R2 sequence in HLSL
// http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
namespace MRR2 {
float triangularWave(float x) {
return abs(0.5f - x) * -2.0f + 1.0f;
}
static const float a1 = (0.6180339887498948);
static const float2 a2 = float2(0.7548776662466927, 0.5698402909980532);
static const float3 a3 = float3(0.8191725133961644, 0.671043606703789, 0.5497004779019701);
@simonbroggi
simonbroggi / MainLightNode.hlsl
Last active June 7, 2025 09:59
Unity Shadergraph custom function node for main light data
#ifndef MAINLIGHT_INCLUDED
#define MAINLIGHT_INCLUDED
void GetMainLightData_float(out half3 direction, out half3 color, out half distanceAttenuation, out half shadowAttenuation)
{
#ifdef SHADERGRAPH_PREVIEW
// In Shader Graph Preview we will assume a default light direction and white color
direction = half3(-0.3, -0.8, 0.6);
color = half3(1, 1, 1);
distanceAttenuation = 1.0;
@smkplus
smkplus / UnityShaderCheatSheet.md
Last active October 22, 2024 12:19
Controlling fixed function states from materials/scripts in Unity

16999105_467532653370479_4085466863356780898_n

Shader "MaterialPropertyDrawer"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
 
[HideInInspector] _MainTex2("Hide Texture", 2D) = "white" {}
@arumoy
arumoy / OpenOtherAppFromUnityScript.cs
Created December 26, 2016 03:37
Open Other App From Unity C# Script - Android
public void OpenApp() {
string bundleId = "<App Package Name>"; // your target bundle id
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
//if the app is installed, no errors. Else, doesn't get past next line
AndroidJavaObject launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage",bundleId);
ca.Call("startActivity",launchIntent);