Add lime-tools as dependency, move /examples to /samples for consistency, update HerokuShaders and SimpleOpenGL samples

This commit is contained in:
Joshua Granick
2013-12-17 16:44:21 -08:00
parent c1d558073c
commit 7306ef8d36
65 changed files with 2154 additions and 2462 deletions

View File

@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<meta
title="lime example - HerokuShaders"
package="com.limeframework.limeexampleherokushaders"
version="1.0.0"
company="limeframework"
/>
<app main="Main" path="bin" file="lime_example_herokushaders" />
<window
width="960"
height="640"
orientation="landscape"
fps="60"
resizable="true"
/>
<assets path="Assets" rename="assets" include="*"/>
<source path="src" />
<haxelib name="lime" />
</project>

View File

@@ -1,330 +0,0 @@
//Ported and modified from OpenFL examples
//underscorediscovery
import lime.utils.Assets;
import lime.Lime;
//Import GL stuff from Lime
import lime.gl.GL;
import lime.gl.GLBuffer;
import lime.gl.GLProgram;
import lime.gl.GLShader;
//utils
import lime.utils.Float32Array;
import lime.geometry.Matrix3D;
import lime.InputHandler.MouseEvent;
//import the shader code for the examples
//todo : Port to assets like latest openfl example
import shaders.FragmentShader_4278_1;
import shaders.FragmentShader_5359_8;
import shaders.FragmentShader_5398_8;
import shaders.FragmentShader_5454_21;
import shaders.FragmentShader_5492;
import shaders.FragmentShader_5733;
import shaders.FragmentShader_5805_18;
import shaders.FragmentShader_5812;
import shaders.FragmentShader_5891_5;
import shaders.FragmentShader_6022;
import shaders.FragmentShader_6043_1;
import shaders.FragmentShader_6049;
import shaders.FragmentShader_6147_1;
import shaders.FragmentShader_6162;
import shaders.FragmentShader_6175;
import shaders.FragmentShader_6223_2;
import shaders.FragmentShader_6238;
import shaders.FragmentShader_6284_1;
import shaders.FragmentShader_6286;
import shaders.FragmentShader_6288_1;
import shaders.VertexShader;
class Main {
public var lib : Lime;
//A bunch of these shaders are expensive so for most users this is
//is a bad idea to just abuse their system when they run the sample.
//You can set the below value to true to see them though.
public var include_slow_expensive_examples : Bool = false;
public var slow_end_index : Int = 6;
private var mouse_x : Int = 0;
private var mouse_y : Int = 0;
//The maximum time to spend on a shader example before cycling
//We start really quickly,
//a) because we want to make sure the user knows there are more than 1 and
//b) because the first index is fixed, but the randomness can pick a new one
private static var maxTime = 2;
//The current active shader example in the list
private var currentIndex:Int;
//The OpenGL values
private var buffer:GLBuffer;
private var currentProgram:GLProgram;
private var positionAttribute:Dynamic;
private var timeUniform:Dynamic;
private var mouseUniform:Dynamic;
private var resolutionUniform:Dynamic;
private var backbufferUniform:Dynamic;
private var surfaceSizeUniform:Dynamic;
private var startTime:Dynamic;
private var vertexPosition:Dynamic;
public function new() {}
//Ready is called by lime when it has created the window etc.
//We can start using GL here.
public function ready( _lime : Lime ) {
//Store a reference, in case we want it
lib = _lime;
// Init the shaders and view
init();
} //ready
public function init() {
//Find the starting index
currentIndex = (include_slow_expensive_examples ? 0 : slow_end_index);
//Create a vertex buffer, for a Quad, bind it and submit it once using STATIC draw so it stays in GPU
buffer = GL.createBuffer();
GL.bindBuffer(GL.ARRAY_BUFFER, buffer);
GL.bufferData(GL.ARRAY_BUFFER, new Float32Array ([ -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0 ]), GL.STATIC_DRAW);
//start the mouse center screen
//lime stores the window size in it's config (as well as other window options)
mouse_x = Std.int(lib.config.width/2);
mouse_y = Std.int(lib.config.height/2);
//Compile the shader selected
compile();
} //init
//lime will call this when the mouse moves, so we can get a position
public function onmousemove( e:MouseEvent ) {
mouse_x = Std.int(e.x);
mouse_y = Std.int(e.y);
} //onmousemove
//we also set this on mouse down, so mobile has some interactivity (could also use ontouchdown)
public function onmousedown( e:MouseEvent ) {
mouse_x = Std.int(e.x);
mouse_y = Std.int(e.y);
} //onmousedown
//called each frame by lime for logic (called before render)
public function update() {
//check if we have passed the max time for watching this shader
var time = haxe.Timer.stamp() - startTime;
if (time > maxTime && fragmentShaders.length > 1) {
//Pick a random example to show
#if !mobile
if( include_slow_expensive_examples ) {
currentIndex = Std.random( fragmentShaders.length - 1 );
} else {
currentIndex = slow_end_index + Std.random( (fragmentShaders.length - slow_end_index - 1) );
}
#else
currentIndex = Std.random( fragmentShaders.length - 1 );
#end
//recompile using this index
compile();
//switch time if after the first one
if(maxTime == 2) maxTime = 10;
} //if time is passed max time
} //update
//Called each frame by lime, when the window wants to render
public function render() {
//Set the viewport to the config window size
GL.viewport( 0, 0, lib.config.width, lib.config.height );
//If the shader failed to link or compile we don't render yet
if (currentProgram == null) return;
//The current time is the time since the last shader started, and now
var time = haxe.Timer.stamp() - startTime;
//Activate the current shader
GL.useProgram(currentProgram);
//Pass the attributes to the shaders
GL.uniform1f( timeUniform, time );
GL.uniform2f( mouseUniform, (mouse_x / lib.config.width) * 2 - 1, (mouse_y / lib.config.height) * 2 - 1 );
GL.uniform2f( resolutionUniform, lib.config.width, lib.config.height );
GL.uniform1i( backbufferUniform, 0 );
GL.uniform2f( surfaceSizeUniform, lib.config.width, lib.config.height );
//Point to the buffer we created earlier to draw
GL.bindBuffer( GL.ARRAY_BUFFER, buffer );
GL.vertexAttribPointer( positionAttribute, 2, GL.FLOAT, false, 0, 0 );
GL.vertexAttribPointer( vertexPosition, 2, GL.FLOAT, false, 0, 0 );
//Clear the screen
GL.clearColor(0, 0, 0, 1);
GL.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT );
//And finally draw the quad!
GL.drawArrays (GL.TRIANGLES, 0, 6);
} //render
private function compile ():Void {
var program = GL.createProgram ();
var vertex = VertexShader.source;
//When on web specifically we prefix the shader with a required precision qualifier
#if desktop
var fragment = "";
#else
var fragment = "precision mediump float;";
#end
fragment += fragmentShaders[currentIndex].source;
var vs = createShader(vertex, GL.VERTEX_SHADER);
var fs = createShader(fragment, GL.FRAGMENT_SHADER);
//Woops, this didn't compile so jump out
//todo : Add compiler logs.
if (vs == null || fs == null) {
return;
}
//Attach the shaders to the program
GL.attachShader(program, vs);
GL.attachShader(program, fs);
//Clean up unnecessary shader references (they are stored by index in the Program)
GL.deleteShader(vs);
GL.deleteShader(fs);
//Link the program on the GPU
GL.linkProgram (program);
//Check if linking was good
if (GL.getProgramParameter (program, GL.LINK_STATUS) == 0) {
trace( GL.getProgramInfoLog(program) );
trace( "VALIDATE_STATUS: " + GL.getProgramParameter (program, GL.VALIDATE_STATUS));
trace( "ERROR: " + GL.getError() );
return;
} //GL.LINK_STATUS == 0
//If we had an existing program? Clean up
if (currentProgram != null) {
GL.deleteProgram (currentProgram);
}
//Store the new program
currentProgram = program;
//Activate the new program
GL.useProgram(currentProgram);
//Make sure that the attributes are referenced correctly
positionAttribute = GL.getAttribLocation(currentProgram, "surfacePosAttrib");
vertexPosition = GL.getAttribLocation (currentProgram, "position");
//As well as enabled
GL.enableVertexAttribArray (vertexPosition);
GL.enableVertexAttribArray(positionAttribute);
//And for the uniforms, we store their location because it can change per shader
timeUniform = GL.getUniformLocation(program, "time");
mouseUniform = GL.getUniformLocation(program, "mouse");
resolutionUniform = GL.getUniformLocation(program, "resolution");
backbufferUniform = GL.getUniformLocation(program, "backbuffer");
surfaceSizeUniform = GL.getUniformLocation(program, "surfaceSize");
//So that we can calculate the new shader running time
startTime = haxe.Timer.stamp();
} //compile
//Take a source shader, compile it, check for errors and return the GLShader
private function createShader( source:String, type:Int ) : GLShader {
var shader = GL.createShader (type);
GL.shaderSource(shader, source);
GL.compileShader(shader);
if (GL.getShaderParameter(shader, GL.COMPILE_STATUS) == 0) {
return null;
}
return shader;
} //createShader
#if !mobile
//The list of shaders to cycle through
private static var fragmentShaders:Array<Dynamic> = [
//These are the more expensive ones, excluded by default
FragmentShader_6223_2,
FragmentShader_6175,
FragmentShader_6162,
FragmentShader_6049,
FragmentShader_5359_8,
FragmentShader_4278_1,
//These are the ok ones
FragmentShader_6286,
FragmentShader_6288_1,
FragmentShader_6284_1,
FragmentShader_6238,
FragmentShader_6147_1,
FragmentShader_6043_1,
FragmentShader_6022,
FragmentShader_5891_5,
FragmentShader_5805_18,
FragmentShader_5812,
FragmentShader_5733,
FragmentShader_5454_21,
FragmentShader_5492,
FragmentShader_5398_8
];
#else //!mobile
//These are mobile ones
private static var fragmentShaders:Array<Dynamic> = [
FragmentShader_6284_1,
FragmentShader_6238,
FragmentShader_6147_1,
FragmentShader_5891_5,
FragmentShader_5805_18,
FragmentShader_5492,
FragmentShader_5398_8
];
#end //if !mobile
} //Main class

View File

@@ -1,98 +0,0 @@
package shaders;
class FragmentShader_4278_1 {
//http://glsl.heroku.com/e#4278.1
public static var source = "
uniform float time;
uniform vec2 resolution;
uniform vec2 mouse;
mat3 genRotMat(float a0,float x,float y,float z){
float a=a0*3.1415926535897932384626433832795/180.0;
return mat3(
1.0+(1.0-cos(a))*(x*x-1.0),
-z*sin(a)+(1.0-cos(a))*x*y,
y*sin(a)+(1.0-cos(a))*x*z,
z*sin(a)+(1.0-cos(a))*x*y,
1.0+(1.0-cos(a))*(y*y-1.0),
-x*sin(a)+(1.0-cos(a))*y*z,
-y*sin(a)+(1.0-cos(a))*x*z,
x*sin(a)+(1.0-cos(a))*y*z,
1.0+(1.0-cos(a))*(z*z-1.0)
);
}
float cubeDist(vec3 p){
return max(abs(p.x),max(abs(p.y),abs(p.z)));
}
void main(){
float spread=1.0;
float total=0.0;
float delta=0.01;
float cameraZ=-1.75;
float nearZ=-1.0;
float farZ=1.0;
float gs=0.0;
int iter=0;
vec3 col=vec3(0.0,0.0,0.0);
vec3 ray=vec3(0.0,0.0,0.0);
mat3 rot=genRotMat(sin(time/4.13)*360.0,1.0,0.0,0.0);
rot=rot*genRotMat(sin(time/4.64)*360.0,0.0,1.0,0.0);
rot=rot*genRotMat(sin(time/4.24)*360.0,0.0,0.0,1.0);
vec2 p=vec2(0.0,0.0);
p.x=gl_FragCoord.x/resolution.y-0.5*resolution.x/resolution.y;
p.y=gl_FragCoord.y/resolution.y-0.5;
ray.xy+=p.xy*spread*(nearZ-cameraZ);
vec3 rayDir=vec3(spread*p.xy*delta,delta);
vec3 tempDir=rayDir*rot;
vec3 norm;
ray.z=nearZ;
bool refracted=false;
for(int i=0;i<250;i++){
vec3 temp;
vec3 tempc;
float val;
temp=ray.xyz*rot;
tempc=temp;
float thres=0.5;
if(tempc.x<0.0)tempc.x=abs(tempc.x);
if(tempc.x<thres)tempc.x=0.0;
else tempc.x=1.0/tempc.x*sin(time);
if(tempc.y<0.0)tempc.y=abs(tempc.y);
if(tempc.y<thres)tempc.y=0.0;
else tempc.y=1.0/tempc.y*sin(time*0.842);
if(tempc.z<0.0)tempc.z=abs(tempc.z);
if(tempc.z<thres)tempc.z=0.0;
else tempc.z=1.0/tempc.z*sin(time*1.132);
val=cubeDist(temp);
if(val<thres && !refracted){
rayDir=vec3(0.5*spread*p.xy*delta,delta);
refracted=true;
}
if(val<0.0)val=abs(val);
if(val<thres)val=0.0;
else val=1.0/val;
col.x+=(val+tempc.x)/2.0;
col.y+=(val+tempc.y)/2.0;
col.z+=(val+tempc.z)/2.0;
ray+=rayDir;
iter++;
if(ray.z>=farZ)break;
}
col.x=col.x/float(iter);
col.y=col.y/float(iter);
col.z=col.z/float(iter);
gl_FragColor=vec4(col,1.0);
}
";
}

View File

@@ -1,146 +0,0 @@
package shaders;
class FragmentShader_5359_8 {
//http://glsl.heroku.com/e#5359.8
public static var source = "
uniform float time;
uniform vec2 resolution;
// NEBULA - CoffeeBreakStudios.com (CBS)
// Work in progress....
//
// 3148.26: Switched from classic to simplex noise
// 3148.27: Reduced number of stars
// 3249.0: Switched to fast computed 3D noise. Less quality but ~ 2x faster
// 3249.5: Removed use of random number generator to gain performance
// 3265.0: Added rotation: glsl.heroku.com/e#3005.1
// 3265.6: Faster random number generator
// 5359.0: Added Barrel distortion and different starfield: http://glsl.heroku.com/e#5334.3
//Utility functions
vec3 fade(vec3 t) {
return vec3(1.0,1.0,1.0);
}
vec2 rotate(vec2 point, float rads) {
float cs = cos(rads);
float sn = sin(rads);
return point * mat2(cs, -sn, sn, cs);
}
vec4 randomizer4(const vec4 x)
{
vec4 z = mod(x, vec4(5612.0));
z = mod(z, vec4(3.1415927 * 2.0));
return(fract(cos(z) * vec4(56812.5453)));
}
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
// Fast computed noise
// http://www.gamedev.net/topic/502913-fast-computed-noise/
const float A = 1.0;
const float B = 57.0;
const float C = 113.0;
const vec3 ABC = vec3(A, B, C);
const vec4 A3 = vec4(0, B, C, C+B);
const vec4 A4 = vec4(A, A+B, C+A, C+A+B);
float cnoise4(const in vec3 xx)
{
vec3 x = mod(xx + 32768.0, 65536.0);
vec3 ix = floor(x);
vec3 fx = fract(x);
vec3 wx = fx*fx*(3.0-2.0*fx);
float nn = dot(ix, ABC);
vec4 N1 = nn + A3;
vec4 N2 = nn + A4;
vec4 R1 = randomizer4(N1);
vec4 R2 = randomizer4(N2);
vec4 R = mix(R1, R2, wx.x);
float re = mix(mix(R.x, R.y, wx.y), mix(R.z, R.w, wx.y), wx.z);
return 1.0 - 2.0 * re;
}
float surface3 ( vec3 coord, float frequency ) {
float n = 0.0;
n += 1.0 * abs( cnoise4( coord * frequency ) );
n += 0.5 * abs( cnoise4( coord * frequency * 2.0 ) );
n += 0.25 * abs( cnoise4( coord * frequency * 4.0 ) );
n += 0.125 * abs( cnoise4( coord * frequency * 8.0 ) );
n += 0.0625 * abs( cnoise4( coord * frequency * 16.0 ) );
return n;
}
vec2 barrelDistortion(vec2 coord) {
vec2 cc = coord;// - 0.5;
float dist = dot(cc, cc);
return coord + cc * (dist * dist) * .4;
}
void main( void ) {
float rads = radians(time*3.15);
//vec2 position = gl_FragCoord.xy / resolution.xy;
vec2 position=barrelDistortion(-1.0+2.0*((gl_FragCoord.xy)/resolution.xy));
vec2 positionStars = ( gl_FragCoord.xy - resolution.xy*.5 ) / resolution.x;
position += rotate(position, rads);
float n = surface3(vec3(position*sin(time*0.1), time * 0.05)*mat3(1,sin(1.0),0,0,.8,.6,0,-.6,.8),0.9);
float n2 = surface3(vec3(position*cos(time*0.1), time * 0.04)*mat3(1,cos(1.0),0,0,.8,.6,0,-.6,.8),0.8);
float lum = length(n);
float lum2 = length(n2);
vec3 tc = pow(vec3(1.0-lum),vec3(sin(position.x)+cos(time)+4.0,8.0+sin(time)+4.0,8.0));
vec3 tc2 = pow(vec3(1.1-lum2),vec3(5.0,position.y+cos(time)+7.0,sin(position.x)+sin(time)+2.0));
vec3 curr_color = (tc*0.8) + (tc2*0.5);
// 256 angle steps
float angle = atan(positionStars.y,positionStars.x)/(2.*3.14159265359);
angle += rads*0.5;
angle -= floor(angle);
float rad = length(positionStars);
float color = 0.0;
for (int i = 0; i < 10; i++) {
float angleFract = fract(angle*256.);
float angleRnd = floor(angle*256.)+1.;
float angleRnd1 = fract(angleRnd*fract(angleRnd*.7235)*45.1);
float angleRnd2 = fract(angleRnd*fract(angleRnd*.82657)*13.724);
float t = time+angleRnd1*10.;
float radDist = sqrt(angleRnd2+float(i));
float adist = radDist/rad*.1;
float dist = (t*.1+adist);
dist = abs(fract(dist)-.5);
color += max(0.,.5-dist*40./adist)*(.5-abs(angleFract-.5))*5./adist/radDist;
angle = fract(angle+.61);
}
float color1 = color*rad;
//curr_color += color/(n+n2);
gl_FragColor = vec4(curr_color, 1.0)+vec4( color1,color1,color,color1)/(n+n2);
}
";
}

