Skip to content

Instantly share code, notes, and snippets.

View CharStiles's full-sized avatar

Char CharStiles

View GitHub Profile
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
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
// i copied and pasted these functions from the sticker sheet
// As t runs from 0 to 1 (our normalized palette index or domain),
//the cosine oscilates c times with a phase of d.
//The result is scaled and biased by a and b to meet the desired constrast and brightness.
// 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)
{
float smoothMod(float x, float y, float e){
float top = cos(PI * (x/y)) * sin(PI * (x/y));
float bot = pow(sin(PI * (x/y)),2.)+ pow(e, sin(time));
float at = atan(top/bot);
return y * (1./2.) - (1./PI) * at ;
}
void main () {
vec2 masterUV = uvN();
vec2 pos = masterUV;
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
// to see this function graphed out go to: https://www.desmos.com/calculator/rz7abjujdj
vec3 cosPalette( float t )
{
// please play around with these numbers to get a better palette
vec3 brightness = vec3(0.3);
vec3 contrast = vec3(0.5);
vec3 osc = vec3(0.5,1.0,0.0);
vec3 phase = vec3(0.4,0.9,0.2);
return brightness + contrast*cos( 6.28318*(osc*t+phase) );
}
// As t runs from 0 to 1 (our normalized palette index or domain),
//the cosine oscilates c times with a phase of d.
//The result is scaled and biased by a and b to meet the desired constrast and brightness.
// 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)
{
#version 150
// I made this using kodelife if you modify the inputs and outputs correctly it should translate to other programs as well
// things to look out for is all the uniforms, the input pixel position and the output pixel color
uniform float time;
uniform vec2 resolution;
uniform sampler2D prevPass;
in VertexData
{
void main () {
// we put the pixel coordinates in a variable for easy access
vec2 pos = uvN();
// here we get the webcam texture from channel0 which we assigned in the texture
// panel (the lil gradient icon)
// we use the pixel coordinates to grab the right pixel
vec4 web =texture2D(channel0,pos);
// here we just add the pixels postition as a color, just for fun
// http://www.iquilezles.org/www/articles/palettes/palettes.htm
// As t runs from 0 to 1 (our normalized palette index or domain),
//the cosine oscilates c times with a phase of d.
//The result is scaled and biased by a and b to meet the desired constrast and brightness.
vec3 cosPalette( float t, vec3 a, vec3 b, vec3 c, vec3 d )
{
return a + b*cos( 6.28318*(c*t+d) );
}
void main () {