Skip to content

Commit

Permalink
Finally a happy render result
Browse files Browse the repository at this point in the history
  • Loading branch information
utensil committed Aug 16, 2024
1 parent 6179448 commit 6413c60
Showing 1 changed file with 119 additions and 0 deletions.
119 changes: 119 additions & 0 deletions trees/math-000K.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
\import{ag-macros}
% clifford hopf spin tt ag math draft
\tag{math}
\tag{draft}

% definition theorem lemma construction observation
% convention corollary axiom example exercise proof
% discussion remark notation
% \taxon{}
% \refcardt{lemma}{}{}{}{

% kostecki2011introduction leinster2016basic nakahira2023diagrammatic rosiak2022sheaf

% cox1997ideals gathmann2013commutative

\note{test implicit surface shader 2}{
\shader{ }\verb>>>|
// Adapted from https://lygia.xyz/lighting/raymarch

#define LIGHT_COLOR vec3(1.000,0.794,0.066)
#define RESOLUTION iResolution.xy
#define RAYMARCH_MULTISAMPLE 4
#define RAYMARCH_BACKGROUND (RAYMARCH_AMBIENT + rayDirection.y * 0.8)
#define RAYMARCH_AMBIENT vec3(0.7, 0.9, 1.0)
// #define RAYMARCH_AMBIENT vec3(0.374,0.481,0.535)

#include "lygia/space/ratio.glsl"
#include "lygia/sdf.glsl"
#include "lygia/lighting/raymarch.glsl"
#include "lygia/color/space/linear2gamma.glsl"

float checkBoard(vec2 uv, vec2 _scale) {
uv = floor(fract(uv * _scale) * 2.0);
return min(1.0, uv.x + uv.y) - (uv.x * uv.y);
}

float myCubeSDF(vec3 p) {
float x = p.x;
float y = p.y;
float z = p.z;
float x6 = pow(x, 6.);
float y6 = pow(y, 6.);
float z6 = pow(z, 6.);

return x6+y6+z6-1.;
}

float mySDF2(vec3 p) {
float x = p.x;
float y = p.y;
float z = p.z;
float y2 = pow(y, 2.);
float z3 = pow(z, 3.);
float z4 = pow(z, 4.);
float x2 = pow(x, 2.);
float z2 = pow(z, 2.);
float y3 = pow(y, 3.);

// return y2+z3-z4-x2*z2;

// return x2*z2+z4-y2-z3;

// return -x2+y2*z2+z3;

// return z2-x2-y2;

return x2-z2*y2+y3;
}

Material raymarchMap( in vec3 pos ) {
// float check = 0.5 + checkBoard(pos.xz, vec2(1.0, 1.0)) * 0.5;
// Material res = materialNew(vec3(check), 0.0, 0.5, planeSDF(pos - vec3(0.0, -2.0, 0.0)));

// res = opUnion( res, materialNew( vec3(1.0, 2.0, 1.0), myCubeSDF(pos - vec3(0.0, -1.0, 0.0))*0.004 ) );

// res = opUnion( res, materialNew( vec3(1.0, 2.0, 1.0),opIntersection(0.004 * myCubeSDF(pos), cubeSDF(pos, 1.0))) );

// res = opUnion(res, materialNew( vec3(1.0, 2.0, 1.0), 0.004 * abs(mySDF2(pos))));

// res = opUnion(res, materialNew( vec3(1.0, 2.0, 1.0), opIntersection(0.05 * abs(mySDF2(pos)), cubeSDF(pos, 1.0))) );

Material res = materialNew( vec3(1.0, 2.0, 1.0), opIntersection(0.05 * abs(mySDF2(pos)), cubeSDF(pos, 1.0)));

// res = opUnion( res, materialNew( vec3(1.0, 1.0, 1.0), 1.0, 0.0, sphereSDF(pos-vec3( 0.0, 2.0, 0.0), 0.5 ) ) );
// res = opUnion( res, materialNew( vec3(0.0, 1.0, 1.0), boxSDF( pos-vec3( 2.0, 0.5, 0.0), vec3(0.4, 0.4, 0.4) ) ) );
// res = opUnion( res, materialNew( vec3(0.3, 0.3, 1.0), torusSDF( pos-vec3( 0.0, 0.5, 2.0), vec2(0.4,0.1) ) ) );
// res = opUnion( res, materialNew( vec3(0.3, 0.1, 0.3), capsuleSDF( pos,vec3(-2.3, 0.4,-0.2), vec3(-1.6,0.75,0.2), 0.2 ) ) );
// res = opUnion( res, materialNew( vec3(0.5, 0.3, 0.4), triPrismSDF( pos-vec3(-2.0, 0.50,-2.0), vec2(0.5,0.1) ) ) );
// res = opUnion( res, materialNew( vec3(0.2, 0.2, 0.8), cylinderSDF( pos-vec3( 2.0, 0.50,-2.0), vec2(0.2,0.4) ) ) );
// res = opUnion( res, materialNew( vec3(0.7, 0.5, 0.2), coneSDF( pos-vec3( 0.0, 0.75,-2.0), vec3(0.8,0.6,0.6) ) ) );
// res = opUnion( res, materialNew( vec3(0.4, 0.2, 0.9), hexPrismSDF( pos-vec3(-2.0, 0.60, 2.0), vec2(0.5,0.1) ) ) );
// res = opUnion( res, materialNew( vec3(0.1, 0.3, 0.6), pyramidSDF( pos-vec3( 2.0, 0.10, 2.0), 1.0 ) ) );;
return res;
}

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 u_resolution = iResolution.xy;
vec2 u_mouse = iMouse.xy;
float u_time = iTime;

vec3 color = vec3(0.0);
vec2 pixel = 1.0/u_resolution;
vec2 st = fragCoord.xy * pixel;
vec2 uv = ratio(st, u_resolution);

vec2 mo = u_mouse * pixel;
float time = 32.0 + u_time * 1.5;
// vec3 cam = vec3( 12.5*cos(0.1*time), 2.2, 12.5*sin(0.1*time) );
vec3 cam = vec3( 8.5*cos(0.1*time - 7.0*mo.x), 2.2, 8.5*sin(0.1*time - 7.0*mo.x) );

color = raymarch(cam, vec3(0.0), uv).rgb;
color = linear2gamma(color);

fragColor = vec4( color, 1.0 );
}

>>>
}

0 comments on commit 6413c60

Please sign in to comment.