View File

@@ -1,44 +0,0 @@
package shaders;
class FragmentShader_5398_8 {
//http://glsl.heroku.com/e#5398.8
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
void main( void ) {
float scale = resolution.y / 100.0;
float ring = 50.0;
float radius = resolution.x*1.0;
float gap = scale*.5;
vec2 pos = gl_FragCoord.xy - resolution.xy*.5;
float d = length(pos);
// Create the wiggle
d += (sin(pos.y*0.25/scale+time)*sin(pos.x*0.25/scale+time*.5))*scale*2.0;
// Compute the distance to the closest ring
float v = mod(d + radius/(ring*2.0), radius/ring);
v = abs(v - radius/(ring*2.0));
v = clamp(v-gap, 0.0, 1.0);
d /= radius;
vec3 m = fract((d-1.0)*vec3(ring*-.5, -ring, ring*.25)*0.5);
gl_FragColor = vec4( m*v, 1.0 );
}
";
}

View File

@@ -1,141 +0,0 @@
package shaders;
class FragmentShader_5454_21 {
//http://glsl.heroku.com/e#5454.21
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
// from http://glsl.heroku.com/e#5484.0
vec3 asteroids( vec2 position ) {
// 256 angle steps
float angle = atan(position.y,position.x)/(2.*3.14159265359);
angle -= floor(angle);
float rad = length(position);
float color = 0.0;
for (int i = 0; i < 5; i++) {
float angleFract = fract(angle*256.);
float angleRnd = floor(angle*256.)+1.;
float angleRnd1 = fract(angleRnd*fract(angleRnd*.7235)*45.1);
float angleRnd2 = fract(angleRnd*fract(angleRnd*.82657)*13.724);
float t = -time+angleRnd1*10.;
float radDist = sqrt(angleRnd2+float(i));
float adist = radDist/rad*.1;
float dist = (t*.1+adist);
dist = abs(fract(dist)-.5);
color += max(0.,.5-dist*40./adist)*(.5-abs(angleFract-.5))*5./adist/radDist;
angle = fract(angle+.61);
}
return vec3( color )*.3;
}
// from http://glsl.heroku.com/e#5248.0
#define BIAS 0.1
#define SHARPNESS 3.0
vec3 star(vec2 position, float BLADES) {
float blade = clamp(pow(sin(atan(position.y,position.x )*BLADES)+BIAS, SHARPNESS), 0.0, 1.0);
vec3 color = mix(vec3(-0.34, -0.5, -1.0), vec3(0.0, -0.5, -1.0), (position.y + 1.0) * 0.25);
float d = 1.0/length(position) * 0.075;
color += vec3(0.95, 0.65, 0.30) * d;
color += vec3(0.95, 0.45, 0.30) * min(1.0, blade *0.7) * d;
return color;
}
vec3 star2(vec2 position, float BLADES) {
float blade = clamp(pow(sin(atan(position.y,position.x )*BLADES + time*.5)+BIAS, 8.0), 0.0, 1.0);
vec3 color = mix(vec3(-0.34, -0.5, -0.0), vec3(0.0, -0.5, -0.0), (position.y + 1.0) * 0.25);
float d = 1.0/length(position) * 0.075;
color += vec3(0.95, 0.65, 0.30) * d;
color += vec3(0.95, 0.45, 0.30) * min(1.0, blade *0.7)*0.5;
return max(color.rgb, 0.0)*.5;
}
// Tweaked from http://glsl.heroku.com/e#4982.0
float hash( float n ) { return fract(sin(n)*43758.5453); }
float noise( in vec2 x )
{
vec2 p = floor(x);
vec2 f = fract(x);
f = f*f*(3.0-2.0*f);
float n = p.x + p.y*57.0;
float res = mix(mix(hash(n+0.0), hash(n+1.0),f.x), mix(hash(n+57.0), hash(n+58.0),f.x),f.y);
return res;
}
vec3 cloud(vec2 p) {
vec3 f = vec3(0.0);
f += 0.5000*noise(p*10.0)*vec3(.45, .55, 1.0);
f += 0.2500*noise(p*20.0)*vec3(.85, .45, 1.0);
f += 0.1250*noise(p*40.0)*vec3(1.0, .00, 0.3);
f += 0.0625*noise(p*80.0)*vec3(1.0, 1.0, 1.0);
return f*.5;
}
const float SPEED = 0.005;
const float SCALE = 80.0;
const float DENSITY = 1.5;
const float BRIGHTNESS = 10.0;
vec2 ORIGIN = resolution.xy*.5;
float rand(vec2 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); }
vec3 layer(float i, vec2 pos, float dist, vec2 coord) {
float a = pow((1.0-dist),20.0);
float t = i*10.0 - time*i*i;
float r = coord.x - (t*SPEED);
float c = fract(a+coord.y + i*.543);
vec2 p = vec2(r, c*.5)*SCALE*(4.0/(i*i));
vec2 uv = fract(p)*2.0-1.0;
float m = clamp((rand(floor(p))-DENSITY/i)*BRIGHTNESS, 0.0, 1.0);
return clamp(star(uv*.5, 6.0)*m*dist, 0.0, 1.0);
}
void main( void ) {
vec2 pos = gl_FragCoord.xy - ORIGIN ;
float dist = length(pos) / resolution.y;
vec2 coord = vec2(pow(dist, 0.1), atan(pos.x, pos.y) / (3.1415926*2.0));
// Nebulous cloud
vec3 color = cloud(pos/resolution);
// Background stars
float a = pow((1.0-dist),20.0);
float t = time*-.05;
float r = coord.x - (t*0.005);
float c = fract(a+coord.y + 0.0*.543);
vec2 p = vec2(r, c*.5)*4000.0;
vec2 uv = fract(p)*2.0-1.0;
float m = clamp((rand(floor(p))-.9)*10.0, 0.0, 1.0);
color += clamp((1.0-length(uv*2.0))*m*dist, 0.0, 1.0);
color += asteroids(pos/resolution.x);
// Flying stars into black hole
color += layer(2.0, pos, dist, coord);
color += layer(3.0, pos, dist, coord);
color += layer(4.0, pos, dist, coord);
color += star2(pos/resolution, 2.0);
gl_FragColor = vec4(color, 1.0);
}
";
}

View File

@@ -1,140 +0,0 @@
package shaders;
class FragmentShader_5492 {
//http://glsl.heroku.com/e#5492.0
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
// Helper constants
#define F2 0.366025403
#define G2 0.211324865
#define K 0.0243902439 // 1/41
// Permutation polynomial
float permute(float x) {
return mod((34.0 * x + 1.0)*x, 289.0);
}
// Gradient mapping with an extra rotation.
vec2 grad2(vec2 p, float rot) {
#if 1
// Map from a line to a diamond such that a shift maps to a rotation.
float u = permute(permute(p.x) + p.y) * K + rot; // Rotate by shift
u = 4.0 * fract(u) - 2.0;
return vec2(abs(u)-1.0, abs(abs(u+1.0)-2.0)-1.0);
#else
#define TWOPI 6.28318530718
// For more isotropic gradients, sin/cos can be used instead.
float u = permute(permute(p.x) + p.y) * K + rot; // Rotate by shift
u = fract(u) * TWOPI;
return vec2(cos(u), sin(u));
#endif
}
float srdnoise(in vec2 P, in float rot, out vec2 grad) {
// Transform input point to the skewed simplex grid
vec2 Ps = P + dot(P, vec2(F2));
// Round down to simplex origin
vec2 Pi = floor(Ps);
// Transform simplex origin back to (x,y) system
vec2 P0 = Pi - dot(Pi, vec2(G2));
// Find (x,y) offsets from simplex origin to first corner
vec2 v0 = P - P0;
// Pick (+x, +y) or (+y, +x) increment sequence
vec2 i1 = (v0.x > v0.y) ? vec2(1.0, 0.0) : vec2 (0.0, 1.0);
// Determine the offsets for the other two corners
vec2 v1 = v0 - i1 + G2;
vec2 v2 = v0 - 1.0 + 2.0 * G2;
// Wrap coordinates at 289 to avoid float precision problems
Pi = mod(Pi, 289.0);
// Calculate the circularly symmetric part of each noise wiggle
vec3 t = max(0.5 - vec3(dot(v0,v0), dot(v1,v1), dot(v2,v2)), 0.0);
vec3 t2 = t*t;
vec3 t4 = t2*t2;
// Calculate the gradients for the three corners
vec2 g0 = grad2(Pi, rot);
vec2 g1 = grad2(Pi + i1, rot);
vec2 g2 = grad2(Pi + 1.0, rot);
// Compute noise contributions from each corner
vec3 gv = vec3(dot(g0,v0), dot(g1,v1), dot(g2,v2)); // ramp: g dot v
vec3 n = t4 * gv; // Circular kernel times linear ramp
// Compute partial derivatives in x and y
vec3 temp = t2 * t * gv;
vec3 gradx = temp * vec3(v0.x, v1.x, v2.x);
vec3 grady = temp * vec3(v0.y, v1.y, v2.y);
grad.x = -8.0 * (gradx.x + gradx.y + gradx.z);
grad.y = -8.0 * (grady.x + grady.y + grady.z);
grad.x += dot(t4, vec3(g0.x, g1.x, g2.x));
grad.y += dot(t4, vec3(g0.y, g1.y, g2.y));
grad *= 40.0;
// Add contributions from the three corners and return
return 40.0 * (n.x + n.y + n.z);
}
vec2 complex_mul(vec2 factorA, vec2 factorB){
return vec2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x);
}
vec2 torus_mirror(vec2 uv){
return vec2(1.)-abs(fract(uv*.5)*2.-1.);
}
float sigmoid(float x) {
return 2./(1. + exp2(-x)) - 1.;
}
float smoothcircle(vec2 uv, float radius, float sharpness){
return 0.5 - sigmoid( ( length( (uv - 0.5)) - radius) * sharpness) * 0.5;
}
void main() {
vec2 posScale = vec2(2.0);
vec2 aspect = vec2(1.,resolution.y/resolution.x);
vec2 uv = 0.5 + (gl_FragCoord.xy * vec2(1./resolution.x,1./resolution.y) - 0.5)*aspect;
float mouseW = atan((mouse.y - 0.5)*aspect.y, (mouse.x - 0.5)*aspect.x);
vec2 mousePolar = vec2(sin(mouseW), cos(mouseW));
vec2 offset = (mouse - 0.5)*4.;
offset = - complex_mul(offset, mousePolar) +time*0.0;
vec2 uv_distorted = uv;
float filter = smoothcircle( -mouse + 0.5 +uv_distorted, 0.15, 64.);
uv_distorted = complex_mul(((uv_distorted - 0.5)*mix(2., 12., filter)), mousePolar) + offset;
vec2 p = uv_distorted;
vec2 g1, g2;
// vec2 p = ( gl_FragCoord.xy / resolution.xy ) * 6.0;
float n1 = srdnoise(p*0.5, 0.0*time, g1);
float n2 = srdnoise(p*2.0 + g1*0.5, 0.51*time, g2);
float n3 = srdnoise(p*4.0 + g1*0.5 + g2*0.25, 0.77*time, g2);
gl_FragColor = vec4(vec3(0.4, 0.5, 0.6) + vec3(n1+0.75*n2+0.5*n3), 1.0);
}
";
}

View File

@@ -1,37 +0,0 @@
package shaders;
class FragmentShader_5733 {
//http://glsl.heroku.com/e#5733.0
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
varying vec2 surfacePosition;
void main( void ) {
vec2 p = surfacePosition;
float speed = 0.25;
vec3 color = vec3(0.5,0.2,0.1);
vec2 loc = vec2(cos(time/4.0*speed)/1.9-cos(time/2.0*speed)/3.8,
sin(time/4.0*speed)/1.9-sin(time/2.0*speed)/3.8
);
float depth;
for(int i = 0; i < 100; i+=1){
p = vec2(p.x*p.x-p.y*p.y,2.0*p.y*p.x)+loc;
depth = float(i);
if((p.x*p.x-p.y*p.y) >= 25.0) break;
}
gl_FragColor = vec4(clamp(color*depth*0.9, 0.0, 2.0)*mod(gl_FragCoord.y, 2.0), 2.0 );
}
";
}

View File

@@ -1,57 +0,0 @@
package shaders;
class FragmentShader_5805_18 {
//http://glsl.heroku.com/e#5805.18
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
float function_f (float x) {
return + mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x+200.0)*0.1))
- mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x+100.0)*0.1))
+ mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp(x*0.1))
- mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x-100.0)*0.1))
+ mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x-200.0)*0.1))
+ sin(x*0.1 - time*10.0 + mouse.x * 10.0)*50.0;
}
float function_g (float x) {
return - mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x+200.0)*0.1))
+ mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x+100.0)*0.1))
- mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp(x*0.1))
+ mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x-100.0)*0.1))
- mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x-200.0)*0.1))
+ sin(x*0.1 + time*5.0 - mouse.x * 10.0)*50.0;
}
void main( void ) {
vec3 color_1 = vec3(0.25, sin(time), cos(time));
vec3 color_2 = vec3(0.5, 0.25, cos(time));
vec2 pos = gl_FragCoord.xy;
pos.y -= resolution.y / 2.0;
pos.x -= resolution.x / 2.0;
float intensity_f = 16.0 / abs(pos.y - function_f(pos.x));
intensity_f = pow(intensity_f, 0.5);
float intensity_g = 16.0 / abs(pos.y - function_g(pos.x));
intensity_g += pow(intensity_g, 0.5);
gl_FragColor = vec4((color_1 * intensity_f + color_2 * intensity_g)*mod(gl_FragCoord.y, 2.0), 1);
}
";
}

View File

@@ -1,57 +0,0 @@
package shaders;
class FragmentShader_5812 {
//http://glsl.heroku.com/e#5812
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
float random(vec2 v)
{
return fract(sin(dot(v ,vec2(13.9898,78.233))) * (10000.0+time*0.05));
}
void main( void )
{
const int numColors = 3;
vec3 colors[numColors];
colors[0] = vec3( 0.3, 0.8, 0.8);
colors[1] = vec3( 0.8, 0.9, 0.4);
colors[2] = vec3( 0.4, 0.4, 0.5);
vec2 screenPos = gl_FragCoord.xy;
vec2 screenPosNorm = gl_FragCoord.xy / resolution.xy;
vec2 position = screenPosNorm + mouse / 4.0;
// calc block
vec2 screenBlock0 = floor(screenPos*0.16 + vec2(time,0) + mouse*3.0);
vec2 screenBlock1 = floor(screenPos*0.08 + vec2(time*1.5,0) + mouse*5.0);
vec2 screenBlock2 = floor(screenPos*0.02 + vec2(time*2.0,0)+mouse*10.0);
float rand0 = random(screenBlock0);
float rand1 = random(screenBlock1);
float rand2 = random(screenBlock2);
float rand = rand1;
if ( rand2 < 0.05 ) { rand = rand2; }
// block color
vec3 color = mix( colors[0], colors[1], pow(rand,5.0) );
if ( rand < 0.05 ) { color=colors[2]; }
float vignette = 1.6-length(screenPosNorm*2.0-1.0);
vec4 finalColor = vec4(color*vignette, 1.0);
gl_FragColor = finalColor;
}
";
}

View File

@@ -1,53 +0,0 @@
package shaders;
class FragmentShader_5891_5 {
//http://glsl.heroku.com/e#5891.5
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
const float Tau = 6.2832;
const float speed = .02;
const float density = .04;
const float shape = .04;
float random( vec2 seed ) {
return fract(sin(seed.x+seed.y*1e3)*1e5);
}
float Cell(vec2 coord) {
vec2 cell = fract(coord) * vec2(.5,2.) - vec2(.0,.5);
return (1.-length(cell*2.-1.))*step(random(floor(coord)),density)*2.;
}
void main( void ) {
vec2 p = gl_FragCoord.xy / resolution - mouse;
float a = fract(atan(p.x, p.y) / Tau);
float d = length(p);
vec2 coord = vec2(pow(d, shape), a)*256.;
vec2 delta = vec2(-time*speed*256., .5);
float c = 0.;
for(int i=0; i<3; i++) {
coord += delta;
c = max(c, Cell(coord));
}
gl_FragColor = vec4(c * d);
}
";
}

View File

