Skip to content

Instantly share code, notes, and snippets.

precision mediump float;
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
const float sphereSize = 1.0;
float distanceFunc(vec3 p){
return length(p) - sphereSize;
}
@doxas
doxas / 2.5kjuliaset.html
Last active August 29, 2015 14:06
glsl_asset_test
<!DOCTYPE html><meta charset="utf-8"><script id="fs" type="xs/fs">
precision mediump float; uniform float t; uniform vec2 r;
vec3 hsv(float h, float s, float v){
vec4 t = vec4(1., 2. / 3., 1. / 3., 3.);
vec3 p = abs(fract(vec3(h) + t.xyz) * 6. - vec3(t.w));
return v * mix(vec3(t.x), clamp(p - vec3(t.x), 0., 1.), s);}
void main(void){
vec2 x = vec2(-.345, .654); vec2 y = vec2(t * .005, 0.);
vec2 z = (gl_FragCoord.xy * 2. - r) / max(r.x, r.y); int j = 0;
for(int i = 0; i < 360; i++){j++; if(length(z) > 2.){break;}
@doxas
doxas / minify.html
Last active August 29, 2015 14:06
glsl_asset_minify
<!DOCTYPE html><meta charset="utf-8"><script id="fs" type="xs/fs">precision mediump float;uniform float t;uniform vec2 r;
// fragment shader code
</script><script id="vs" type="xs/vs">attribute vec3 position;void main(void){gl_Position=vec4(position,1.0);}</script><script>window.onload=function(){var a,b,c,d,e,f,g,p,t,u,v,w,x,y,z;b=function(s){return document.getElementById(s)};w=window;w.addEventListener('keydown',k,true);c=b('c');g=c.getContext('webgl');c.width=x=w.innerWidth;c.height=y=w.innerHeight;v=g.createShader(g.VERTEX_SHADER);g.shaderSource(v,b('vs').text);g.compileShader(v);f=g.createShader(g.FRAGMENT_SHADER);g.shaderSource(f,b('fs').text);g.compileShader(f);if(!g.getShaderParameter(v,g.COMPILE_STATUS)){alert(g.getShaderInfoLog(v));return;}if(!g.getShaderParameter(f,g.COMPILE_STATUS)){alert(g.getShaderInfoLog(f));return;}p=g.createProgram();g.attachShader(p,v);g.attachShader(p,f);g.linkProgram(p);if(!g.getProgramParameter(p,g.LINK_STATUS)){alert(g.getProgramInfoLog(p));return;}e=(p!=null);g.useProg
@doxas
doxas / gist:e9a3d006c7d19d2a0047
Created November 21, 2014 18:10
GLSL simple raytrace
<html><head><script src="script.js" type="text/javascript"></script><script id="fs" type="x-shader/x-fragment">precision mediump float;
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
// const ==========================================================================================
const vec3 cPos = vec3(0.0, 0.0, 3.0);
const vec3 cDir = vec3(0.0, 0.0, -1.0);
const vec3 cUp = vec3(0.0, 1.0, 0.0);
const float targetDepth = 1.0;
{
"name": "demo",
"version": "0.0.1",
"description": "demo",
"main": "build/index.html",
"dependencies": {},
"devDependencies": {
"browser-sync": "^2.3.1",
"gulp": "^3.8.11",
"gulp-concat": "^2.5.2",
// load plugin
var gulp = require('gulp'),
$ = require('gulp-load-plugins')({
pattern: ['gulp-*', 'gulp.*'],
replaceString: /\bgulp[\-.]/
}),
browserSync = require('browser-sync'),
runSequence = require('run-sequence');
// path string
function mouseMove(e) {
var cw = c.width;
var ch = c.height;
var wh = 1 / Math.sqrt(cw * cw + ch * ch);
var x = e.clientX - c.offsetLeft - cw * 0.5;
var y = e.clientY - c.offsetTop - ch * 0.5;
var sq = Math.sqrt(x * x + y * y);
var r = sq * 2.0 * Math.PI * wh;
if (sq != 1) {
sq = 1 / sq;
#define PI 3.14159265
float perlin(vec3 p){
vec3 i = floor(p);
vec4 a = dot(i, vec3(1.0, 57.0, 21.0)) + vec4(0.0, 57.0, 21.0, 78.0);
vec3 f = cos((p - i) * PI) * (-0.5) + 0.5;
a = mix(sin(cos(a) * a), sin(cos(1.0 + a) * (1.0 + a)), f.x);
a.xy = mix(a.xz, a.yw, f.y);
return mix(a.x, a.y, f.z);
}
function SimpleAjax(callBackFunction){
// private scope variable -------------------------------------------------
var response = '';
var tmp = this;
// property ---------------------------------------------------------------
this.h;
// method -----------------------------------------------------------------
// initialize for xmlhttprequest
log --graph --decorate=full --stat --oneline --remotes --branches -10