Skip to content

Commit

Permalink
Tweak for the best angle for using abs
Browse files Browse the repository at this point in the history
  • Loading branch information
utensil committed Aug 17, 2024
1 parent 9a1b432 commit e68c2de
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions trees/math-000K.tree
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
#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_BACKGROUND (RAYMARCH_AMBIENT + rayDirection.y * 0.8)
#define RAYMARCH_BACKGROUND vec3(1.0, 1.0, 1.0)
#define RAYMARCH_AMBIENT vec3(1.0, 1.0, 1.0)
// #define RAYMARCH_AMBIENT vec3(0.7, 0.9, 1.0)
// #define RAYMARCH_AMBIENT vec3(0.374,0.481,0.535)

#define EPSILON 0.0001
Expand Down Expand Up @@ -60,7 +62,7 @@ float mySDF2(vec3 p) {
float z2 = pow(z, 2.);
float y3 = pow(y, 3.);

// return 5.*(z2+y3-y4-x2*y2);
return 5.*(z2+y3-y4-x2*y2);

// return (y2-x2-z2);

Expand All @@ -83,7 +85,7 @@ Material raymarchMap( in vec3 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 * tapping_abs(mySDF2(pos)), sphereSDF(pos, 1.8)));
Material res = materialNew( vec3(1.0, 2.0, 1.0), opIntersection(0.05 * abs(mySDF2(pos)), sphereSDF(pos, 1.8)));

// 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) ) ) );
Expand Down Expand Up @@ -111,8 +113,19 @@ void mainImage( out vec4 fragColor, in vec2 fragCoord )
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) );

// 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) );

const vec2 initMouse = vec2(0.2, -0.1);
vec2 mouse = initMouse + vec2(0.035625*sin(u_time*PI), 0.0); // initMouse; // iMouse.xy == vec2(0.,0.) ? initMouse : (iMouse.xy/iResolution.xy - 0.5);
float pitch = clamp(- mouse.x * 2.*PI * 1., -PI,PI);
float yaw = clamp( mouse.y * PI * 1.2, -PI*0.5, PI*0.5);
// pitch and yaw rotations (column-wise matrices)
mat3 rot = mat3(cos(yaw), sin(yaw), 0., -sin(yaw), cos(yaw), 0., 0., 0., 1.);
rot = rot * mat3(cos(pitch), 0., -sin(pitch), 0., 1., 0., sin(pitch), 0., cos(pitch));
vec3 camPos = vec3(-3., 2., -2.);
// apply
vec3 cam = rot*camPos;

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

Expand Down

0 comments on commit e68c2de

Please sign in to comment.