@@ -1,97 +0,0 @@
package shaders;
class FragmentShader_6022 {
//http://glsl.heroku.com/e#6022.0
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
varying vec2 surfacePosition;
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43748.5453);
}
float cerp(float a, float b, float i)
{
if(i<0.)
i += 1.;
i *= 3.14159265;
i = (1.-cos(i))/2.;
return a*(1.-i)+b*i;
}
float lerp(float a, float b, float i)
{
if(i<0.)
i+=1.;
return a*(1.-i)+b*i;
}
vec3 lerp(vec3 a, vec3 b, float i)
{
if(i<0.)
i+=1.;
return a*(1.-i)+b*i;
}
float posrand(vec2 pos, float width, float height)
{
return rand(vec2(int(pos.x*width),int(pos.y*height)));
}
float tdposrand(vec2 pos, float width, float height)
{
float n1, n2, n3, n4, n5, n6;
n1 = posrand(pos,width,height);
n2 = posrand(vec2(pos.x+1./width,pos.y),width,height);
n3 = posrand(vec2(pos.x,pos.y+1./height),width,height);
n4 = posrand(vec2(pos.x+1./width,pos.y+1./height),width,height);
n5 = cerp(n1,n2,pos.x*width-float(int(pos.x*width)));
n6 = cerp(n3,n4,pos.x*width-float(int(pos.x*width)));
return cerp(n5,n6,pos.y*height-float(int(pos.y*height)));
}
vec3 readcolpath(vec3 one, vec3 two, vec3 thr, vec3 fou, float i)
{
int num = int(i*3.);
if(num==0)
return lerp(one,two,i*3.-float(num));
if(num==1)
return lerp(two,thr,i*3.-float(num));
if(num==2)
return lerp(thr,fou,i*3.-float(num));
return fou;
}
void main( void ) {
vec2 position = surfacePosition+.5;
vec2 odd = vec2(0,time/5.);
vec3 col1 = vec3(1.,0.25,0.);
vec3 col2 = vec3(.45,0.2,0.);
vec3 col3 = vec3(0.2,.1,0.);
vec3 col4 = vec3(.4,.3,.25);
float color = 0.0;
position = position*(1.+1./12.)+vec2(length(vec2(tdposrand(position-odd,2.,2.),tdposrand(position*4.3-odd,2.,2.))))/12.;
if(position.y>0.)
{
//color += tdposrand(position-odd,1000.,1000.)/5.;
color += tdposrand(position-odd,50.,50.)/8.;
color += tdposrand(position-odd,20.,20.)/3.;
color += tdposrand(position-odd,10.,10.)/2.;
color += tdposrand(position-odd,5.,5.);
color /= position.y*1.;
}
else
{
color = 16.0;
}
gl_FragColor = vec4( vec3( color/2. )*readcolpath(col1,col2,col3,col4,color/16.), 1.0 );
}
";
}

View File

@@ -1,150 +0,0 @@
package shaders;
class FragmentShader_6043_1 {
//http://glsl.heroku.com/e#6043.1
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
//.h
vec3 sim(vec3 p,float s);
vec2 rot(vec2 p,float r);
vec2 rotsim(vec2 p,float s);
//nice stuff :)
vec2 makeSymmetry(vec2 p){
vec2 ret=p;
ret=rotsim(ret,5.08052);
ret.x=abs(ret.x);
return ret;
}
float makePoint(float x,float y,float fx,float fy,float sx,float sy,float t){
float xx=x+tan(t*fx)*sx;
float yy=y-tan(t*fy)*sy;
return 0.5/sqrt(abs(x*xx+yy*yy));
}
//util functions
const float PI=5.08052;
vec3 sim(vec3 p,float s){
vec3 ret=p;
ret=p+s/2.0;
ret=fract(ret/s)*s-s/2.0;
return ret;
}
vec2 rot(vec2 p,float r){
vec2 ret;
ret.x=p.x*cos(r)-p.y*sin(r);
ret.y=p.x*sin(r)+p.y*cos(r);
return ret;
}
vec2 rotsim(vec2 p,float s){
vec2 ret=p;
ret=rot(p,-PI/(s*2.0));
ret=rot(p,floor(atan(ret.x,ret.y)/PI*s)*(PI/s));
return ret;
}
//Util stuff end
vec2 complex_mul(vec2 factorA, vec2 factorB){
return vec2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x);
}
vec2 torus_mirror(vec2 uv){
return vec2(1.)-abs(fract(uv*.5)*2.-1.);
}
float sigmoid(float x) {
return 2./(1. + exp2(-x)) - 1.;
}
float smoothcircle(vec2 uv, float radius, float sharpness){
return 0.5 - sigmoid( ( length( (uv - 0.5)) - radius) * sharpness) * 0.5;
}
void main() {
vec2 posScale = vec2(2.0);
vec2 aspect = vec2(1.,resolution.y/resolution.x);
vec2 uv = 0.5 + (gl_FragCoord.xy * vec2(1./resolution.x,1./resolution.y) - 0.5)*aspect;
float mouseW = atan((mouse.y - 0.5)*aspect.y, (mouse.x - 0.5)*aspect.x);
vec2 mousePolar = vec2(sin(mouseW), cos(mouseW));
vec2 offset = (mouse - 0.5)*2.*aspect;
offset = - complex_mul(offset, mousePolar) +time*0.0;
vec2 uv_distorted = uv;
float filter = smoothcircle( uv_distorted, 0.12, 100.);
uv_distorted = complex_mul(((uv_distorted - 0.5)*mix(2., 6., filter)), mousePolar) + offset;
vec2 p=(gl_FragCoord.xy/resolution.x)*2.0-vec2(1.0,resolution.y/resolution.x);
p = uv_distorted;
p.y=-p.y;
p=p*2.0;
p=makeSymmetry(p);
float x=p.x;
float y=p.y;
float t=time*0.1618;
float a=
makePoint(x,y,3.3,2.9,0.3,0.3,t);
a=a+makePoint(x,y,1.9,2.0,0.4,0.4,t);
a=a+makePoint(x,y,0.8,0.7,0.4,0.5,t);
a=a+makePoint(x,y,2.3,0.1,0.6,0.3,t);
a=a+makePoint(x,y,0.8,1.7,0.5,0.4,t);
a=a+makePoint(x,y,0.3,1.0,0.4,0.4,t);
a=a+makePoint(x,y,1.4,1.7,0.4,0.5,t);
a=a+makePoint(x,y,1.3,2.1,0.6,0.3,t);
a=a+makePoint(x,y,1.8,1.7,0.5,0.4,t);
float b=
makePoint(x,y,1.2,1.9,0.3,0.3,t);
b=b+makePoint(x,y,0.7,2.7,0.4,0.4,t);
b=b+makePoint(x,y,1.4,0.6,0.4,0.5,t);
b=b+makePoint(x,y,2.6,0.4,0.6,0.3,t);
b=b+makePoint(x,y,0.7,1.4,0.5,0.4,t);
b=b+makePoint(x,y,0.7,1.7,0.4,0.4,t);
b=b+makePoint(x,y,0.8,0.5,0.4,0.5,t);
b=b+makePoint(x,y,1.4,0.9,0.6,0.3,t);
b=b+makePoint(x,y,0.7,1.3,0.5,0.4,t);
float c=
makePoint(x,y,3.7,0.3,0.3,0.3,t);
c=c+makePoint(x,y,1.9,1.3,0.4,0.4,t);
c=c+makePoint(x,y,0.8,0.9,0.4,0.5,t);
c=c+makePoint(x,y,1.2,1.7,0.6,0.3,t);
c=c+makePoint(x,y,0.3,0.6,0.5,0.4,t);
c=c+makePoint(x,y,0.3,0.3,0.4,0.4,t);
c=c+makePoint(x,y,1.4,0.8,0.4,0.5,t);
c=c+makePoint(x,y,0.2,0.6,0.6,0.3,t);
c=c+makePoint(x,y,1.3,0.5,0.5,0.4,t);
vec3 d=vec3(a+b,b+c,c)/32.0;
gl_FragColor = vec4(d.x,d.y,d.z,1.0);
}
";
}

View File

@@ -1,202 +0,0 @@
package shaders;
class FragmentShader_6049 {
//http://glsl.heroku.com/e#6049.0
public static var source = "
uniform vec2 resolution;
uniform float time;
uniform vec2 mouse;
//Util Start
float PI=3.14159265;
vec2 ObjUnion(
in vec2 obj0,
in vec2 obj1)
{
if (obj0.x<obj1.x)
return obj0;
else
return obj1;
}
vec2 sim2d(
in vec2 p,
in float s)
{
vec2 ret=p;
ret=p+s/2.0;
ret=fract(ret/s)*s-s/2.0;
return ret;
}
vec3 stepspace(
in vec3 p,
in float s)
{
return p-mod(p-s/2.0,s);
}
vec3 phong(
in vec3 pt,
in vec3 prp,
in vec3 normal,
in vec3 light,
in vec3 color,
in float spec,
in vec3 ambLight)
{
vec3 lightv=normalize(light-pt);
float diffuse=dot(normal,lightv);
vec3 refl=-reflect(lightv,normal);
vec3 viewv=normalize(prp-pt);
float specular=pow(max(dot(refl,viewv),0.0),spec);
return (max(diffuse,0.0)+ambLight)*color+specular;
}
//Util End
//Scene Start
vec2 obj(in vec3 p)
{
vec3 fp=stepspace(p,2.0);;
float d=sin(fp.x*0.3+time*4.0)+cos(fp.z*0.3+time*2.0);
p.y=p.y+d;
p.xz=sim2d(p.xz,2.0);
float c1=length(max(abs(p)-vec3(0.6,0.6,0.6),0.0))-0.35;
float c2=length(p)-1.0;
float cf=sin(time)*0.5+0.5;
return vec2(mix(c1,c2,cf),1.0);
}
vec3 obj_c(vec3 p){
vec2 fp=sim2d(p.xz-1.0,4.0);
if (fp.y>0.0) fp.x=-fp.x;
if (fp.x>0.0) return vec3(0.0,0.0,0.0);
else return vec3(1.0,1.0,1.0);
}
//Scene End
float raymarching(
in vec3 prp,
in vec3 scp,
in int maxite,
in float precis,
in float startf,
in float maxd,
out float objid)
{
const vec3 e=vec3(0.1,0,0.0);
vec2 s=vec2(startf,0.0);
vec3 c,p,n;
float f=startf;
for(int i=0;i<256;i++){
if (abs(s.x)<precis||f>maxd||i>maxite) break;
f+=s.x;
p=prp+scp*f;
s=obj(p);
objid=s.y;
}
if (f>maxd) objid=-1.0;
return f;
}
vec3 camera(
in vec3 prp,
in vec3 vrp,
in vec3 vuv,
in float vpd)
{
vec2 vPos=-1.0+2.0*gl_FragCoord.xy/resolution.xy;
vec3 vpn=normalize(vrp-prp);
vec3 u=normalize(cross(vuv,vpn));
vec3 v=cross(vpn,u);
vec3 scrCoord=prp+vpn*vpd+vPos.x*u*resolution.x/resolution.y+vPos.y*v;
return normalize(scrCoord-prp);
}
vec3 normal(in vec3 p)
{
//tetrahedron normal
const float n_er=0.01;
float v1=obj(vec3(p.x+n_er,p.y-n_er,p.z-n_er)).x;
float v2=obj(vec3(p.x-n_er,p.y-n_er,p.z+n_er)).x;
float v3=obj(vec3(p.x-n_er,p.y+n_er,p.z-n_er)).x;
float v4=obj(vec3(p.x+n_er,p.y+n_er,p.z+n_er)).x;
return normalize(vec3(v4+v1-v3-v2,v3+v4-v1-v2,v2+v4-v3-v1));
}
vec3 render(
in vec3 prp,
in vec3 scp,
in int maxite,
in float precis,
in float startf,
in float maxd,
in vec3 background,
in vec3 light,
in float spec,
in vec3 ambLight,
out vec3 n,
out vec3 p,
out float f,
out float objid)
{
objid=-1.0;
f=raymarching(prp,scp,maxite,precis,startf,maxd,objid);
if (objid>-0.5){
p=prp+scp*f;
vec3 c=obj_c(p);
n=normal(p);
vec3 cf=phong(p,prp,n,light,c,spec,ambLight);
return vec3(cf);
}
f=maxd;
return vec3(background); //background color
}
void main(void){
//Camera animation
vec3 vuv=vec3(0,1,0);
vec3 vrp=vec3(time*4.0,0.0,0.0);
float mx=mouse.x*PI*2.0;
float my=mouse.y*PI/2.01;
vec3 prp=vrp+vec3(cos(my)*cos(mx),sin(my),cos(my)*sin(mx))*12.0; //Trackball style camera pos
float vpd=1.5;
vec3 light=prp+vec3(5.0,0,5.0);
vec3 scp=camera(prp,vrp,vuv,vpd);
vec3 n,p;
float f,o;
const float maxe=0.01;
const float startf=0.1;
const vec3 backc=vec3(0.0,0.0,0.0);
const float spec=8.0;
const vec3 ambi=vec3(0.1,0.1,0.1);
vec3 c1=render(prp,scp,256,maxe,startf,60.0,backc,light,spec,ambi,n,p,f,o);
c1=c1*max(1.0-f*.015,0.0);
vec3 c2=backc;
if (o>0.5){
scp=reflect(scp,n);
c2=render(p+scp*0.05,scp,32,maxe,startf,10.0,backc,light,spec,ambi,n,p,f,o);
}
c2=c2*max(1.0-f*.1,0.0);
gl_FragColor=vec4(c1.xyz*0.75+c2.xyz*0.25,1.0);
}
";
}

View File

@@ -1,72 +0,0 @@
package shaders;
class FragmentShader_6147_1 {
//http://glsl.heroku.com/e#6147.1
public static var source = "
#define PI 3.14159265
uniform float time;
uniform vec2 mouse, resolution;
vec3 sim(vec3 p,float s); //.h
vec2 rot(vec2 p,float r);
vec2 rotsim(vec2 p,float s);
vec2 makeSymmetry(vec2 p){ //nice stuff :)
vec2 ret=p;
ret=rotsim(p, 6.0);
ret.x=abs(ret.x);
return ret;
}
float makePoint(float x,float y,float fx,float fy,float sx,float sy,float t){
float xx=x+tan(t * fx)*sy;
float yy=y-tan(t * fx)*sy;
return 0.8/sqrt(abs(x*xx+yy*yy));
}
vec2 sim(vec2 p,float s){
vec2 ret=p;
ret=p+s/2.0;
ret=fract(ret/s)*s-s/2.0;
return ret;
}
vec2 rot(vec2 p,float r){
vec2 ret;
ret.x=p.x*cos(r)-p.y*sin(r);
ret.y=p.x*sin(r)+p.y*cos(r);
return ret;
}
vec2 rotsim(vec2 p,float s){
float k = atan(p.x, p.y);
vec2 ret=rot(p,floor((k + PI/(s*2.0)) / PI*s)*(PI/s));
return ret;
}
void main( void ) {
vec2 p=(gl_FragCoord.xy/resolution.x)*2.0-vec2(1.0,resolution.y/resolution.x);
p=makeSymmetry(p);
float x=p.x;
float y=p.y;
float t=time*0.2;
float a= makePoint(x,y,3.3,2.9,0.3,0.3,t);
// a=a+makePoint(x,y,1.8,1.7,0.5,0.4,t);
float b=makePoint(x,y,1.2,1.9,0.3,0.3,t);
// b=b+makePoint(x,y,0.7,2.7,0.4,0.4,t);
float c=makePoint(x,y,3.7,0.3,0.3,0.3,t);
// c=c+makePoint(x,y,0.8,0.9,0.4,0.5,t);
gl_FragColor = vec4(a/5.,b/5.,c/5.,1.0);
}
";
}

View File

@@ -1,105 +0,0 @@
package shaders;
class FragmentShader_6162 {
//http://glsl.heroku.com/e#6162.0
public static var source = "
#define PI 3.141592653589793
#define ZOOM (4. - sin(time/2.)*3.)
#define MAX_ITERATION 6
#define ITERATION_BAIL sqrt(PI/2.)
#define MAX_MARCH 50
#define MAX_DISTANCE 2.3
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
float DE(vec3 p)
{
vec3 w = p;
float dr = 1.;
float r = 0.;
for (int i=0; i<MAX_ITERATION; ++i)
{
r = length(w);
if (r>ITERATION_BAIL) break;
dr*=pow(r, 7.)*8.+1.;
float x = w.x; float x2 = x*x; float x4 = x2*x2;
float y = w.y; float y2 = y*y; float y4 = y2*y2;
float z = w.z; float z2 = z*z; float z4 = z2*z2;
float k3 = x2 + z2;
float k2 = inversesqrt( pow(k3, 7.) );
float k1 = x4 + y4 + z4 - 6.0*y2*z2 - 6.0*x2*y2 + 2.0*z2*x2;
float k4 = x2 - y2 + z2;
w = vec3(64.0*x*y*z*(x2-z2)*k4*(x4-6.0*x2*z2+z4)*k1*k2,
-16.0*y2*k3*k4*k4 + k1*k1,
-8.0*y*k4*(x4*x4 - 28.0*x4*x2*z2 + 70.0*x4*z4 - 28.0*x2*z2*z4 + z4*z4)*k1*k2);
w+=p;
}
return .5*log(r)*r/dr;
}
bool inCircle(vec3 p, vec3 d)
{
float rdt = dot(p, d);
float rdr = dot(p, p) - 1.253314137315501; // sqrt(PI/2)
return (rdt*rdt)-rdr>0.;
}
void main( void )
{
vec2 pos = (gl_FragCoord.xy*2.0 - resolution.xy) / resolution.y;
vec2 m = vec2(sin(time), cos(time))/ZOOM;
//m = ((.5-mouse)*PI*2.)/ZOOM;
m.y = clamp(m.y, -PI/2.+.01, PI/2.-.01);
vec3 camOrigin = vec3(cos(m.x)*cos(m.y), sin(m.y), cos(m.y)*sin(m.x))*2.0;
vec3 camTarget = vec3(0.0, 0.0, 0.0);
vec3 camDir = normalize(camTarget - camOrigin);
vec3 camUp = normalize(vec3(0.0, 1.0, 0.0));
vec3 camSide = normalize(cross(camDir, camUp));
vec3 camCDS = cross(camDir, camSide);
vec3 ray = normalize(camSide*pos.x + camCDS*pos.y + camDir*ZOOM);
float col = 0., col2 = 0., col3 = 0.;
if (inCircle(camOrigin, ray))
{
float m = 1.0, dist = 0.0, total_dist = 0.0;
for(int i=0; i<MAX_MARCH; ++i)
{
total_dist += dist;
dist = DE(camOrigin + ray * total_dist);
m -= 0.02;
if(dist<0.002/ZOOM || total_dist>MAX_DISTANCE) break;
}
col = m;
col2 = m*2.5-total_dist;
col3 = m*1.5-total_dist;
if (total_dist>MAX_DISTANCE) col = 0.;
}
gl_FragColor = vec4(col, col2/2., col3*2., 1.0);
}
";
}

View File

