chore: reformat
This commit is contained in:
parent
5b6d03e1c8
commit
39f9437838
2 changed files with 28 additions and 36 deletions
|
@ -25,47 +25,42 @@ const vec3 color2 = vec3(0.827, 0.945, 0.875);
|
||||||
|
|
||||||
// returns the distance from the ray to this sphere in the scene
|
// returns the distance from the ray to this sphere in the scene
|
||||||
float sphere_render(vec3 ray_pos, float radius, vec3 sphere_pos) {
|
float sphere_render(vec3 ray_pos, float radius, vec3 sphere_pos) {
|
||||||
|
return distance(ray_pos, sphere_pos) - radius;
|
||||||
return distance(ray_pos, sphere_pos) - radius;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float remap11(float val ) {
|
float remap11(float val) {
|
||||||
return ((val - .5) * 2.);
|
return ((val - .5) * 2.);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
// Set up camera and sphere object
|
// Set up camera and sphere object
|
||||||
vec3 ray_dir = normalize(vec3( remap11(texture_coordinates.x) , remap11(texture_coordinates.y), 1.));
|
vec3 ray_dir = normalize(vec3(remap11(texture_coordinates.x), remap11(texture_coordinates.y), 1.));
|
||||||
vec3 ray_pos = camera_pos;
|
vec3 ray_pos = camera_pos;
|
||||||
const vec3 sphere_pos = vec3(0.,0.,3.);
|
const vec3 sphere_pos = vec3(0., 0., 3.);
|
||||||
const float rad = 1.;
|
const float rad = 1.;
|
||||||
|
|
||||||
for(int i = 0; i < MAX_ITERATIONS; i++) {
|
for (int i = 0; i < MAX_ITERATIONS; i++) {
|
||||||
|
float distance = sphere_render(ray_pos, rad, sphere_pos);
|
||||||
|
|
||||||
float distance = sphere_render(ray_pos, rad, sphere_pos);
|
// Check If within tolerances
|
||||||
|
if (distance < MIN_TOLERANCE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Check If within tolerances
|
ray_pos += (distance * ray_dir);
|
||||||
if( distance < MIN_TOLERANCE) {
|
color = vec4(mix(color1, color2, float(i) / float(MAX_ITERATIONS)), 1.);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ray_pos += (distance * ray_dir);
|
// Image stuff for later
|
||||||
color = vec4(mix(color1, color2, float(i) / float(MAX_ITERATIONS)),1.);
|
/*
|
||||||
}
|
if ((texture_coordinates.x + texture_coordinates.y) > 1.) {
|
||||||
|
color = texture(uSampler1, texture_coordinates);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
color = texture(uSampler2, texture_coordinates);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// Basic color time shift
|
||||||
// Image stuff for later
|
// color = vec4( texture_coordinates, (sin( time * PI) + 1.)/2. , 1.);
|
||||||
/*
|
|
||||||
if ((texture_coordinates.x + texture_coordinates.y) > 1.) {
|
|
||||||
color = texture(uSampler1, texture_coordinates);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
color = texture(uSampler2, texture_coordinates);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// Basic color time shift
|
|
||||||
// color = vec4( texture_coordinates, (sin( time * PI) + 1.)/2. , 1.);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,7 @@ precision highp float;
|
||||||
in vec2 vertex_position;
|
in vec2 vertex_position;
|
||||||
out vec2 texture_coordinates;
|
out vec2 texture_coordinates;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
gl_Position = vec4(vertex_position, 0.5, 1.0);
|
||||||
gl_Position = vec4( vertex_position, 0.5, 1.0 );
|
texture_coordinates = vec2((vertex_position + vec2(1.0)) / 2.0);
|
||||||
texture_coordinates = vec2( (vertex_position + vec2(1.0) ) / 2.0 );
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue