#version 300 es
precision highp float;
uniform sampler2D prgm1Texture;
uniform vec2 resolution;
uniform float time;
out vec4 fragColor;
// Main GPU Loop
void main(void){
vec2 uv = gl_FragCoord.xy / resolution.xy;
uv.x *= resolution.x / resolution.y;
fragColor = vec4(1.0, 0.2, 0.0, 1.0);
}
#version 300 es
precision highp float;
//Uniforms
uniform vec2 resolution;
uniform float time;
//Outputs
out vec4 fragColor;
//Transformation functions
vec2 rotate(float angle, vec2 position){
mat2 transformation = mat2(
cos(angle), -sin(angle),
sin(angle), cos(angle)
);
return position * transformation;
}
//2D Shape Functions
float circleDistance(vec2 position, float radius, vec2 displacement){
return length(position - displacement) - radius;
}
//3D Shape functions
float sphereDistance(vec3 position, float radius, vec3 displacement){
return length(position - displacement) - radius;
}
//Mapper Functions
float sceneMapper(vec3 position){
vec3 spherePosition = position;
float sphere = sphereDistance(spherePosition, 0.5, vec3(0.0));
return sphere;
}
//Camera settings
vec3[2] cameraPosition(vec2 screenPosition){
vec3 rayOrigin = vec3(0.0, 0.0, -1.0);
vec3 rayDirection = normalize(vec3(screenPosition, 1.0));
return vec3[2](rayOrigin, rayDirection);
}
//RayMarcher settings
const float minDistance = 0.0001;
const float maxTravelled = 1000.0;
const int maxMarches = 500;
//Raymarcher Function
vec3 rayMarcher(vec3 rayOrigin, vec3 rayDirection){
vec3 positionColor = vec3(0.0, 0.0, 0.0);
float rayTravelled = 0.0;
int marchIteration = 0;
for(marchIteration; marchIteration < maxMarches; marchIteration++){
vec3 rayPosition = rayOrigin + rayDirection * rayTravelled;
float rayDistance = sceneMapper(rayPosition);
rayTravelled += rayDistance;
if(rayDistance < minDistance){
}
}
return positionColor;
}
//Main GPU Loop
void main(void){
vec2 screenPosition = (gl_FragCoord.xy / resolution.xy) * 0.5 + 0.5;
screenPosition.x *= resolution.x / resolution.y;
fragColor = vec4(1.0, 0.2, 0.0, 1.0);
}