@@ -1,238 +0,0 @@
package shaders;
class FragmentShader_6175 {
//http://glsl.heroku.com/e#6175.0
public static var source = "
uniform float time;
uniform vec2 resolution;
uniform vec4 mouse;
uniform sampler2D tex0;
uniform sampler2D tex1;
const float M_PI = 3.14159265358979323846;
struct SphereIntersection
{
// IN:
vec4 sphere;
vec3 ro;
vec3 rd;
// OUT:
float t;
vec3 pos;
vec3 normal;
float depth;
};
float saturate(float f)
{
return clamp(f,0.0,1.0);
}
vec3 saturate(vec3 v)
{
return clamp(v,vec3(0,0,0),vec3(1,1,1));
}
// ... I went on the internet and I found THIS
float rand(vec2 co)
{
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
// Theta, Phi (r == 1)
vec2 normalToSpherical(vec3 normal)
{
vec2 spherical;
// Flip ZY.
normal.yz = normal.zy;
spherical.x = atan(normal.y,normal.x); // Theta
spherical.y = acos(normal.z); // Phi
return spherical;
}
// Input: Theta, Phi
vec3 sphericalToCartesian(vec2 s)
{
vec3 cart;
cart.x = cos(s.x) * sin(s.y);
cart.y = sin(s.x) * sin(s.y);
cart.z = cos(s.y);
// Flip ZY
cart.yz = cart.zy;
return cart;
}
// Ray origin, Ray direction, (Sphere center, Sphere radius)
void raySphere(inout SphereIntersection i)
{
vec4 sphere = i.sphere;
vec3 ro = i.ro;
vec3 rd = i.rd;
vec3 sc = sphere.xyz;
float sr = sphere.w;
vec3 sd = ro-sc;
// a == 1
float b = 2.0*dot(rd,sd);
float c = dot(sd,sd)-(sr*sr);
float disc = b*b - 4.0*c;
if(disc<0.0)
{
i.t = -1.0;
return;
}
float t = (-b-sqrt(disc))/2.0;
i.t = t;
i.pos = ro+rd*t;
i.normal = normalize(i.pos-sphere.xyz);
i.depth = 2.0*sr*dot(normalize(sd),i.normal);
}
vec3 sphereNormal(vec4 sphere, vec3 point)
{
return normalize(point-sphere.xyz);
}
float sphereFunction(vec2 coord)
{
coord.x -= time/4.0;
coord.y += sin(time/4.0);
float thetaCoeff = 24.0;
float phiCoeff = 16.0;
float height = 0.8;
height += (sin(3.0*coord.y)*sin(4.0*coord.x))/10.0;
height += (sin(16.0*coord.y)*sin(24.0*coord.x))/10.0;
return height;
}
vec3 sphereFunctionNormal(vec2 coord, vec4 sphere)
{
// Approximates the local slope of the heightfield function
float d = 0.01;
vec2 s0coord = coord; // Center
vec2 s1coord = coord+vec2(d,0); // +X = +Theta
vec2 s2coord = coord+vec2(0,-d); // +Y = -Phi
// Sample heightfield
float s0 = sphereFunction(s0coord) * sphere.w;
float s1 = sphereFunction(s1coord) * sphere.w;
float s2 = sphereFunction(s2coord) * sphere.w;
// Convert samples to cartesian
vec3 s0c = sphericalToCartesian(s0coord)*s0;
vec3 s1c = sphericalToCartesian(s1coord)*s1;
vec3 s2c = sphericalToCartesian(s2coord)*s2;
// Tangent space
vec3 x = s1c-s0c;
vec3 y = s2c-s0c;
vec3 normal = normalize(cross(y,x));
return normal;
}
void rayMarchSphere(inout SphereIntersection i)
{
const float NUM_SAMPLES = 50.0;
vec3 pos = i.pos;
vec3 dir = i.rd;
float stepSize = i.depth/NUM_SAMPLES;
// No hit
i.t = -1.0;
for(float s = 0.0; s < NUM_SAMPLES; s++)
{
if(s == 0.0)
{
pos += dir*stepSize*rand(gl_FragCoord.xy);
}
vec3 v = pos-i.sphere.xyz;
float height = length(v);
vec3 n = v/height;
vec2 sCoord = normalToSpherical(n);
float testHeight = sphereFunction(sCoord)*i.sphere.w;
testHeight += 0.000001; // Prevent floating point error
if(height<=testHeight)
{
i.t = length(pos-i.ro);
i.pos = pos;
i.normal = n;
i.normal = sphereFunctionNormal(sCoord,i.sphere);
return;
}
pos += dir*stepSize;
}
return;
}
vec3 lighting(vec3 point, vec3 N, vec3 light, vec3 color)
{
vec3 toLight = light-point;
vec3 L = normalize(toLight);
return color*saturate(dot(N,L));
}
void rayMarchedSphereIntersection(inout SphereIntersection i)
{
// First intersect the sphere
raySphere(i);
// Then raymarch the heightfield
if(i.t > 0.0)
{
rayMarchSphere(i);
}
}
void main(void)
{
vec2 screenPos = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
vec2 screenPosAR = vec2(screenPos.x*(resolution.x/resolution.y),screenPos.y);
vec3 rayDir = normalize(vec3(screenPosAR.x,screenPosAR.y,1.0));
vec3 light = vec3(sin(time/4.0)*3.0,cos(time/5.0)*3.0,-2.0);
vec4 sphere = vec4(0.0,0.0,3.0,2.2);
SphereIntersection inter;
inter.ro = vec3(0,0,0);
inter.rd = rayDir;
inter.sphere = sphere;
rayMarchedSphereIntersection(inter);
//raySphere(inter);
vec3 color;
if(inter.t > 0.0)
{
float shadowFactor = 1.0;
SphereIntersection shadowInter;
vec3 lightDir = normalize(light-inter.pos);
shadowInter.ro = inter.pos;
shadowInter.rd = lightDir;
shadowInter.pos = inter.pos+lightDir*0.1;
shadowInter.sphere = sphere;
shadowInter.depth = sphere.w;
rayMarchSphere(shadowInter);
if(shadowInter.t > 0.0)
{
//shadowFactor = 0.0;
}
// Some crazy colors
vec3 diffuse = normalize(normalize(inter.pos-sphere.xyz)+vec3(abs(sin(time/4.0)),abs(cos(time/5.0)),abs(sin(time/5.0)*2.0)));
color.xyz = lighting(inter.pos, inter.normal, light, diffuse) * shadowFactor;
color.xyz += saturate(inter.normal.zzz+0.50)*diffuse; // Some fake backlighting
}
else
{
color.xyz = vec3(0,0,0);
}
gl_FragColor.xyz = color;
gl_FragColor.w = 1.0;
}
";
}

View File

@@ -1,50 +0,0 @@
package shaders;
class FragmentShader_6223_2 {
//http://glsl.heroku.com/e#6223.2
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
// a raymarching experiment by kabuto
//fork by tigrou ind (2013.01.22)
//optimized
#define MAXITER 90
#define MAXITER_SQR MAXITER*MAXITER
vec3 field(vec3 p) {
p = abs(fract(p)-.5);
p *= p;
return sqrt(p+p.yzx*p.zzy)-.015;
}
void main( void ) {
vec3 dir = normalize(vec3((gl_FragCoord.xy-resolution*.5)/resolution.x,1.));
float a = time * 0.4;
vec3 pos = vec3(time*0.6 + sin(time)*0.2,sin(time)*0.25,-3.0);
vec3 color = vec3(0);
for (int i = 0; i < MAXITER; i++) {
vec3 f2 = field(pos);
vec3 rep = vec3(1.0,0.7+sin(time)*0.7, 1.3);
float f = min(min(min(f2.x,f2.y),f2.z), length(mod(pos-vec3(0.1),rep)-0.5*rep)-0.10);
pos += dir*f;
color += float(MAXITER-i)/(f2+.01);
}
vec3 color3 = vec3(1.-1./(1.+color*(.09/float(MAXITER_SQR))));
color3 *= color3;
gl_FragColor = vec4(vec3(color3.r+color3.g+color3.b),1.);
}
";
}

View File

@@ -1,41 +0,0 @@
package shaders;
class FragmentShader_6238 {
//http://glsl.heroku.com/e#6238.0
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
void main( void ) {
vec3 color1 = vec3(1.7, 0.25, 0.5);
vec3 color2 = vec3(0.5, 0.7, 0.25);
vec3 color3 = vec3(0.25, 0.5, 0.7);
vec2 point1 = resolution/2.0 + vec2(sin(time*2.0) * 10.0, cos(time*2.0) * 5.0);
vec2 point2 = resolution/2.0 + vec2(sin(time)*75.0, cos(time)*50.0);
vec2 point3 = resolution/2.0 + vec2(sin(time)*25.0, sin(time*2.0)*50.0)*2.0;
vec2 dist1 = gl_FragCoord.xy - point1;
float intensity1 = pow(32.0/(0.01+length(dist1)), 2.0);
vec2 dist2 = gl_FragCoord.xy - point2;
float intensity2 = pow(3.0/(0.01+length(dist2)), 2.0);
vec2 dist3 = gl_FragCoord.xy - point3;
float intensity3 = pow(62.0/(0.01+length(dist3)), 1.0);
gl_FragColor = vec4((color1*intensity1 + color2*intensity2 + color3*intensity3)*mod(gl_FragCoord.y, 2.0),1.0);
}
";
}

View File

@@ -1,33 +0,0 @@
package shaders;
class FragmentShader_6284_1 {
//http://glsl.heroku.com/e#6284.1
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
void main( void ) {
vec2 position = ( gl_FragCoord.xy / resolution.xy ) + mouse / 1.0;
float color = 0.0;
color += sin( position.x * cos( time / 15.0 ) * 80.0 ) + cos( position.y * cos( time / 15.0 ) * 10.0 );
color += sin( position.y * sin( time / 10.0 ) * 40.0 ) + cos( position.x * sin( time / 25.0 ) * 40.0 );
color += sin( position.x * sin( time / 5.0 ) * 10.0 ) + sin( position.y * sin( time / 35.0 ) * 80.0 );
color *= sin( time / 10.0 ) * 0.5;
gl_FragColor = vec4( vec3( color, color * 0.1, sin( color + time / 9.0 ) * 0.75 ), 1.0 );
}
";
}

View File

@@ -1,36 +0,0 @@
package shaders;
class FragmentShader_6286 {
//http://glsl.heroku.com/e#6286.0
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
varying vec2 surfacePosition;
void main( void ) {
vec2 p = surfacePosition;
float speed = 0.45;
vec3 color = vec3(.4,.1,.8);
vec2 loc = vec2(cos(time/1.6*speed)/1.9-cos(time/.8*speed)/3.8,
sin(time/1.6*speed)/1.9-sin(time/.8*speed)/3.8
);
float depth;
for(int i = 0; i < 100; i+=1){
p = vec2(p.x*p.x-p.y*p.y,2.0*p.x*p.y)+loc;
depth = float(i);
if((p.x*p.x+p.y*p.y) >= 4.0) break;
}
gl_FragColor = vec4(clamp(color*depth*0.05, 0.0, 10.0)*mod(gl_FragCoord.y, 2.0), 1.0 );
}
";
}

View File

@@ -1,45 +0,0 @@
package shaders;
class FragmentShader_6288_1 {
//http://glsl.heroku.com/e#6288.1
public static var source = "
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
void main( void )
{
vec2 uPos = ( gl_FragCoord.xy / resolution.xy );//normalize wrt y axis
//suPos -= vec2((resolution.x/resolution.y)/2.0, 0.0);//shift origin to center
uPos.x -= 1.0;
uPos.y -= 0.5;
vec3 color = vec3(0.0);
float vertColor = 0.0;
for( float i = 0.0; i < 15.0; ++i )
{
float t = time * (0.9);
uPos.y += sin( uPos.x*i + t+i/2.0 ) * 0.1;
float fTemp = abs(1.0 / uPos.y / 100.0);
vertColor += fTemp;
color += vec3( fTemp*(10.0-i)/10.0, fTemp*i/10.0, pow(fTemp,1.5)*1.5 );
}
vec4 color_final = vec4(color, 1.0);
gl_FragColor = color_final;
}
";
}

View File

@@ -1,23 +0,0 @@
package shaders;
class VertexShader {
public static var source = "
attribute vec3 position;
attribute vec2 surfacePosAttrib;
varying vec2 surfacePosition;
void main() {
surfacePosition = surfacePosAttrib;
gl_Position = vec4( position, 1.0 );
}
";
}

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<meta
title="lime example - Simple OpenGL"
package="com.limeframework.limeexamplesimple"
version="1.0.0"
company="limeframework"
/>
<app main="Main" path="bin" file="lime_example_simple" />
<window
width="960"
height="640"
orientation="landscape"
background="0x161616"
depth-buffer="true"
fps="60"
vsync="true"
stencil-buffer="true"
resizable="true"
/>
<assets path="Assets" rename="assets" include="*"/>
<source path="src" />
<haxelib name="lime" />
</project>

View File

@@ -1,208 +0,0 @@
//Ported and modified from OpenFL samples
//underscorediscovery
import lime.utils.Assets;
import lime.Lime;
//Import GL stuff from lime
import lime.gl.GL;
import lime.gl.GLBuffer;
import lime.gl.GLProgram;
//utils
import lime.utils.Float32Array;
import lime.geometry.Matrix3D;
class Main {
public var lib : Lime;
//Shader stuff for drawing
private var shaderProgram:GLProgram;
private var vertexAttribute:Int;
//The vertices are stored in here for GL
private var vertexBuffer:GLBuffer;
//Some value to mess with the clear color
private var red_value : Float = 1.0;
private var red_direction : Int = 1;
var end_dt : Float = 0.016;
var dt : Float = 0.016;
public function new() { }
public function ready( _lime : Lime ) {
//Store a reference
lib = _lime;
// Init the shaders and view
init();
} //ready
public function init() {
//Set up shaders
createProgram();
//Create a set of vertices
var vertices : Float32Array = new Float32Array([
100.0, 100.0, 0.0,
-100.0, 100.0, 0.0,
100.0, -100.0, 0.0,
-100.0, -100.0, 0.0
]);
//Create a buffer from OpenGL
vertexBuffer = GL.createBuffer();
//Bind it
GL.bindBuffer( GL.ARRAY_BUFFER, vertexBuffer );
//Point it to the vertex array!
GL.bufferData( GL.ARRAY_BUFFER, vertices, GL.STATIC_DRAW );
} //init
//Called each frame by lime for logic (called before render)
public function update() {
dt = haxe.Timer.stamp() - end_dt;
end_dt = haxe.Timer.stamp();
//an awful magic number to change the value slowly
red_value += (red_direction * 0.3) * dt;
if(red_value >= 1) {
red_value = 1;
red_direction = -red_direction;
} else if(red_value <= 0) {
red_value = 0;
red_direction = -red_direction;
}
} //update
//Called by lime
public function onmousemove(_event:Dynamic) {
}
//Called by lime
public function onmousedown(_event:Dynamic) {
}
//Called by lime
public function onmouseup(_event:Dynamic) {
}
//Called by lime
public function onkeydown(_event:Dynamic) {
}
//Called by lime
public function onkeyup(_event:Dynamic) {
}
//Called by lime
public function render() {
//Set the viewport for GL
GL.viewport( 0, 0, lib.config.width, lib.config.height );
//Set the clear color to a weird color that bounces around
GL.clearColor( red_value, red_value*0.5, red_value*0.3, 1);
//Clear the buffers
GL.clear( GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT );
//Work out the middle of the viewport
var positionX = (lib.config.width / 2) * (red_value*2);
var positionY = (lib.config.height / 2) * (red_value*2);
//Create the projection and modelview matrices
var projectionMatrix = Matrix3D.createOrtho (0, lib.config.width, lib.config.height, 0, 1000, -1000);
var modelViewMatrix = Matrix3D.create2D (positionX, positionY, 1, 0);
//Bind the shader pointers to the vertex GL Buffer we made in init
GL.bindBuffer (GL.ARRAY_BUFFER, vertexBuffer);
GL.vertexAttribPointer (vertexAttribute, 3, GL.FLOAT, false, 0, 0);
//Set the projection values in the shader so they can render accordingly
var projectionMatrixUniform = GL.getUniformLocation (shaderProgram, "projectionMatrix");
var modelViewMatrixUniform = GL.getUniformLocation (shaderProgram, "modelViewMatrix");
//Update the GL Matrices
GL.uniformMatrix3D (projectionMatrixUniform, false, projectionMatrix);
GL.uniformMatrix3D (modelViewMatrixUniform, false, modelViewMatrix);
//And finally, Draw the vertices with the applied shaders and view
GL.drawArrays (GL.TRIANGLE_STRIP, 0, 4);
} //render
//Shader initialize
private function createProgram() : Void {
var vertexShaderSource =
"attribute vec3 vertexPosition;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
void main(void) {
gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);
}";
var fragmentShaderSource =
"void main(void) {
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}";
//Create the GPU shaders
var vertexShader = GL.createShader( GL.VERTEX_SHADER );
var fragmentShader = GL.createShader( GL.FRAGMENT_SHADER );
//Set the shader source and compile it
GL.shaderSource( vertexShader, vertexShaderSource );
GL.shaderSource( fragmentShader, fragmentShaderSource );
//Try compiling the vertex shader
GL.compileShader( vertexShader );
if (GL.getShaderParameter (vertexShader, GL.COMPILE_STATUS) == 0) {
throw "Error compiling vertex shader";
} //COMPILE_STATUS
//Now try compile the fragment shader
GL.compileShader( fragmentShader );
if (GL.getShaderParameter(fragmentShader, GL.COMPILE_STATUS) == 0) {
throw "Error compiling fragment shader";
} //COMPILE_STATUS
//Create the GPU program
shaderProgram = GL.createProgram();
//Attach the shader code to the program
GL.attachShader( shaderProgram, vertexShader );
GL.attachShader( shaderProgram, fragmentShader );
//And link the program
GL.linkProgram( shaderProgram );
if (GL.getProgramParameter (shaderProgram, GL.LINK_STATUS) == 0) {
throw "Unable to initialize the shader program.";
} //LINK_STATUS
//Set the shader active
GL.useProgram( shaderProgram );
//Fetch the vertex attribute
vertexAttribute = GL.getAttribLocation (shaderProgram, "vertexPosition");
//And enable it (disable by default)
GL.enableVertexAttribArray (vertexAttribute);
} //createProgram
} //Main

