larry babby and threejs for glsl

This commit is contained in:
Sam
2024-06-24 21:24:00 +12:00
parent 87d5dc634d
commit 907ebae4c0
6474 changed files with 1279596 additions and 8 deletions

View File

@@ -0,0 +1,16 @@
#pragma glslify: LightStruct = require(./struct)
#pragma glslify: export(another)
float alongside() {
return 0.0;
}
float another(float n) {
LightStruct b = LightStruct(vec3(0), vec4(0));
return n * n + b.position + alongside() + t + u;
}
float another(float n, float c) {
LightStruct b = LightStruct(vec3(0), vec4(0));
return n * n + b.position + another(c) + t + u - v;
}

View File

@@ -0,0 +1,9 @@
precision mediump float;
uniform vec2 uVec;
#pragma glslify: a = require( "./sibling" )
void main() {
gl_FragColor = vec4(a(1.0));
}

View File

@@ -0,0 +1,32 @@
#pragma glslify: Ray = require('./complex-ray.glsl')
#pragma glslify: RayResult = require('./complex-ray-result.glsl')
RayResult rayBail() {
return RayResult(0.0, 0.0, false);
}
RayResult march(Ray source, float maxd, float precis) {
float latest = precis * 2.0;
float dist = +0.0;
float type = -1.0;
RayResult res = rayBail();
for (int i = 0; i < 99; i++) {
if (latest < precis || dist > maxd) break;
res = map(source.ro + source.rd * dist);
dist += res.d;
}
if(dist >= maxd) {
return rayBail();
}
return res;
}
RayResult march(Ray ray) {
return march(ray, 20.0, 0.001);
}
#pragma glslify: export(march)

View File

@@ -0,0 +1,7 @@
struct Result {
float d;
float type;
bool hit;
};
#pragma glslify: export(Result)

View File

@@ -0,0 +1,6 @@
struct Ray {
vec3 ro;
vec3 rd;
};
#pragma glslify: export(Ray)

View File

@@ -0,0 +1,29 @@
precision mediump float;
#pragma glslify: RayResult = require('./complex-ray-result')
#pragma glslify: Ray = require('./complex-ray')
RayResult doModel(vec3 p);
#pragma glslify: march = require('./complex-march', map = doModel)
RayResult doModel(vec3 p) {
float d = length(p);
float id = 1.0;
return RayResult(d, id, true);
}
void main() {
vec3 color = vec3(0);
vec3 rd = normalize(vec3(1));
vec3 ro = vec3(0);
RayResult t = march(Ray(ro, rd));
if (t.hit) {
color = vec3(t.d);
}
gl_FragColor = vec4(color, 1);
}

View File

@@ -0,0 +1,5 @@
float mappedChild() {
return map(vec3(0));
}
#pragma glslify: export(mappedChild)

View File

@@ -0,0 +1,20 @@
precision mediump float;
float source1(vec3 p);
float source2(vec3 p);
#pragma glslify: map1 = require('./multiple-mapped-child', map = source1)
#pragma glslify: map2 = require('./multiple-mapped-child', map = source2)
#pragma glslify: map3 = require('./multiple-mapped-child', map = source1)
float source1(vec3 p) {
return length(p) - 1.0;
}
float source2(vec3 p) {
return length(p) - 2.0;
}
void main() {
gl_FragColor = vec4(map1(), map2(), map3(), 1);
}

View File

@@ -0,0 +1,9 @@
#pragma glslify: another_thing = require(./another, t = v = 4.0, u = uVec.x)
#pragma glslify: LightStruct = require(./struct)
float sibling(float a) {
LightStruct b = LightStruct(vec3(0), vec4(0));
return a * another_thing(b.color + 2.0);
}
#pragma glslify: export(sibling)

View File

@@ -0,0 +1,7 @@
precision mediump float;
attribute vec2 position;
void main() {
gl_Position = vec4(position, 1, 1);
}

View File

@@ -0,0 +1,6 @@
#pragma glslify: export(Light)
struct Light {
vec3 position;
vec4 color;
};

View File

@@ -0,0 +1,5 @@
vec3 child(vec2 coord) {
return vec3(g.zx - a * coord + b - c + float(e) * f, t);
}
#pragma glslify: export(child)

View File

@@ -0,0 +1,17 @@
struct Ray {
vec3 origin;
vec3 direction;
} ray1;
const Ray ray2 = Ray(vec3(0), vec3(0, 1, 0));
const vec2 vec = vec2(0.0);
const float pi = 6.28;
#pragma glslify: n = require('./unsuffixable-child', a = vec.x, b = 5.0, c = vec, e = 2, f = ray1.origin.xy, t = pi, g = ray2.direction)
void runner(in vec2 fragCoord) {
gl_FragColor = vec4(n(fragCoord + vec2(d + h)), 1.0);
}
#pragma glslify: export(runner)

View File

@@ -0,0 +1,10 @@
precision mediump float;
const float pi = 3.14;
uniform vec2 P;
#pragma glslify: run = require('./unsuffixable-source.glsl', d = pi, h = P.x)
void main() {
run(gl_FragCoord.xy);
}

View File

@@ -0,0 +1,3 @@
#version 150
float PI = 3.14159265359;