Compare commits

..

3 Commits

3 changed files with 22 additions and 10 deletions

9
build.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
cd build
cmake --build .
echo "dd bs=1 skip=61<\$0|unlzma>/tmp/C;chmod +x /tmp/C;/tmp/C;exit" > two
chmod +x two
sstrip one
lzma -9 one
cat one.lzma >> two
rm one.lzma

View File

@@ -77,8 +77,6 @@ void framebuffer_size_callback(GLFWwindow *window, int width, int height) {
}
int main(int argc, char **argv) {
std::cout << "test";
std::cout << std::flush;
GLFWwindow *window;

View File

@@ -28,7 +28,7 @@ struct Ray {
};
Ray createRay(vec3 dir, vec3 pos){
return Ray(dir, pos, .0, .0, SmallHit(80.,0.,false), vec3(.0));
return Ray(dir, pos, .0, .0, SmallHit(80.,0.,false), vec3(1.0));
}
Ray applyMin(Ray ray, float min) {
@@ -52,11 +52,11 @@ Ray applyMin(Ray ray, float min) {
float planeMin(vec3 pos){
return pos.y - planeHeight;
return pos.y - planeHeight+ 0.2*sin(5*pos.x+t)*sin(5*pos.y+t)*sin(5*pos.z+t);
}
float sphereMin(vec3 pos){
return length(pos - center) - radius + 0.2*sin(5*pos.x+t)*sin(5*pos.y+t)*sin(5*pos.z+t);
return length(pos - center) - radius;
}
Ray minFn(Ray ray){
@@ -88,11 +88,13 @@ Ray march(Ray ray){
//ray.min = minFn(ray.pos);
ray = minFn(ray);
int c = 0;
while(( c < 200) && (ray.min < 100.0f) && (ray.min > 0.01f) ) {
while(( c < 1000) && (ray.min < 100.0f) && (ray.min > 0.01f) ) {
ray = minFn(ray);
c++;
}
if(ray.min > 0.01){
ray.color = vec3(1.0);
}
return ray;
}
@@ -142,11 +144,14 @@ void main()
light *= shLeve;
Ray reflectR = createRay(reflect(ray.dir,normal),ray.pos + 0.1* normal);
reflectR = march(reflectR);
if(ray.min <= 0.2){
//FragColor = vec4(vec3(shRay.small.min)*0.1,1.0);
FragColor = vec4(ray.color * (light+0.3), 1.0);
//FragColor = vec4(0,1,0,1.0);
FragColor = vec4(mix(ray.color,reflectR.color,0.3) * (light+0.3), 1.0);
} else {
FragColor = vec4(.0,0.0,0.0,1.0);
FragColor = vec4(ray.color,1.0);
}
}