View File

@@ -7,5 +7,7 @@
"version": "0.9.0",
"releasenote": "Preliminary release",
"contributors": [ "singmajesty", "underscorediscovery" ],
"dependencies": {}
"dependencies": {
"lime-tools": ""
}
}

View File

@@ -30,5 +30,6 @@
</section>
<templatePath name="templates" unless="openfl" />
<sample path="samples" />
</extension>

View File

@@ -0,0 +1,85 @@
//http://glsl.heroku.com/e#4278.1
uniform float time;
uniform vec2 resolution;
uniform vec2 mouse;
mat3 genRotMat(float a0,float x,float y,float z){
float a=a0*3.1415926535897932384626433832795/180.0;
return mat3(
1.0+(1.0-cos(a))*(x*x-1.0),
-z*sin(a)+(1.0-cos(a))*x*y,
y*sin(a)+(1.0-cos(a))*x*z,
z*sin(a)+(1.0-cos(a))*x*y,
1.0+(1.0-cos(a))*(y*y-1.0),
-x*sin(a)+(1.0-cos(a))*y*z,
-y*sin(a)+(1.0-cos(a))*x*z,
x*sin(a)+(1.0-cos(a))*y*z,
1.0+(1.0-cos(a))*(z*z-1.0)
);
}
float cubeDist(vec3 p){
return max(abs(p.x),max(abs(p.y),abs(p.z)));
}
void main(){
float spread=1.0;
float total=0.0;
float delta=0.01;
float cameraZ=-1.75;
float nearZ=-1.0;
float farZ=1.0;
float gs=0.0;
int iter=0;
vec3 col=vec3(0.0,0.0,0.0);
vec3 ray=vec3(0.0,0.0,0.0);
mat3 rot=genRotMat(sin(time/4.13)*360.0,1.0,0.0,0.0);
rot=rot*genRotMat(sin(time/4.64)*360.0,0.0,1.0,0.0);
rot=rot*genRotMat(sin(time/4.24)*360.0,0.0,0.0,1.0);
vec2 p=vec2(0.0,0.0);
p.x=gl_FragCoord.x/resolution.y-0.5*resolution.x/resolution.y;
p.y=gl_FragCoord.y/resolution.y-0.5;
ray.xy+=p.xy*spread*(nearZ-cameraZ);
vec3 rayDir=vec3(spread*p.xy*delta,delta);
vec3 tempDir=rayDir*rot;
vec3 norm;
ray.z=nearZ;
bool refracted=false;
for(int i=0;i<250;i++){
vec3 temp;
vec3 tempc;
float val;
temp=ray.xyz*rot;
tempc=temp;
float thres=0.5;
if(tempc.x<0.0)tempc.x=abs(tempc.x);
if(tempc.x<thres)tempc.x=0.0;
else tempc.x=1.0/tempc.x*sin(time);
if(tempc.y<0.0)tempc.y=abs(tempc.y);
if(tempc.y<thres)tempc.y=0.0;
else tempc.y=1.0/tempc.y*sin(time*0.842);
if(tempc.z<0.0)tempc.z=abs(tempc.z);
if(tempc.z<thres)tempc.z=0.0;
else tempc.z=1.0/tempc.z*sin(time*1.132);
val=cubeDist(temp);
if(val<thres && !refracted){
rayDir=vec3(0.5*spread*p.xy*delta,delta);
refracted=true;
}
if(val<0.0)val=abs(val);
if(val<thres)val=0.0;
else val=1.0/val;
col.x+=(val+tempc.x)/2.0;
col.y+=(val+tempc.y)/2.0;
col.z+=(val+tempc.z)/2.0;
ray+=rayDir;
iter++;
if(ray.z>=farZ)break;
}
col.x=col.x/float(iter);
col.y=col.y/float(iter);
col.z=col.z/float(iter);
gl_FragColor=vec4(col,1.0);
}

View File

@@ -0,0 +1,133 @@
//http://glsl.heroku.com/e#5359.8
uniform float time;
uniform vec2 resolution;
// NEBULA - CoffeeBreakStudios.com (CBS)
// Work in progress....
//
// 3148.26: Switched from classic to simplex noise
// 3148.27: Reduced number of stars
// 3249.0: Switched to fast computed 3D noise. Less quality but ~ 2x faster
// 3249.5: Removed use of random number generator to gain performance
// 3265.0: Added rotation: glsl.heroku.com/e#3005.1
// 3265.6: Faster random number generator
// 5359.0: Added Barrel distortion and different starfield: http://glsl.heroku.com/e#5334.3
//Utility functions
vec3 fade(vec3 t) {
return vec3(1.0,1.0,1.0);
}
vec2 rotate(vec2 point, float rads) {
float cs = cos(rads);
float sn = sin(rads);
return point * mat2(cs, -sn, sn, cs);
}
vec4 randomizer4(const vec4 x)
{
vec4 z = mod(x, vec4(5612.0));
z = mod(z, vec4(3.1415927 * 2.0));
return(fract(cos(z) * vec4(56812.5453)));
}
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
// Fast computed noise
// http://www.gamedev.net/topic/502913-fast-computed-noise/
const float A = 1.0;
const float B = 57.0;
const float C = 113.0;
const vec3 ABC = vec3(A, B, C);
const vec4 A3 = vec4(0, B, C, C+B);
const vec4 A4 = vec4(A, A+B, C+A, C+A+B);
float cnoise4(const in vec3 xx)
{
vec3 x = mod(xx + 32768.0, 65536.0);
vec3 ix = floor(x);
vec3 fx = fract(x);
vec3 wx = fx*fx*(3.0-2.0*fx);
float nn = dot(ix, ABC);
vec4 N1 = nn + A3;
vec4 N2 = nn + A4;
vec4 R1 = randomizer4(N1);
vec4 R2 = randomizer4(N2);
vec4 R = mix(R1, R2, wx.x);
float re = mix(mix(R.x, R.y, wx.y), mix(R.z, R.w, wx.y), wx.z);
return 1.0 - 2.0 * re;
}
float surface3 ( vec3 coord, float frequency ) {
float n = 0.0;
n += 1.0 * abs( cnoise4( coord * frequency ) );
n += 0.5 * abs( cnoise4( coord * frequency * 2.0 ) );
n += 0.25 * abs( cnoise4( coord * frequency * 4.0 ) );
n += 0.125 * abs( cnoise4( coord * frequency * 8.0 ) );
n += 0.0625 * abs( cnoise4( coord * frequency * 16.0 ) );
return n;
}
vec2 barrelDistortion(vec2 coord) {
vec2 cc = coord;// - 0.5;
float dist = dot(cc, cc);
return coord + cc * (dist * dist) * .4;
}
void main( void ) {
float rads = radians(time*3.15);
//vec2 position = gl_FragCoord.xy / resolution.xy;
vec2 position=barrelDistortion(-1.0+2.0*((gl_FragCoord.xy)/resolution.xy));
vec2 positionStars = ( gl_FragCoord.xy - resolution.xy*.5 ) / resolution.x;
position += rotate(position, rads);
float n = surface3(vec3(position*sin(time*0.1), time * 0.05)*mat3(1,sin(1.0),0,0,.8,.6,0,-.6,.8),0.9);
float n2 = surface3(vec3(position*cos(time*0.1), time * 0.04)*mat3(1,cos(1.0),0,0,.8,.6,0,-.6,.8),0.8);
float lum = length(n);
float lum2 = length(n2);
vec3 tc = pow(vec3(1.0-lum),vec3(sin(position.x)+cos(time)+4.0,8.0+sin(time)+4.0,8.0));
vec3 tc2 = pow(vec3(1.1-lum2),vec3(5.0,position.y+cos(time)+7.0,sin(position.x)+sin(time)+2.0));
vec3 curr_color = (tc*0.8) + (tc2*0.5);
// 256 angle steps
float angle = atan(positionStars.y,positionStars.x)/(2.*3.14159265359);
angle += rads*0.5;
angle -= floor(angle);
float rad = length(positionStars);
float color = 0.0;
for (int i = 0; i < 10; i++) {
float angleFract = fract(angle*256.);
float angleRnd = floor(angle*256.)+1.;
float angleRnd1 = fract(angleRnd*fract(angleRnd*.7235)*45.1);
float angleRnd2 = fract(angleRnd*fract(angleRnd*.82657)*13.724);
float t = time+angleRnd1*10.;
float radDist = sqrt(angleRnd2+float(i));
float adist = radDist/rad*.1;
float dist = (t*.1+adist);
dist = abs(fract(dist)-.5);
color += max(0.,.5-dist*40./adist)*(.5-abs(angleFract-.5))*5./adist/radDist;
angle = fract(angle+.61);
}
float color1 = color*rad;
//curr_color += color/(n+n2);
gl_FragColor = vec4(curr_color, 1.0)+vec4( color1,color1,color,color1)/(n+n2);
}

View File

@@ -0,0 +1,31 @@
//http://glsl.heroku.com/e#5398.8
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
void main( void ) {
float scale = resolution.y / 100.0;
float ring = 50.0;
float radius = resolution.x*1.0;
float gap = scale*.5;
vec2 pos = gl_FragCoord.xy - resolution.xy*.5;
float d = length(pos);
// Create the wiggle
d += (sin(pos.y*0.25/scale+time)*sin(pos.x*0.25/scale+time*.5))*scale*2.0;
// Compute the distance to the closest ring
float v = mod(d + radius/(ring*2.0), radius/ring);
v = abs(v - radius/(ring*2.0));
v = clamp(v-gap, 0.0, 1.0);
d /= radius;
vec3 m = fract((d-1.0)*vec3(ring*-.5, -ring, ring*.25)*0.5);
gl_FragColor = vec4( m*v, 1.0 );
}

View File

@@ -0,0 +1,128 @@
//http://glsl.heroku.com/e#5454.21
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
// from http://glsl.heroku.com/e#5484.0
vec3 asteroids( vec2 position ) {
// 256 angle steps
float angle = atan(position.y,position.x)/(2.*3.14159265359);
angle -= floor(angle);
float rad = length(position);
float color = 0.0;
for (int i = 0; i < 5; i++) {
float angleFract = fract(angle*256.);
float angleRnd = floor(angle*256.)+1.;
float angleRnd1 = fract(angleRnd*fract(angleRnd*.7235)*45.1);
float angleRnd2 = fract(angleRnd*fract(angleRnd*.82657)*13.724);
float t = -time+angleRnd1*10.;
float radDist = sqrt(angleRnd2+float(i));
float adist = radDist/rad*.1;
float dist = (t*.1+adist);
dist = abs(fract(dist)-.5);
color += max(0.,.5-dist*40./adist)*(.5-abs(angleFract-.5))*5./adist/radDist;
angle = fract(angle+.61);
}
return vec3( color )*.3;
}
// from http://glsl.heroku.com/e#5248.0
#define BIAS 0.1
#define SHARPNESS 3.0
vec3 star(vec2 position, float BLADES) {
float blade = clamp(pow(sin(atan(position.y,position.x )*BLADES)+BIAS, SHARPNESS), 0.0, 1.0);
vec3 color = mix(vec3(-0.34, -0.5, -1.0), vec3(0.0, -0.5, -1.0), (position.y + 1.0) * 0.25);
float d = 1.0/length(position) * 0.075;
color += vec3(0.95, 0.65, 0.30) * d;
color += vec3(0.95, 0.45, 0.30) * min(1.0, blade *0.7) * d;
return color;
}
vec3 star2(vec2 position, float BLADES) {
float blade = clamp(pow(sin(atan(position.y,position.x )*BLADES + time*.5)+BIAS, 8.0), 0.0, 1.0);
vec3 color = mix(vec3(-0.34, -0.5, -0.0), vec3(0.0, -0.5, -0.0), (position.y + 1.0) * 0.25);
float d = 1.0/length(position) * 0.075;
color += vec3(0.95, 0.65, 0.30) * d;
color += vec3(0.95, 0.45, 0.30) * min(1.0, blade *0.7)*0.5;
return max(color.rgb, 0.0)*.5;
}
// Tweaked from http://glsl.heroku.com/e#4982.0
float hash( float n ) { return fract(sin(n)*43758.5453); }
float noise( in vec2 x )
{
vec2 p = floor(x);
vec2 f = fract(x);
f = f*f*(3.0-2.0*f);
float n = p.x + p.y*57.0;
float res = mix(mix(hash(n+0.0), hash(n+1.0),f.x), mix(hash(n+57.0), hash(n+58.0),f.x),f.y);
return res;
}
vec3 cloud(vec2 p) {
vec3 f = vec3(0.0);
f += 0.5000*noise(p*10.0)*vec3(.45, .55, 1.0);
f += 0.2500*noise(p*20.0)*vec3(.85, .45, 1.0);
f += 0.1250*noise(p*40.0)*vec3(1.0, .00, 0.3);
f += 0.0625*noise(p*80.0)*vec3(1.0, 1.0, 1.0);
return f*.5;
}
const float SPEED = 0.005;
const float SCALE = 80.0;
const float DENSITY = 1.5;
const float BRIGHTNESS = 10.0;
vec2 ORIGIN = resolution.xy*.5;
float rand(vec2 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); }
vec3 layer(float i, vec2 pos, float dist, vec2 coord) {
float a = pow((1.0-dist),20.0);
float t = i*10.0 - time*i*i;
float r = coord.x - (t*SPEED);
float c = fract(a+coord.y + i*.543);
vec2 p = vec2(r, c*.5)*SCALE*(4.0/(i*i));
vec2 uv = fract(p)*2.0-1.0;
float m = clamp((rand(floor(p))-DENSITY/i)*BRIGHTNESS, 0.0, 1.0);
return clamp(star(uv*.5, 6.0)*m*dist, 0.0, 1.0);
}
void main( void ) {
vec2 pos = gl_FragCoord.xy - ORIGIN ;
float dist = length(pos) / resolution.y;
vec2 coord = vec2(pow(dist, 0.1), atan(pos.x, pos.y) / (3.1415926*2.0));
// Nebulous cloud
vec3 color = cloud(pos/resolution);
// Background stars
float a = pow((1.0-dist),20.0);
float t = time*-.05;
float r = coord.x - (t*0.005);
float c = fract(a+coord.y + 0.0*.543);
vec2 p = vec2(r, c*.5)*4000.0;
vec2 uv = fract(p)*2.0-1.0;
float m = clamp((rand(floor(p))-.9)*10.0, 0.0, 1.0);
color += clamp((1.0-length(uv*2.0))*m*dist, 0.0, 1.0);
color += asteroids(pos/resolution.x);
// Flying stars into black hole
color += layer(2.0, pos, dist, coord);
color += layer(3.0, pos, dist, coord);
color += layer(4.0, pos, dist, coord);
color += star2(pos/resolution, 2.0);
gl_FragColor = vec4(color, 1.0);
}

View File

@@ -0,0 +1,127 @@
//http://glsl.heroku.com/e#5492.0
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
// Helper constants
#define F2 0.366025403
#define G2 0.211324865
#define K 0.0243902439 // 1/41
// Permutation polynomial
float permute(float x) {
return mod((34.0 * x + 1.0)*x, 289.0);
}
// Gradient mapping with an extra rotation.
vec2 grad2(vec2 p, float rot) {
#if 1
// Map from a line to a diamond such that a shift maps to a rotation.
float u = permute(permute(p.x) + p.y) * K + rot; // Rotate by shift
u = 4.0 * fract(u) - 2.0;
return vec2(abs(u)-1.0, abs(abs(u+1.0)-2.0)-1.0);
#else
#define TWOPI 6.28318530718
// For more isotropic gradients, sin/cos can be used instead.
float u = permute(permute(p.x) + p.y) * K + rot; // Rotate by shift
u = fract(u) * TWOPI;
return vec2(cos(u), sin(u));
#endif
}
float srdnoise(in vec2 P, in float rot, out vec2 grad) {
// Transform input point to the skewed simplex grid
vec2 Ps = P + dot(P, vec2(F2));
// Round down to simplex origin
vec2 Pi = floor(Ps);
// Transform simplex origin back to (x,y) system
vec2 P0 = Pi - dot(Pi, vec2(G2));
// Find (x,y) offsets from simplex origin to first corner
vec2 v0 = P - P0;
// Pick (+x, +y) or (+y, +x) increment sequence
vec2 i1 = (v0.x > v0.y) ? vec2(1.0, 0.0) : vec2 (0.0, 1.0);
// Determine the offsets for the other two corners
vec2 v1 = v0 - i1 + G2;
vec2 v2 = v0 - 1.0 + 2.0 * G2;
// Wrap coordinates at 289 to avoid float precision problems
Pi = mod(Pi, 289.0);
// Calculate the circularly symmetric part of each noise wiggle
vec3 t = max(0.5 - vec3(dot(v0,v0), dot(v1,v1), dot(v2,v2)), 0.0);
vec3 t2 = t*t;
vec3 t4 = t2*t2;
// Calculate the gradients for the three corners
vec2 g0 = grad2(Pi, rot);
vec2 g1 = grad2(Pi + i1, rot);
vec2 g2 = grad2(Pi + 1.0, rot);
// Compute noise contributions from each corner
vec3 gv = vec3(dot(g0,v0), dot(g1,v1), dot(g2,v2)); // ramp: g dot v
vec3 n = t4 * gv; // Circular kernel times linear ramp
// Compute partial derivatives in x and y
vec3 temp = t2 * t * gv;
vec3 gradx = temp * vec3(v0.x, v1.x, v2.x);
vec3 grady = temp * vec3(v0.y, v1.y, v2.y);
grad.x = -8.0 * (gradx.x + gradx.y + gradx.z);
grad.y = -8.0 * (grady.x + grady.y + grady.z);
grad.x += dot(t4, vec3(g0.x, g1.x, g2.x));
grad.y += dot(t4, vec3(g0.y, g1.y, g2.y));
grad *= 40.0;
// Add contributions from the three corners and return
return 40.0 * (n.x + n.y + n.z);
}
vec2 complex_mul(vec2 factorA, vec2 factorB){
return vec2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x);
}
vec2 torus_mirror(vec2 uv){
return vec2(1.)-abs(fract(uv*.5)*2.-1.);
}
float sigmoid(float x) {
return 2./(1. + exp2(-x)) - 1.;
}
float smoothcircle(vec2 uv, float radius, float sharpness){
return 0.5 - sigmoid( ( length( (uv - 0.5)) - radius) * sharpness) * 0.5;
}
void main() {
vec2 posScale = vec2(2.0);
vec2 aspect = vec2(1.,resolution.y/resolution.x);
vec2 uv = 0.5 + (gl_FragCoord.xy * vec2(1./resolution.x,1./resolution.y) - 0.5)*aspect;
float mouseW = atan((mouse.y - 0.5)*aspect.y, (mouse.x - 0.5)*aspect.x);
vec2 mousePolar = vec2(sin(mouseW), cos(mouseW));
vec2 offset = (mouse - 0.5)*4.;
offset = - complex_mul(offset, mousePolar) +time*0.0;
vec2 uv_distorted = uv;
float filter = smoothcircle( -mouse + 0.5 +uv_distorted, 0.15, 64.);
uv_distorted = complex_mul(((uv_distorted - 0.5)*mix(2., 12., filter)), mousePolar) + offset;
vec2 p = uv_distorted;
vec2 g1, g2;
// vec2 p = ( gl_FragCoord.xy / resolution.xy ) * 6.0;
float n1 = srdnoise(p*0.5, 0.0*time, g1);
float n2 = srdnoise(p*2.0 + g1*0.5, 0.51*time, g2);
float n3 = srdnoise(p*4.0 + g1*0.5 + g2*0.25, 0.77*time, g2);
gl_FragColor = vec4(vec3(0.4, 0.5, 0.6) + vec3(n1+0.75*n2+0.5*n3), 1.0);
}

