Skip to content

Instantly share code, notes, and snippets.

View caiwan's full-sized avatar
🐺

Caiwan caiwan

🐺
View GitHub Profile
@caiwan
caiwan / stub.ahk
Created June 2, 2015 08:58
Autohotkey stub
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Description goez here
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; exit by typing 'qqq'
:*:qqq::
{
exitapp 0
}
@caiwan
caiwan / distantfunctions.inc.glsl
Last active November 13, 2017 21:22
Raymarch stuff
//http://iquilezles.org/www/articles/distfunctions/distfunctions.htm
// -- Distant functions
float sdPlane( vec3 p ) {return p.y+0.2;}
float sdSphere( vec3 p, float s ) {return length(p)-s;}
float sdCylinder( vec3 p, vec3 c ){ return length(p.xz-c.xy)-c.z; }
float udRoundBox( vec3 p, vec3 b, float r ){return length(max(abs(p)-b,0.0))-r;}
float udRoundBoxInf( vec3 p, vec2 b, float r ){return length(max(vec3(abs(p.xz)-b,0.0),0.0))-r;}
float maxcomp( vec3 p ) {return max(p.x,max(p.y,p.z));}
@caiwan
caiwan / loader.inc.cpp
Last active August 29, 2015 14:20
Farbrausch-like loaderbar in a single shader
namespace {
//works!
///@return 0 if everything succeeds 1 otherwise (or throw an exception)
int initLoader(){
this->loader.s_loader= new FWrender::Shader();
this->loader.s_loader->createFromMemory( /* create(&vss, &fss) */
"#version 330 core\n"
"layout(location = 0) in vec3 "SHADER_ATTRIB_VERTEX";"
"void main(){"
"gl_Position = vec4("SHADER_ATTRIB_VERTEX",1.);"
@caiwan
caiwan / colorspace.inc.glsl
Created May 8, 2015 10:42
2D Effect library of code snippets (Shadertoy:https://www.shadertoy.com/view/ldSXzt)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// *** COLOR TRANSFORMATION ***
//http://beesbuzz.biz/code/hsv_color_transforms.php
vec3 rgb2yiq(vec3 color){return color * mat3(0.299,0.587,0.114,0.596,-0.274,-0.321,0.211,-0.523,0.311);}
vec3 yiq2rgb(vec3 color){return color * mat3(1.,0.956,0.621,1,-0.272,-0.647,1.,-1.107,1.705);}
// Direkt HSV transzformacio
vec3 hsvTransform(vec3 color, vec3 hsv){float _h = hsv.x, _s = hsv.y, _v = hsv.y; float VSU = _v*_s*cos(_h*PI/180.), VSW = _v*_s*sin(_h*PI/180.), rr = (.299*_v+.701*VSU+.168*VSW)*color.x + (.587*_v-.587*VSU+.330*VSW)*color.y + (.114*_v-.114*VSU-.497*VSW)*color.z, gg = (.299*_v-.299*VSU-.328*VSW)*color.x + (.587*_v+.413*VSU+.035*VSW)*color.y + (.114*_v-.114*VSU+.292*VSW)*color.z, bb = (.299*_v-.300*VSU+1.25*VSW)*color.x + (.587*_v-.588*VSU-1.05*VSW)*color.y + (.114*_v+.886*VSU-.203*VSW)*color.z; return vec3(rr,gg,bb); }
vec4 packDepth(const in float depth) {
const vec4 bit_shift = vec4( 256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);
const vec4 bit_mask = vec4( 0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);
vec4 res = fract(depth * bit_shift);
res -= res.xxyz * bit_mask;
return res;
}
float unpackDepth(const in vec4 rgba_depth) {
const vec4 bit_shift = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);