Browse Source

added skybox, fixed split faces NAN uv values

Iver 1 month ago
parent
commit
dca568d1e2

BIN
builds/librasteriver.so


BIN
builds/main.bin


+ 5 - 5
changelog.txt

@@ -1,5 +1,5 @@
--integrated PitMap
--added RI_load_image function
--fixed wrong arg indecies in setKernelArg comments in RI_render
--removed grid example scene
--ADDED TEXTURESS !!!! IT WORKS !!!!! FIRST !!! TRY !!! OMGG!!!!!! >W<
+-added checker texture
+-added desert panorama and blue gradient skybox textures
+-added skybox example
+-fixed vector 2 lerp function by changing multiply 0 to memset 0
+-added vector 2 memset

+ 46 - 0
objects/skybox.obj

@@ -0,0 +1,46 @@
+# Blender 4.3.2
+# www.blender.org
+mtllib skybox.mtl
+o Cube
+v 1.000000 1.000000 -1.000000
+v 1.000000 -1.000000 -1.000000
+v 1.000000 1.000000 1.000000
+v 1.000000 -1.000000 1.000000
+v -1.000000 1.000000 -1.000000
+v -1.000000 -1.000000 -1.000000
+v -1.000000 1.000000 1.000000
+v -1.000000 -1.000000 1.000000
+vn -0.0000 -1.0000 -0.0000
+vn -0.0000 -0.0000 -1.0000
+vn 1.0000 -0.0000 -0.0000
+vn -0.0000 1.0000 -0.0000
+vn -1.0000 -0.0000 -0.0000
+vn -0.0000 -0.0000 1.0000
+vt 0.625000 0.750000
+vt 0.875000 0.500000
+vt 0.625000 0.500000
+vt 0.375000 1.000000
+vt 0.375000 0.750000
+vt 0.375000 0.250000
+vt 0.625000 0.000000
+vt 0.375000 0.000000
+vt 0.125000 0.750000
+vt 0.375000 0.500000
+vt 0.125000 0.500000
+vt 0.625000 0.250000
+vt 0.875000 0.750000
+vt 0.625000 1.000000
+s 0
+usemtl Material
+f 3/1/1 5/2/1 1/3/1
+f 8/4/2 3/1/2 4/5/2
+f 6/6/3 7/7/3 8/8/3
+f 8/9/4 2/10/4 6/11/4
+f 4/5/5 1/3/5 2/10/5
+f 2/10/6 5/12/6 6/6/6
+f 3/1/1 7/13/1 5/2/1
+f 8/4/2 7/14/2 3/1/2
+f 6/6/3 5/12/3 7/7/3
+f 8/9/4 4/5/4 2/10/4
+f 4/5/5 3/1/5 1/3/5
+f 2/10/6 1/3/6 5/12/6

+ 1 - 1
src/headers/types.h

@@ -124,7 +124,7 @@ typedef struct {
     RI_vector_2 uv_1;
     RI_vector_2 uv_2;
 
-    cl_uint should_render;
+    unsigned char should_render;
 } RI_face;
 
 typedef struct {

+ 7 - 1
src/kernels/kernels.cl

@@ -81,6 +81,12 @@ void vector_3_memset(RI_vector_3 *vector, double value){
     vector->z = value;
 }
 
+// set all values of a vector 2
+void vector_2_memset(RI_vector_2 *vector, double value){
+    vector->x = value;
+    vector->y = value;
+}
+
 // value-wise multiplacation.
 // multiply the whole vector by 1 value
 void vector_3_times(RI_vector_3 *vector, double value){
@@ -192,7 +198,7 @@ void global_quaternion_multiply(__global RI_vector_4* a, RI_vector_4 b){
 void vector_2_lerp(RI_vector_2 vector_a, RI_vector_2 vector_b, RI_vector_2 *result, double w1){
     double w0 = 1.0 - w1;
 
-    vector_2_times(result, 0);
+    vector_2_memset(result, 0);
 
     vector_2_times(&vector_a, w0);
     vector_2_times(&vector_b, w1);

+ 10 - 12
src/launch program/main.c

@@ -16,28 +16,26 @@ int main(){
 
     RI_scene *scene = RI_new_scene();
 
-    scene->camera.FOV = 1.5;
+    scene->camera.FOV = 2.1;
     scene->camera.min_clip = 0.1;
 
+    RI_mesh *skybox_mesh = RI_load_mesh("objects/skybox.obj");
     RI_mesh *cube_mesh = RI_load_mesh("objects/cube.obj");
 
     scene->actors = malloc(sizeof(RI_actor));
 
-    float min_x = -100;
-    float max_x = 100;
-    float min_y = -100;
-    float max_y = 100;
-
-    RI_texture* texture = RI_load_image("textures/test_texture_4_cube_8192x8192.bmp");
+    RI_texture* texture = RI_load_image("textures/desert_skybox_1000x1000.bmp");
 
     scene->actors[0] = RI_new_actor();
          
-    scene->actors[0]->mesh = cube_mesh;
+    scene->actors[0]->mesh = skybox_mesh;
     scene->actors[0]->texture = texture;
          
-    scene->actors[0]->scale = (RI_vector_3){50, 50, 50};
-    scene->actors[0]->position = (RI_vector_3){0, 0, 300};
+    scene->actors[0]->scale = (RI_vector_3){10000, 10000, 10000};
+    scene->actors[0]->position = (RI_vector_3){0, 0, 0};
     
+    RI_euler_rotation_to_quaternion(&scene->actors[0]->rotation, (RI_vector_3){0, 0, 0});
+
     scene->length_of_actors_array = 1;
 
     long int start, end;
@@ -56,7 +54,7 @@ int main(){
         
         // scene->camera.FOV = context->current_frame;
         
-        RI_euler_rotation_to_quaternion(&scene->actors[0]->rotation, (RI_vector_3){rotation, rotation, rotation});
+        RI_euler_rotation_to_quaternion(&scene->camera.rotation, (RI_vector_3){0, rotation, 0});
 
         rotation += delta_time;
 
@@ -71,7 +69,7 @@ int main(){
 
         total_fps += fps;
 
-        printf("fps: %f average fps: %f\n", fps, total_fps / context->current_frame);
+        printf("frame %d fps: %f average fps: %f\n", context->current_frame, fps, total_fps / context->current_frame);
     }
 
     free(scene->actors);

BIN
textures/checker_texture_4_cube_256x256.bmp


BIN
textures/desert_skybox_1000x1000.bmp


BIN
textures/skybox_texture_4_cube_1024x1024.bmp


BIN
textures/skybox_texture_4_cube_1024x1024.xcf


BIN
textures/skybox_texture_4_cube_256x256.bmp