View File

@@ -0,0 +1,24 @@
//http://glsl.heroku.com/e#5733.0
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
varying vec2 surfacePosition;
void main( void ) {
vec2 p = surfacePosition;
float speed = 0.25;
vec3 color = vec3(0.5,0.2,0.1);
vec2 loc = vec2(cos(time/4.0*speed)/1.9-cos(time/2.0*speed)/3.8,
sin(time/4.0*speed)/1.9-sin(time/2.0*speed)/3.8
);
float depth;
for(int i = 0; i < 100; i+=1){
p = vec2(p.x*p.x-p.y*p.y,2.0*p.y*p.x)+loc;
depth = float(i);
if((p.x*p.x-p.y*p.y) >= 25.0) break;
}
gl_FragColor = vec4(clamp(color*depth*0.9, 0.0, 2.0)*mod(gl_FragCoord.y, 2.0), 2.0 );
}

View File

@@ -0,0 +1,44 @@
//http://glsl.heroku.com/e#5805.18
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
float function_f (float x) {
return + mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x+200.0)*0.1))
- mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x+100.0)*0.1))
+ mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp(x*0.1))
- mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x-100.0)*0.1))
+ mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x-200.0)*0.1))
+ sin(x*0.1 - time*10.0 + mouse.x * 10.0)*50.0;
}
float function_g (float x) {
return - mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x+200.0)*0.1))
+ mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x+100.0)*0.1))
- mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp(x*0.1))
+ mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x-100.0)*0.1))
- mouse.y * 0.5 * 2.0 * resolution.y / 4.0 / (1.0 + exp((x-200.0)*0.1))
+ sin(x*0.1 + time*5.0 - mouse.x * 10.0)*50.0;
}
void main( void ) {
vec3 color_1 = vec3(0.25, sin(time), cos(time));
vec3 color_2 = vec3(0.5, 0.25, cos(time));
vec2 pos = gl_FragCoord.xy;
pos.y -= resolution.y / 2.0;
pos.x -= resolution.x / 2.0;
float intensity_f = 16.0 / abs(pos.y - function_f(pos.x));
intensity_f = pow(intensity_f, 0.5);
float intensity_g = 16.0 / abs(pos.y - function_g(pos.x));
intensity_g += pow(intensity_g, 0.5);
gl_FragColor = vec4((color_1 * intensity_f + color_2 * intensity_g)*mod(gl_FragCoord.y, 2.0), 1);
}

View File

@@ -0,0 +1,44 @@
//http://glsl.heroku.com/e#5812
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
float random(vec2 v)
{
return fract(sin(dot(v ,vec2(13.9898,78.233))) * (10000.0+time*0.05));
}
void main( void )
{
const int numColors = 3;
vec3 colors[numColors];
colors[0] = vec3( 0.3, 0.8, 0.8);
colors[1] = vec3( 0.8, 0.9, 0.4);
colors[2] = vec3( 0.4, 0.4, 0.5);
vec2 screenPos = gl_FragCoord.xy;
vec2 screenPosNorm = gl_FragCoord.xy / resolution.xy;
vec2 position = screenPosNorm + mouse / 4.0;
// calc block
vec2 screenBlock0 = floor(screenPos*0.16 + vec2(time,0) + mouse*3.0);
vec2 screenBlock1 = floor(screenPos*0.08 + vec2(time*1.5,0) + mouse*5.0);
vec2 screenBlock2 = floor(screenPos*0.02 + vec2(time*2.0,0)+mouse*10.0);
float rand0 = random(screenBlock0);
float rand1 = random(screenBlock1);
float rand2 = random(screenBlock2);
float rand = rand1;
if ( rand2 < 0.05 ) { rand = rand2; }
// block color
vec3 color = mix( colors[0], colors[1], pow(rand,5.0) );
if ( rand < 0.05 ) { color=colors[2]; }
float vignette = 1.6-length(screenPosNorm*2.0-1.0);
vec4 finalColor = vec4(color*vignette, 1.0);
gl_FragColor = finalColor;
}

View File

@@ -0,0 +1,40 @@
//http://glsl.heroku.com/e#5891.5
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
const float Tau = 6.2832;
const float speed = .02;
const float density = .04;
const float shape = .04;
float random( vec2 seed ) {
return fract(sin(seed.x+seed.y*1e3)*1e5);
}
float Cell(vec2 coord) {
vec2 cell = fract(coord) * vec2(.5,2.) - vec2(.0,.5);
return (1.-length(cell*2.-1.))*step(random(floor(coord)),density)*2.;
}
void main( void ) {
vec2 p = gl_FragCoord.xy / resolution - mouse;
float a = fract(atan(p.x, p.y) / Tau);
float d = length(p);
vec2 coord = vec2(pow(d, shape), a)*256.;
vec2 delta = vec2(-time*speed*256., .5);
float c = 0.;
for(int i=0; i<3; i++) {
coord += delta;
c = max(c, Cell(coord));
}
gl_FragColor = vec4(c * d);
}

View File

@@ -0,0 +1,84 @@
//http://glsl.heroku.com/e#6022.0
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
varying vec2 surfacePosition;
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43748.5453);
}
float cerp(float a, float b, float i)
{
if(i<0.)
i += 1.;
i *= 3.14159265;
i = (1.-cos(i))/2.;
return a*(1.-i)+b*i;
}
float lerp(float a, float b, float i)
{
if(i<0.)
i+=1.;
return a*(1.-i)+b*i;
}
vec3 lerp(vec3 a, vec3 b, float i)
{
if(i<0.)
i+=1.;
return a*(1.-i)+b*i;
}
float posrand(vec2 pos, float width, float height)
{
return rand(vec2(int(pos.x*width),int(pos.y*height)));
}
float tdposrand(vec2 pos, float width, float height)
{
float n1, n2, n3, n4, n5, n6;
n1 = posrand(pos,width,height);
n2 = posrand(vec2(pos.x+1./width,pos.y),width,height);
n3 = posrand(vec2(pos.x,pos.y+1./height),width,height);
n4 = posrand(vec2(pos.x+1./width,pos.y+1./height),width,height);
n5 = cerp(n1,n2,pos.x*width-float(int(pos.x*width)));
n6 = cerp(n3,n4,pos.x*width-float(int(pos.x*width)));
return cerp(n5,n6,pos.y*height-float(int(pos.y*height)));
}
vec3 readcolpath(vec3 one, vec3 two, vec3 thr, vec3 fou, float i)
{
int num = int(i*3.);
if(num==0)
return lerp(one,two,i*3.-float(num));
if(num==1)
return lerp(two,thr,i*3.-float(num));
if(num==2)
return lerp(thr,fou,i*3.-float(num));
return fou;
}
void main( void ) {
vec2 position = surfacePosition+.5;
vec2 odd = vec2(0,time/5.);
vec3 col1 = vec3(1.,0.25,0.);
vec3 col2 = vec3(.45,0.2,0.);
vec3 col3 = vec3(0.2,.1,0.);
vec3 col4 = vec3(.4,.3,.25);
float color = 0.0;
position = position*(1.+1./12.)+vec2(length(vec2(tdposrand(position-odd,2.,2.),tdposrand(position*4.3-odd,2.,2.))))/12.;
if(position.y>0.)
{
//color += tdposrand(position-odd,1000.,1000.)/5.;
color += tdposrand(position-odd,50.,50.)/8.;
color += tdposrand(position-odd,20.,20.)/3.;
color += tdposrand(position-odd,10.,10.)/2.;
color += tdposrand(position-odd,5.,5.);
color /= position.y*1.;
}
else
{
color = 16.0;
}
gl_FragColor = vec4( vec3( color/2. )*readcolpath(col1,col2,col3,col4,color/16.), 1.0 );
}

View File

@@ -0,0 +1,137 @@
//http://glsl.heroku.com/e#6043.1
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
//.h
vec3 sim(vec3 p,float s);
vec2 rot(vec2 p,float r);
vec2 rotsim(vec2 p,float s);
//nice stuff :)
vec2 makeSymmetry(vec2 p){
vec2 ret=p;
ret=rotsim(ret,5.08052);
ret.x=abs(ret.x);
return ret;
}
float makePoint(float x,float y,float fx,float fy,float sx,float sy,float t){
float xx=x+tan(t*fx)*sx;
float yy=y-tan(t*fy)*sy;
return 0.5/sqrt(abs(x*xx+yy*yy));
}
//util functions
const float PI=5.08052;
vec3 sim(vec3 p,float s){
vec3 ret=p;
ret=p+s/2.0;
ret=fract(ret/s)*s-s/2.0;
return ret;
}
vec2 rot(vec2 p,float r){
vec2 ret;
ret.x=p.x*cos(r)-p.y*sin(r);
ret.y=p.x*sin(r)+p.y*cos(r);
return ret;
}
vec2 rotsim(vec2 p,float s){
vec2 ret=p;
ret=rot(p,-PI/(s*2.0));
ret=rot(p,floor(atan(ret.x,ret.y)/PI*s)*(PI/s));
return ret;
}
//Util stuff end
vec2 complex_mul(vec2 factorA, vec2 factorB){
return vec2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x);
}
vec2 torus_mirror(vec2 uv){
return vec2(1.)-abs(fract(uv*.5)*2.-1.);
}
float sigmoid(float x) {
return 2./(1. + exp2(-x)) - 1.;
}
float smoothcircle(vec2 uv, float radius, float sharpness){
return 0.5 - sigmoid( ( length( (uv - 0.5)) - radius) * sharpness) * 0.5;
}
void main() {
vec2 posScale = vec2(2.0);
vec2 aspect = vec2(1.,resolution.y/resolution.x);
vec2 uv = 0.5 + (gl_FragCoord.xy * vec2(1./resolution.x,1./resolution.y) - 0.5)*aspect;
float mouseW = atan((mouse.y - 0.5)*aspect.y, (mouse.x - 0.5)*aspect.x);
vec2 mousePolar = vec2(sin(mouseW), cos(mouseW));
vec2 offset = (mouse - 0.5)*2.*aspect;
offset = - complex_mul(offset, mousePolar) +time*0.0;
vec2 uv_distorted = uv;
float filter = smoothcircle( uv_distorted, 0.12, 100.);
uv_distorted = complex_mul(((uv_distorted - 0.5)*mix(2., 6., filter)), mousePolar) + offset;
vec2 p=(gl_FragCoord.xy/resolution.x)*2.0-vec2(1.0,resolution.y/resolution.x);
p = uv_distorted;
p.y=-p.y;
p=p*2.0;
p=makeSymmetry(p);
float x=p.x;
float y=p.y;
float t=time*0.1618;
float a=
makePoint(x,y,3.3,2.9,0.3,0.3,t);
a=a+makePoint(x,y,1.9,2.0,0.4,0.4,t);
a=a+makePoint(x,y,0.8,0.7,0.4,0.5,t);
a=a+makePoint(x,y,2.3,0.1,0.6,0.3,t);
a=a+makePoint(x,y,0.8,1.7,0.5,0.4,t);
a=a+makePoint(x,y,0.3,1.0,0.4,0.4,t);
a=a+makePoint(x,y,1.4,1.7,0.4,0.5,t);
a=a+makePoint(x,y,1.3,2.1,0.6,0.3,t);
a=a+makePoint(x,y,1.8,1.7,0.5,0.4,t);
float b=
makePoint(x,y,1.2,1.9,0.3,0.3,t);
b=b+makePoint(x,y,0.7,2.7,0.4,0.4,t);
b=b+makePoint(x,y,1.4,0.6,0.4,0.5,t);
b=b+makePoint(x,y,2.6,0.4,0.6,0.3,t);
b=b+makePoint(x,y,0.7,1.4,0.5,0.4,t);
b=b+makePoint(x,y,0.7,1.7,0.4,0.4,t);
b=b+makePoint(x,y,0.8,0.5,0.4,0.5,t);
b=b+makePoint(x,y,1.4,0.9,0.6,0.3,t);
b=b+makePoint(x,y,0.7,1.3,0.5,0.4,t);
float c=
makePoint(x,y,3.7,0.3,0.3,0.3,t);
c=c+makePoint(x,y,1.9,1.3,0.4,0.4,t);
c=c+makePoint(x,y,0.8,0.9,0.4,0.5,t);
c=c+makePoint(x,y,1.2,1.7,0.6,0.3,t);
c=c+makePoint(x,y,0.3,0.6,0.5,0.4,t);
c=c+makePoint(x,y,0.3,0.3,0.4,0.4,t);
c=c+makePoint(x,y,1.4,0.8,0.4,0.5,t);
c=c+makePoint(x,y,0.2,0.6,0.6,0.3,t);
c=c+makePoint(x,y,1.3,0.5,0.5,0.4,t);
vec3 d=vec3(a+b,b+c,c)/32.0;
gl_FragColor = vec4(d.x,d.y,d.z,1.0);
}

View File

@@ -0,0 +1,189 @@
//http://glsl.heroku.com/e#6049.0
uniform vec2 resolution;
uniform float time;
uniform vec2 mouse;
//Util Start
float PI=3.14159265;
vec2 ObjUnion(
in vec2 obj0,
in vec2 obj1)
{
if (obj0.x<obj1.x)
return obj0;
else
return obj1;
}
vec2 sim2d(
in vec2 p,
in float s)
{
vec2 ret=p;
ret=p+s/2.0;
ret=fract(ret/s)*s-s/2.0;
return ret;
}
vec3 stepspace(
in vec3 p,
in float s)
{
return p-mod(p-s/2.0,s);
}
vec3 phong(
in vec3 pt,
in vec3 prp,
in vec3 normal,
in vec3 light,
in vec3 color,
in float spec,
in vec3 ambLight)
{
vec3 lightv=normalize(light-pt);
float diffuse=dot(normal,lightv);
vec3 refl=-reflect(lightv,normal);
vec3 viewv=normalize(prp-pt);
float specular=pow(max(dot(refl,viewv),0.0),spec);
return (max(diffuse,0.0)+ambLight)*color+specular;
}
//Util End
//Scene Start
vec2 obj(in vec3 p)
{
vec3 fp=stepspace(p,2.0);;
float d=sin(fp.x*0.3+time*4.0)+cos(fp.z*0.3+time*2.0);
p.y=p.y+d;
p.xz=sim2d(p.xz,2.0);
float c1=length(max(abs(p)-vec3(0.6,0.6,0.6),0.0))-0.35;
float c2=length(p)-1.0;
float cf=sin(time)*0.5+0.5;
return vec2(mix(c1,c2,cf),1.0);
}
vec3 obj_c(vec3 p){
vec2 fp=sim2d(p.xz-1.0,4.0);
if (fp.y>0.0) fp.x=-fp.x;
if (fp.x>0.0) return vec3(0.0,0.0,0.0);
else return vec3(1.0,1.0,1.0);
}
//Scene End
float raymarching(
in vec3 prp,
in vec3 scp,
in int maxite,
in float precis,
in float startf,
in float maxd,
out float objid)
{
const vec3 e=vec3(0.1,0,0.0);
vec2 s=vec2(startf,0.0);
vec3 c,p,n;
float f=startf;
for(int i=0;i<256;i++){
if (abs(s.x)<precis||f>maxd||i>maxite) break;
f+=s.x;
p=prp+scp*f;
s=obj(p);
objid=s.y;
}
if (f>maxd) objid=-1.0;
return f;
}
vec3 camera(
in vec3 prp,
in vec3 vrp,
in vec3 vuv,
in float vpd)
{
vec2 vPos=-1.0+2.0*gl_FragCoord.xy/resolution.xy;
vec3 vpn=normalize(vrp-prp);
vec3 u=normalize(cross(vuv,vpn));
vec3 v=cross(vpn,u);
vec3 scrCoord=prp+vpn*vpd+vPos.x*u*resolution.x/resolution.y+vPos.y*v;
return normalize(scrCoord-prp);
}
vec3 normal(in vec3 p)
{
//tetrahedron normal
const float n_er=0.01;
float v1=obj(vec3(p.x+n_er,p.y-n_er,p.z-n_er)).x;
float v2=obj(vec3(p.x-n_er,p.y-n_er,p.z+n_er)).x;
float v3=obj(vec3(p.x-n_er,p.y+n_er,p.z-n_er)).x;
float v4=obj(vec3(p.x+n_er,p.y+n_er,p.z+n_er)).x;
return normalize(vec3(v4+v1-v3-v2,v3+v4-v1-v2,v2+v4-v3-v1));
}
vec3 render(
in vec3 prp,
in vec3 scp,
in int maxite,
in float precis,
in float startf,
in float maxd,
in vec3 background,
in vec3 light,
in float spec,
in vec3 ambLight,
out vec3 n,
out vec3 p,
out float f,
out float objid)
{
objid=-1.0;
f=raymarching(prp,scp,maxite,precis,startf,maxd,objid);
if (objid>-0.5){
p=prp+scp*f;
vec3 c=obj_c(p);
n=normal(p);
vec3 cf=phong(p,prp,n,light,c,spec,ambLight);
return vec3(cf);
}
f=maxd;
return vec3(background); //background color
}
void main(void){
//Camera animation
vec3 vuv=vec3(0,1,0);
vec3 vrp=vec3(time*4.0,0.0,0.0);
float mx=mouse.x*PI*2.0;
float my=mouse.y*PI/2.01;
vec3 prp=vrp+vec3(cos(my)*cos(mx),sin(my),cos(my)*sin(mx))*12.0; //Trackball style camera pos
float vpd=1.5;
vec3 light=prp+vec3(5.0,0,5.0);
vec3 scp=camera(prp,vrp,vuv,vpd);
vec3 n,p;
float f,o;
const float maxe=0.01;
const float startf=0.1;
const vec3 backc=vec3(0.0,0.0,0.0);
const float spec=8.0;
const vec3 ambi=vec3(0.1,0.1,0.1);
vec3 c1=render(prp,scp,256,maxe,startf,60.0,backc,light,spec,ambi,n,p,f,o);
c1=c1*max(1.0-f*.015,0.0);
vec3 c2=backc;
if (o>0.5){
scp=reflect(scp,n);
c2=render(p+scp*0.05,scp,32,maxe,startf,10.0,backc,light,spec,ambi,n,p,f,o);
}
c2=c2*max(1.0-f*.1,0.0);
gl_FragColor=vec4(c1.xyz*0.75+c2.xyz*0.25,1.0);
}

