Skip to content

Instantly share code, notes, and snippets.

View CharStiles's full-sized avatar

Char CharStiles

View GitHub Profile
#!/bin/bash
# Function to generate a random hex color
generate_random_color() {
printf "%06x\n" $((RANDOM%16777215))
}
# Set the desktop directory
desktop_dir="$HOME/Desktop"
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_vol;
// i copied and pasted these functions from the sticker sheet
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_vol;
// http://www.iquilezles.org/www/articles/palettes/palettes.htm
// to see this function graphed out go to: https://www.desmos.com/calculator/rz7abjujdj
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_vol;
void main() {
// http://www.iquilezles.org/www/articles/palettes/palettes.htm
// to see this function graphed out go to: https://www.desmos.com/calculator/18rq4ybrru
vec3 cosPalette( float t , vec3 brightness, vec3 contrast, vec3 osc, vec3 phase)
{
return brightness + contrast*cos( 6.28318*(osc*t+phase) );
}
// Repeat around the origin by a fixed angle.
// For easier use, num of repetitions is use to specify the angle.
// http://www.iquilezles.org/www/articles/palettes/palettes.htm
// to see this function graphed out go to: https://www.desmos.com/calculator/rz7abjujdj
vec3 cosPalette( float t , vec3 brightness, vec3 contrast, vec3 osc, vec3 phase)
{
return brightness + contrast*cos( 6.28318*(osc*t+phase) );
}
void main() {
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_vol;
#define PI 3.14
uniform sampler2D midi;
vec2 midiCoord(float offset)
{
float x = mod(offset,32.);
float y = offset / 32.;
return vec2(x,y)/32.;
}
float getMidi(float number){
@CharStiles
CharStiles / unityStickerSheet.shader
Created October 5, 2021 21:57
Unity shader sticker sheet
// Tips for converting GLSL functions to Unity functions
// vec turn into float (usually massive comand all replace works)
// fract -> frac
// mod -> modf
// time, iTime, u_Time -> _Time.y
float3 hsv2rgb(float3 c) {
c = float3(c.x, clamp(c.yz, 0.0, 1.0));
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
Shader "Custom/swirl"
{
Properties
{
_Color ("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
}
SubShader