Skip to content

Instantly share code, notes, and snippets.

@cancinconn
cancinconn / metallicratiosearch.m
Last active January 26, 2018 05:07
MATLAB code to automate the search for a relation between the diagonals of regular polygons and the metallic ratios.
sideLength = 1;
differenceThreshold = 0; % show results that differ at most this much.
%differenceThreshold = 0.0000000001;
metallicCount = 1000000; % to be safe, make sure this is greater than sideLength * (the maximum value of n)
metallicRatios = zeros(1, metallicCount);
for ratioNumber = 1:metallicCount
metallicRatios(1, ratioNumber) = (ratioNumber + sqrt(4 + ratioNumber^2))/2;
@cancinconn
cancinconn / Pearlescent.shader
Last active March 10, 2024 19:13
An attempt at a basic pearlescent shader for Unity.
Shader "Custom/Pearlescent" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_ColorDirect("Indirect 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
_Iterations("Iridescence Function Iterations (Power)", Range(0,20)) = 5
}
SubShader {