View File

@@ -0,0 +1,59 @@
//http://glsl.heroku.com/e#6147.1
#define PI 3.14159265
uniform float time;
uniform vec2 mouse, resolution;
vec3 sim(vec3 p,float s); //.h
vec2 rot(vec2 p,float r);
vec2 rotsim(vec2 p,float s);
vec2 makeSymmetry(vec2 p){ //nice stuff :)
vec2 ret=p;
ret=rotsim(p, 6.0);
ret.x=abs(ret.x);
return ret;
}
float makePoint(float x,float y,float fx,float fy,float sx,float sy,float t){
float xx=x+tan(t * fx)*sy;
float yy=y-tan(t * fx)*sy;
return 0.8/sqrt(abs(x*xx+yy*yy));
}
vec2 sim(vec2 p,float s){
vec2 ret=p;
ret=p+s/2.0;
ret=fract(ret/s)*s-s/2.0;
return ret;
}
vec2 rot(vec2 p,float r){
vec2 ret;
ret.x=p.x*cos(r)-p.y*sin(r);
ret.y=p.x*sin(r)+p.y*cos(r);
return ret;
}
vec2 rotsim(vec2 p,float s){
float k = atan(p.x, p.y);
vec2 ret=rot(p,floor((k + PI/(s*2.0)) / PI*s)*(PI/s));
return ret;
}
void main( void ) {
vec2 p=(gl_FragCoord.xy/resolution.x)*2.0-vec2(1.0,resolution.y/resolution.x);
p=makeSymmetry(p);
float x=p.x;
float y=p.y;
float t=time*0.2;
float a= makePoint(x,y,3.3,2.9,0.3,0.3,t);
// a=a+makePoint(x,y,1.8,1.7,0.5,0.4,t);
float b=makePoint(x,y,1.2,1.9,0.3,0.3,t);
// b=b+makePoint(x,y,0.7,2.7,0.4,0.4,t);
float c=makePoint(x,y,3.7,0.3,0.3,0.3,t);
// c=c+makePoint(x,y,0.8,0.9,0.4,0.5,t);
gl_FragColor = vec4(a/5.,b/5.,c/5.,1.0);
}

View File

@@ -0,0 +1,92 @@
//http://glsl.heroku.com/e#6162.0
#define PI 3.141592653589793
#define ZOOM (4. - sin(time/2.)*3.)
#define MAX_ITERATION 6
#define ITERATION_BAIL sqrt(PI/2.)
#define MAX_MARCH 50
#define MAX_DISTANCE 2.3
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
float DE(vec3 p)
{
vec3 w = p;
float dr = 1.;
float r = 0.;
for (int i=0; i<MAX_ITERATION; ++i)
{
r = length(w);
if (r>ITERATION_BAIL) break;
dr*=pow(r, 7.)*8.+1.;
float x = w.x; float x2 = x*x; float x4 = x2*x2;
float y = w.y; float y2 = y*y; float y4 = y2*y2;
float z = w.z; float z2 = z*z; float z4 = z2*z2;
float k3 = x2 + z2;
float k2 = inversesqrt( pow(k3, 7.) );
float k1 = x4 + y4 + z4 - 6.0*y2*z2 - 6.0*x2*y2 + 2.0*z2*x2;
float k4 = x2 - y2 + z2;
w = vec3(64.0*x*y*z*(x2-z2)*k4*(x4-6.0*x2*z2+z4)*k1*k2,
-16.0*y2*k3*k4*k4 + k1*k1,
-8.0*y*k4*(x4*x4 - 28.0*x4*x2*z2 + 70.0*x4*z4 - 28.0*x2*z2*z4 + z4*z4)*k1*k2);
w+=p;
}
return .5*log(r)*r/dr;
}
bool inCircle(vec3 p, vec3 d)
{
float rdt = dot(p, d);
float rdr = dot(p, p) - 1.253314137315501; // sqrt(PI/2)
return (rdt*rdt)-rdr>0.;
}
void main( void )
{
vec2 pos = (gl_FragCoord.xy*2.0 - resolution.xy) / resolution.y;
vec2 m = vec2(sin(time), cos(time))/ZOOM;
//m = ((.5-mouse)*PI*2.)/ZOOM;
m.y = clamp(m.y, -PI/2.+.01, PI/2.-.01);
vec3 camOrigin = vec3(cos(m.x)*cos(m.y), sin(m.y), cos(m.y)*sin(m.x))*2.0;
vec3 camTarget = vec3(0.0, 0.0, 0.0);
vec3 camDir = normalize(camTarget - camOrigin);
vec3 camUp = normalize(vec3(0.0, 1.0, 0.0));
vec3 camSide = normalize(cross(camDir, camUp));
vec3 camCDS = cross(camDir, camSide);
vec3 ray = normalize(camSide*pos.x + camCDS*pos.y + camDir*ZOOM);
float col = 0., col2 = 0., col3 = 0.;
if (inCircle(camOrigin, ray))
{
float m = 1.0, dist = 0.0, total_dist = 0.0;
for(int i=0; i<MAX_MARCH; ++i)
{
total_dist += dist;
dist = DE(camOrigin + ray * total_dist);
m -= 0.02;
if(dist<0.002/ZOOM || total_dist>MAX_DISTANCE) break;
}
col = m;
col2 = m*2.5-total_dist;
col3 = m*1.5-total_dist;
if (total_dist>MAX_DISTANCE) col = 0.;
}
gl_FragColor = vec4(col, col2/2., col3*2., 1.0);
}

View File

@@ -0,0 +1,225 @@
//http://glsl.heroku.com/e#6175.0
uniform float time;
uniform vec2 resolution;
uniform vec4 mouse;
uniform sampler2D tex0;
uniform sampler2D tex1;
const float M_PI = 3.14159265358979323846;
struct SphereIntersection
{
// IN:
vec4 sphere;
vec3 ro;
vec3 rd;
// OUT:
float t;
vec3 pos;
vec3 normal;
float depth;
};
float saturate(float f)
{
return clamp(f,0.0,1.0);
}
vec3 saturate(vec3 v)
{
return clamp(v,vec3(0,0,0),vec3(1,1,1));
}
// ... I went on the internet and I found THIS
float rand(vec2 co)
{
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
// Theta, Phi (r == 1)
vec2 normalToSpherical(vec3 normal)
{
vec2 spherical;
// Flip ZY.
normal.yz = normal.zy;
spherical.x = atan(normal.y,normal.x); // Theta
spherical.y = acos(normal.z); // Phi
return spherical;
}
// Input: Theta, Phi
vec3 sphericalToCartesian(vec2 s)
{
vec3 cart;
cart.x = cos(s.x) * sin(s.y);
cart.y = sin(s.x) * sin(s.y);
cart.z = cos(s.y);
// Flip ZY
cart.yz = cart.zy;
return cart;
}
// Ray origin, Ray direction, (Sphere center, Sphere radius)
void raySphere(inout SphereIntersection i)
{
vec4 sphere = i.sphere;
vec3 ro = i.ro;
vec3 rd = i.rd;
vec3 sc = sphere.xyz;
float sr = sphere.w;
vec3 sd = ro-sc;
// a == 1
float b = 2.0*dot(rd,sd);
float c = dot(sd,sd)-(sr*sr);
float disc = b*b - 4.0*c;
if(disc<0.0)
{
i.t = -1.0;
return;
}
float t = (-b-sqrt(disc))/2.0;
i.t = t;
i.pos = ro+rd*t;
i.normal = normalize(i.pos-sphere.xyz);
i.depth = 2.0*sr*dot(normalize(sd),i.normal);
}
vec3 sphereNormal(vec4 sphere, vec3 point)
{
return normalize(point-sphere.xyz);
}
float sphereFunction(vec2 coord)
{
coord.x -= time/4.0;
coord.y += sin(time/4.0);
float thetaCoeff = 24.0;
float phiCoeff = 16.0;
float height = 0.8;
height += (sin(3.0*coord.y)*sin(4.0*coord.x))/10.0;
height += (sin(16.0*coord.y)*sin(24.0*coord.x))/10.0;
return height;
}
vec3 sphereFunctionNormal(vec2 coord, vec4 sphere)
{
// Approximates the local slope of the heightfield function
float d = 0.01;
vec2 s0coord = coord; // Center
vec2 s1coord = coord+vec2(d,0); // +X = +Theta
vec2 s2coord = coord+vec2(0,-d); // +Y = -Phi
// Sample heightfield
float s0 = sphereFunction(s0coord) * sphere.w;
float s1 = sphereFunction(s1coord) * sphere.w;
float s2 = sphereFunction(s2coord) * sphere.w;
// Convert samples to cartesian
vec3 s0c = sphericalToCartesian(s0coord)*s0;
vec3 s1c = sphericalToCartesian(s1coord)*s1;
vec3 s2c = sphericalToCartesian(s2coord)*s2;
// Tangent space
vec3 x = s1c-s0c;
vec3 y = s2c-s0c;
vec3 normal = normalize(cross(y,x));
return normal;
}
void rayMarchSphere(inout SphereIntersection i)
{
const float NUM_SAMPLES = 50.0;
vec3 pos = i.pos;
vec3 dir = i.rd;
float stepSize = i.depth/NUM_SAMPLES;
// No hit
i.t = -1.0;
for(float s = 0.0; s < NUM_SAMPLES; s++)
{
if(s == 0.0)
{
pos += dir*stepSize*rand(gl_FragCoord.xy);
}
vec3 v = pos-i.sphere.xyz;
float height = length(v);
vec3 n = v/height;
vec2 sCoord = normalToSpherical(n);
float testHeight = sphereFunction(sCoord)*i.sphere.w;
testHeight += 0.000001; // Prevent floating point error
if(height<=testHeight)
{
i.t = length(pos-i.ro);
i.pos = pos;
i.normal = n;
i.normal = sphereFunctionNormal(sCoord,i.sphere);
return;
}
pos += dir*stepSize;
}
return;
}
vec3 lighting(vec3 point, vec3 N, vec3 light, vec3 color)
{
vec3 toLight = light-point;
vec3 L = normalize(toLight);
return color*saturate(dot(N,L));
}
void rayMarchedSphereIntersection(inout SphereIntersection i)
{
// First intersect the sphere
raySphere(i);
// Then raymarch the heightfield
if(i.t > 0.0)
{
rayMarchSphere(i);
}
}
void main(void)
{
vec2 screenPos = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
vec2 screenPosAR = vec2(screenPos.x*(resolution.x/resolution.y),screenPos.y);
vec3 rayDir = normalize(vec3(screenPosAR.x,screenPosAR.y,1.0));
vec3 light = vec3(sin(time/4.0)*3.0,cos(time/5.0)*3.0,-2.0);
vec4 sphere = vec4(0.0,0.0,3.0,2.2);
SphereIntersection inter;
inter.ro = vec3(0,0,0);
inter.rd = rayDir;
inter.sphere = sphere;
rayMarchedSphereIntersection(inter);
//raySphere(inter);
vec3 color;
if(inter.t > 0.0)
{
float shadowFactor = 1.0;
SphereIntersection shadowInter;
vec3 lightDir = normalize(light-inter.pos);
shadowInter.ro = inter.pos;
shadowInter.rd = lightDir;
shadowInter.pos = inter.pos+lightDir*0.1;
shadowInter.sphere = sphere;
shadowInter.depth = sphere.w;
rayMarchSphere(shadowInter);
if(shadowInter.t > 0.0)
{
//shadowFactor = 0.0;
}
// Some crazy colors
vec3 diffuse = normalize(normalize(inter.pos-sphere.xyz)+vec3(abs(sin(time/4.0)),abs(cos(time/5.0)),abs(sin(time/5.0)*2.0)));
color.xyz = lighting(inter.pos, inter.normal, light, diffuse) * shadowFactor;
color.xyz += saturate(inter.normal.zzz+0.50)*diffuse; // Some fake backlighting
}
else
{
color.xyz = vec3(0,0,0);
}
gl_FragColor.xyz = color;
gl_FragColor.w = 1.0;
}

View File

@@ -0,0 +1,37 @@
//http://glsl.heroku.com/e#6223.2
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
// a raymarching experiment by kabuto
//fork by tigrou ind (2013.01.22)
//optimized
#define MAXITER 90
#define MAXITER_SQR MAXITER*MAXITER
vec3 field(vec3 p) {
p = abs(fract(p)-.5);
p *= p;
return sqrt(p+p.yzx*p.zzy)-.015;
}
void main( void ) {
vec3 dir = normalize(vec3((gl_FragCoord.xy-resolution*.5)/resolution.x,1.));
float a = time * 0.4;
vec3 pos = vec3(time*0.6 + sin(time)*0.2,sin(time)*0.25,-3.0);
vec3 color = vec3(0);
for (int i = 0; i < MAXITER; i++) {
vec3 f2 = field(pos);
vec3 rep = vec3(1.0,0.7+sin(time)*0.7, 1.3);
float f = min(min(min(f2.x,f2.y),f2.z), length(mod(pos-vec3(0.1),rep)-0.5*rep)-0.10);
pos += dir*f;
color += float(MAXITER-i)/(f2+.01);
}
vec3 color3 = vec3(1.-1./(1.+color*(.09/float(MAXITER_SQR))));
color3 *= color3;
gl_FragColor = vec4(vec3(color3.r+color3.g+color3.b),1.);
}

View File

@@ -0,0 +1,28 @@
//http://glsl.heroku.com/e#6238.0
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
void main( void ) {
vec3 color1 = vec3(1.7, 0.25, 0.5);
vec3 color2 = vec3(0.5, 0.7, 0.25);
vec3 color3 = vec3(0.25, 0.5, 0.7);
vec2 point1 = resolution/2.0 + vec2(sin(time*2.0) * 10.0, cos(time*2.0) * 5.0);
vec2 point2 = resolution/2.0 + vec2(sin(time)*75.0, cos(time)*50.0);
vec2 point3 = resolution/2.0 + vec2(sin(time)*25.0, sin(time*2.0)*50.0)*2.0;
vec2 dist1 = gl_FragCoord.xy - point1;
float intensity1 = pow(32.0/(0.01+length(dist1)), 2.0);
vec2 dist2 = gl_FragCoord.xy - point2;
float intensity2 = pow(3.0/(0.01+length(dist2)), 2.0);
vec2 dist3 = gl_FragCoord.xy - point3;
float intensity3 = pow(62.0/(0.01+length(dist3)), 1.0);
gl_FragColor = vec4((color1*intensity1 + color2*intensity2 + color3*intensity3)*mod(gl_FragCoord.y, 2.0),1.0);
}

View File

@@ -0,0 +1,20 @@
//http://glsl.heroku.com/e#6284.1
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
void main( void ) {
vec2 position = ( gl_FragCoord.xy / resolution.xy ) + mouse / 1.0;
float color = 0.0;
color += sin( position.x * cos( time / 15.0 ) * 80.0 ) + cos( position.y * cos( time / 15.0 ) * 10.0 );
color += sin( position.y * sin( time / 10.0 ) * 40.0 ) + cos( position.x * sin( time / 25.0 ) * 40.0 );
color += sin( position.x * sin( time / 5.0 ) * 10.0 ) + sin( position.y * sin( time / 35.0 ) * 80.0 );
color *= sin( time / 10.0 ) * 0.5;
gl_FragColor = vec4( vec3( color, color * 0.1, sin( color + time / 9.0 ) * 0.75 ), 1.0 );
}

View File

@@ -0,0 +1,23 @@
//http://glsl.heroku.com/e#6286.0
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
varying vec2 surfacePosition;
void main( void ) {
vec2 p = surfacePosition;
float speed = 0.45;
vec3 color = vec3(.4,.1,.8);
vec2 loc = vec2(cos(time/1.6*speed)/1.9-cos(time/.8*speed)/3.8,
sin(time/1.6*speed)/1.9-sin(time/.8*speed)/3.8
);
float depth;
for(int i = 0; i < 100; i+=1){
p = vec2(p.x*p.x-p.y*p.y,2.0*p.x*p.y)+loc;
depth = float(i);
if((p.x*p.x+p.y*p.y) >= 4.0) break;
}
gl_FragColor = vec4(clamp(color*depth*0.05, 0.0, 10.0)*mod(gl_FragCoord.y, 2.0), 1.0 );
}

View File

@@ -0,0 +1,32 @@
//http://glsl.heroku.com/e#6288.1
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
void main( void )
{
vec2 uPos = ( gl_FragCoord.xy / resolution.xy );//normalize wrt y axis
//suPos -= vec2((resolution.x/resolution.y)/2.0, 0.0);//shift origin to center
uPos.x -= 1.0;
uPos.y -= 0.5;
vec3 color = vec3(0.0);
float vertColor = 0.0;
for( float i = 0.0; i < 15.0; ++i )
{
float t = time * (0.9);
uPos.y += sin( uPos.x*i + t+i/2.0 ) * 0.1;
float fTemp = abs(1.0 / uPos.y / 100.0);
vertColor += fTemp;
color += vec3( fTemp*(10.0-i)/10.0, fTemp*i/10.0, pow(fTemp,1.5)*1.5 );
}
vec4 color_final = vec4(color, 1.0);
gl_FragColor = color_final;
}

View File

@@ -0,0 +1,11 @@
attribute vec3 position;
attribute vec2 surfacePosAttrib;
varying vec2 surfacePosition;
void main() {
surfacePosition = surfacePosAttrib;
gl_Position = vec4( position, 1.0 );
}

View File

@@ -0,0 +1 @@
These shaders are taken from http://glsl.heroku.com

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<project version="2">
<!-- Output SWF options -->
<output>
<movie outputType="Application" />
<movie input="" />
<movie path="project.lime" />
<movie fps="30" />
<movie width="800" />
<movie height="600" />
<movie version="3" />
<movie minorVersion="0" />
<movie platform="NME" />
<movie background="#FFFFFF" />
</output>
<!-- Other classes to be compiled into your SWF -->
<classpaths>
<class path="Source" />
</classpaths>
<!-- Build options -->
<build>
<option directives="" />
<option flashStrict="False" />
<option mainClass="" />
<option enabledebug="False" />
<option additional="" />
</build>
<!-- haxelib libraries -->
<haxelib>
<library name="lime" />
</haxelib>
<!-- Class files to compile (other referenced classes will automatically be included) -->
<compileTargets>
<!-- example: <compile path="..." /> -->
</compileTargets>
<!-- Assets to embed into the output SWF -->
<library>
<!-- example: <asset path="..." id="..." update="..." glyphs="..." mode="..." place="..." sharepoint="..." /> -->
</library>
<!-- Paths to exclude from the Project Explorer tree -->
<hiddenPaths>
<!-- example: <hidden path="..." /> -->
</hiddenPaths>
<!-- Executed before build -->
<preBuildCommand />
<!-- Executed after build -->
<postBuildCommand alwaysRun="False" />
<!-- Other project options -->
<options>
<option showHiddenPaths="False" />
<option testMovie="Custom" />
<option testMovieCommand="" />
</options>
<!-- Plugin storage -->
<storage />
</project>

View File

@@ -0,0 +1,199 @@
package;
import haxe.Timer;
import lime.gl.GL;
import lime.gl.GLBuffer;
import lime.gl.GLProgram;
import lime.gl.GLShader;
import lime.gl.GLUniformLocation;
import lime.geometry.Matrix3D;
import lime.utils.Float32Array;
import lime.utils.Assets;
import lime.Lime;
class Main {
private static var fragmentShaders = [ #if mobile "6284.1", "6238", "6147.1", "5891.5", "5805.18", "5492", "5398.8" #else "6286", "6288.1", "6284.1", "6238", "6223.2", "6175", "6162", "6147.1", "6049", "6043.1", "6022", "5891.5", "5805.18", "5812", "5733", "5454.21", "5492", "5359.8", "5398.8", "4278.1" #end ];
private static var maxTime = 7;
private var backbufferUniform:GLUniformLocation;
private var buffer:GLBuffer;
private var currentIndex:Int;
private var currentProgram:GLProgram;
private var currentTime:Float;
private var lime:Lime;
private var mouseUniform:GLUniformLocation;
private var positionAttribute:Int;
private var resolutionUniform:GLUniformLocation;
private var startTime:Float;
private var surfaceSizeUniform:GLUniformLocation;
private var timeUniform:GLUniformLocation;
private var vertexPosition:Int;
public function new () {}
private function compile ():Void {
var program = GL.createProgram ();
var vertex = Assets.getText ("assets/heroku.vert");
#if desktop
var fragment = "";
#else
var fragment = "precision mediump float;";
#end
fragment += Assets.getText ("assets/" + fragmentShaders[currentIndex] + ".frag");
var vs = createShader (vertex, GL.VERTEX_SHADER);
var fs = createShader (fragment, GL.FRAGMENT_SHADER);
if (vs == null || fs == null) return;
GL.attachShader (program, vs);
GL.attachShader (program, fs);
GL.deleteShader (vs);
GL.deleteShader (fs);
GL.linkProgram (program);
if (GL.getProgramParameter (program, GL.LINK_STATUS) == 0) {
trace (GL.getProgramInfoLog (program));
trace ("VALIDATE_STATUS: " + GL.getProgramParameter (program, GL.VALIDATE_STATUS));
trace ("ERROR: " + GL.getError ());
return;
}
if (currentProgram != null) {
GL.deleteProgram (currentProgram);
}
currentProgram = program;
positionAttribute = GL.getAttribLocation (currentProgram, "surfacePosAttrib");
GL.enableVertexAttribArray (positionAttribute);
vertexPosition = GL.getAttribLocation (currentProgram, "position");
GL.enableVertexAttribArray (vertexPosition);
timeUniform = GL.getUniformLocation (program, "time");
mouseUniform = GL.getUniformLocation (program, "mouse");
resolutionUniform = GL.getUniformLocation (program, "resolution");
backbufferUniform = GL.getUniformLocation (program, "backbuffer");
surfaceSizeUniform = GL.getUniformLocation (program, "surfaceSize");
startTime = Timer.stamp ();
currentTime = startTime;
}
private function createShader (source:String, type:Int):GLShader {
var shader = GL.createShader (type);
GL.shaderSource (shader, source);
GL.compileShader (shader);
if (GL.getShaderParameter (shader, GL.COMPILE_STATUS) == 0) {
trace (GL.getShaderInfoLog (shader));
return null;
}
return shader;
}
private function randomizeArray<T> (array:Array<T>):Array<T> {
var arrayCopy = array.copy ();
var randomArray = new Array<T> ();
while (arrayCopy.length > 0) {
var randomIndex = Math.round (Math.random () * (arrayCopy.length - 1));
randomArray.push (arrayCopy.splice (randomIndex, 1)[0]);
}
return randomArray;
}
public function ready (lime:Lime) {
this.lime = lime;
fragmentShaders = randomizeArray (fragmentShaders);
currentIndex = 0;
buffer = GL.createBuffer ();
GL.bindBuffer (GL.ARRAY_BUFFER, buffer);
GL.bufferData (GL.ARRAY_BUFFER, new Float32Array ([ -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0 ]), GL.STATIC_DRAW);
GL.bindBuffer (GL.ARRAY_BUFFER, null);
compile ();
}
public function render ():Void {
if (currentProgram == null) return;
currentTime = Timer.stamp () - startTime;
GL.viewport (0, 0, lime.config.width, lime.config.height);
GL.useProgram (currentProgram);
GL.uniform1f (timeUniform, currentTime);
GL.uniform2f (mouseUniform, 0.1, 0.1); //GL.uniform2f (mouseUniform, (stage.mouseX / stage.stageWidth) * 2 - 1, (stage.mouseY / stage.stageHeight) * 2 - 1);
GL.uniform2f (resolutionUniform, lime.config.width, lime.config.height);
GL.uniform1i (backbufferUniform, 0 );
GL.uniform2f (surfaceSizeUniform, lime.config.width, lime.config.height);
GL.bindBuffer (GL.ARRAY_BUFFER, buffer);
GL.vertexAttribPointer (positionAttribute, 2, GL.FLOAT, false, 0, 0);
GL.vertexAttribPointer (vertexPosition, 2, GL.FLOAT, false, 0, 0);
GL.clearColor (0, 0, 0, 1);
GL.clear (GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT );
GL.drawArrays (GL.TRIANGLES, 0, 6);
GL.bindBuffer (GL.ARRAY_BUFFER, null);
}
public function update ():Void {
if (currentTime > maxTime && fragmentShaders.length > 1) {
currentIndex++;
if (currentIndex > fragmentShaders.length - 1) {
currentIndex = 0;
}
compile ();
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<meta title="Heroku Shaders" package="com.limeframework.samples.herokushaders" version="1.0.0" company="OpenFL Technologies" />
<app main="Main" path="Export" file="HerokuShaders" />
<window require-shaders="true" />
<source path="Source" />
<haxelib name="lime" />
<assets path="Assets" rename="assets" exclude="*.svg" />
<!-- <icon path="Assets/lime.svg" /> -->
</project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<project version="2">
<!-- Output SWF options -->
<output>
<movie outputType="Application" />
<movie input="" />
<movie path="project.lime" />
<movie fps="30" />
<movie width="800" />
<movie height="600" />
<movie version="3" />
<movie minorVersion="0" />
<movie platform="NME" />
<movie background="#FFFFFF" />
</output>
<!-- Other classes to be compiled into your SWF -->
<classpaths>
<class path="Source" />
</classpaths>
<!-- Build options -->
<build>
<option directives="" />
<option flashStrict="False" />
<option mainClass="" />
<option enabledebug="False" />
<option additional="" />
</build>
<!-- haxelib libraries -->
<haxelib>
<library name="lime" />
</haxelib>
<!-- Class files to compile (other referenced classes will automatically be included) -->
<compileTargets>
<!-- example: <compile path="..." /> -->
</compileTargets>
<!-- Assets to embed into the output SWF -->
<library>
<!-- example: <asset path="..." id="..." update="..." glyphs="..." mode="..." place="..." sharepoint="..." /> -->
</library>
<!-- Paths to exclude from the Project Explorer tree -->
<hiddenPaths>
<!-- example: <hidden path="..." /> -->
</hiddenPaths>
<!-- Executed before build -->
<preBuildCommand />
<!-- Executed after build -->
<postBuildCommand alwaysRun="False" />
<!-- Other project options -->
<options>
<option showHiddenPaths="False" />
<option testMovie="Custom" />
<option testMovieCommand="" />
</options>
<!-- Plugin storage -->
<storage />
</project>

View File

@@ -0,0 +1,215 @@
package;
import format.png.Reader;
import format.png.Tools;
import haxe.io.BytesInput;
import lime.gl.GL;
import lime.gl.GLBuffer;
import lime.gl.GLProgram;
import lime.gl.GLTexture;
import lime.geometry.Matrix3D;
import lime.utils.Assets;
import lime.utils.Float32Array;
import lime.utils.UInt8Array;
import lime.Lime;
class Main {
private var imageData:UInt8Array;
private var imageHeight:Int;
private var imageWidth:Int;
private var imageUniform:Int;
private var lime:Lime;
private var modelViewMatrixUniform:Int;
private var projectionMatrixUniform:Int;
private var shaderProgram:GLProgram;
private var texCoordAttribute:Int;
private var texCoordBuffer:GLBuffer;
private var texture:GLTexture;
private var vertexAttribute:Int;
private var vertexBuffer:GLBuffer;
public function new () {}
private function createBuffers ():Void {
var vertices = [
imageWidth, imageHeight, 0,
0, imageHeight, 0,
imageWidth, 0, 0,
0, 0, 0
];
vertexBuffer = GL.createBuffer ();
GL.bindBuffer (GL.ARRAY_BUFFER, vertexBuffer);
GL.bufferData (GL.ARRAY_BUFFER, new Float32Array (cast vertices), GL.STATIC_DRAW);
GL.bindBuffer (GL.ARRAY_BUFFER, null);
var texCoords = [
1, 1,
0, 1,
1, 0,
0, 0,
];
texCoordBuffer = GL.createBuffer ();
GL.bindBuffer (GL.ARRAY_BUFFER, texCoordBuffer);
GL.bufferData (GL.ARRAY_BUFFER, new Float32Array (cast texCoords), GL.STATIC_DRAW);
GL.bindBuffer (GL.ARRAY_BUFFER, null);
}
private function createTexture ():Void {
texture = GL.createTexture ();
GL.bindTexture (GL.TEXTURE_2D, texture);
GL.texImage2D (GL.TEXTURE_2D, 0, GL.RGBA, imageHeight, imageHeight, 0, GL.RGBA, GL.UNSIGNED_BYTE, imageData);
GL.texParameteri (GL.TEXTURE_2D, GL.TEXTURE_MAG_FILTER, GL.LINEAR);
GL.texParameteri (GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.LINEAR);
GL.bindTexture (GL.TEXTURE_2D, null);
}
private function initializeShaders ():Void {
var vertexShaderSource =
"attribute vec3 aVertexPosition;
attribute vec2 aTexCoord;
varying vec2 vTexCoord;
uniform mat4 uModelViewMatrix;
uniform mat4 uProjectionMatrix;
void main(void) {
vTexCoord = aTexCoord;
gl_Position = uProjectionMatrix * uModelViewMatrix * vec4 (aVertexPosition, 1.0);
}";
var vertexShader = GL.createShader (GL.VERTEX_SHADER);
GL.shaderSource (vertexShader, vertexShaderSource);
GL.compileShader (vertexShader);
if (GL.getShaderParameter (vertexShader, GL.COMPILE_STATUS) == 0) {
throw "Error compiling vertex shader";
}
var fragmentShaderSource =
"varying vec2 vTexCoord;
uniform sampler2D uImage0;
void main(void)
{
gl_FragColor = texture2D (uImage0, vTexCoord).bgra;
}";
var fragmentShader = GL.createShader (GL.FRAGMENT_SHADER);
GL.shaderSource (fragmentShader, fragmentShaderSource);
GL.compileShader (fragmentShader);
if (GL.getShaderParameter (fragmentShader, GL.COMPILE_STATUS) == 0) {
throw "Error compiling fragment shader";
}
shaderProgram = GL.createProgram ();
GL.attachShader (shaderProgram, vertexShader);
GL.attachShader (shaderProgram, fragmentShader);
GL.linkProgram (shaderProgram);
if (GL.getProgramParameter (shaderProgram, GL.LINK_STATUS) == 0) {
throw "Unable to initialize the shader program.";
}
vertexAttribute = GL.getAttribLocation (shaderProgram, "aVertexPosition");
texCoordAttribute = GL.getAttribLocation (shaderProgram, "aTexCoord");
projectionMatrixUniform = GL.getUniformLocation (shaderProgram, "uProjectionMatrix");
modelViewMatrixUniform = GL.getUniformLocation (shaderProgram, "uModelViewMatrix");
imageUniform = GL.getUniformLocation (shaderProgram, "uImage0");
}
public function ready (lime:Lime):Void {
this.lime = lime;
var bytes = Assets.getBytes ("assets/lime.png");
var byteInput = new BytesInput (bytes, 0, bytes.length);
var png = new Reader (byteInput).read ();
var data = Tools.extract32 (png);
var header = Tools.getHeader (png);
imageWidth = header.width;
imageHeight = header.height;
imageData = new UInt8Array (data.getData ());
initializeShaders ();
createBuffers ();
createTexture ();
}
private function render ():Void {
GL.viewport (0, 0, lime.config.width, lime.config.height);
GL.clearColor (1.0, 1.0, 1.0, 1.0);
GL.clear (GL.COLOR_BUFFER_BIT);
var positionX = (lime.config.width - imageWidth) / 2;
var positionY = (lime.config.height - imageHeight) / 2;
var projectionMatrix = Matrix3D.createOrtho (0, lime.config.width, lime.config.height, 0, 1000, -1000);
var modelViewMatrix = Matrix3D.create2D (positionX, positionY, 1, 0);
GL.useProgram (shaderProgram);
GL.enableVertexAttribArray (vertexAttribute);
GL.enableVertexAttribArray (texCoordAttribute);
GL.activeTexture (GL.TEXTURE0);
GL.bindTexture (GL.TEXTURE_2D, texture);
GL.enable (GL.TEXTURE_2D);
GL.bindBuffer (GL.ARRAY_BUFFER, vertexBuffer);
GL.vertexAttribPointer (vertexAttribute, 3, GL.FLOAT, false, 0, 0);
GL.bindBuffer (GL.ARRAY_BUFFER, texCoordBuffer);
GL.vertexAttribPointer (texCoordAttribute, 2, GL.FLOAT, false, 0, 0);
GL.uniformMatrix3D (projectionMatrixUniform, false, projectionMatrix);
GL.uniformMatrix3D (modelViewMatrixUniform, false, modelViewMatrix);
GL.uniform1i (imageUniform, 0);
GL.drawArrays (GL.TRIANGLE_STRIP, 0, 4);
GL.bindBuffer (GL.ARRAY_BUFFER, null);
GL.disable (GL.TEXTURE_2D);
GL.bindTexture (GL.TEXTURE_2D, null);
GL.disableVertexAttribArray (vertexAttribute);
GL.disableVertexAttribArray (texCoordAttribute);
GL.useProgram (null);
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<meta title="Simple OpenGLView" package="com.limeframework.samples.simpleopengl" version="1.0.0" company="OpenFL Technologies" />
<app main="Main" path="Export" file="SimpleOpenGL" />
<source path="Source" />
<haxelib name="lime" />
<haxelib name="format" />
<assets path="Assets" rename="assets" exclude="*.svg" />
<!-- <icon path="Assets/lime.svg" /> -->
</project>