|
|
@@ -132,9 +132,9 @@ void rotate_euler(float *x, float *y, float *z, float r_x, float r_y, float r_z)
|
|
|
*z = temp_z;\
|
|
|
};\
|
|
|
\
|
|
|
-__kernel void raster_kernel(__global Object* objects, __global float* verticies, __global float* normals, __global float* uvs, __global int* triangles, __global uint* frame_buffer, __global uchar* textures, __global int* texture_info, int object_count, int width, int height, int show_buffer, int frame, float fov, int total_triangle_count, int total_vertex_count){ \
|
|
|
- int id_x = get_global_id(0) - width / 2; \
|
|
|
- int id_y = get_global_id(1) - height / 2; \
|
|
|
+__kernel void raster_kernel(__global Object* objects, __global float* verticies, __global float* normals, __global float* uvs, __global int* triangles, __global uint* frame_buffer, __global uchar* textures, __global int* texture_info, int object_count, int width, int height, int show_buffer, int frame, float fov, int total_triangle_count, int total_vertex_count, int h_width, int h_height){ \
|
|
|
+ int id_x = get_global_id(0) - h_width; \
|
|
|
+ int id_y = get_global_id(1) - h_height; \
|
|
|
\
|
|
|
float vertical_fov_factor = height / tan(0.5 * fov);\
|
|
|
float horizontal_fov_factor = width / tan(0.5 * fov);\
|
|
|
@@ -200,27 +200,6 @@ __kernel void raster_kernel(__global Object* objects, __global float* verticies,
|
|
|
float x2 = verticies[i2 + 0];\
|
|
|
float y2 = verticies[i2 + 1];\
|
|
|
\
|
|
|
- if (object_r_w <= -9999999){\
|
|
|
- rotate_euler(&x0, &y0, &z0, object_r_x, object_r_y, object_r_z);\
|
|
|
- rotate_euler(&x1, &y1, &z1, object_r_x, object_r_y, object_r_z);\
|
|
|
- rotate_euler(&x2, &y2, &z2, object_r_x, object_r_y, object_r_z);\
|
|
|
- }\
|
|
|
- else{\
|
|
|
- rotate_euler(&x0, &y0, &z0, object_r_x, object_r_y, object_r_z);\
|
|
|
- rotate_euler(&x1, &y1, &z1, object_r_x, object_r_y, object_r_z);\
|
|
|
- rotate_euler(&x2, &y2, &z2, object_r_x, object_r_y, object_r_z);\
|
|
|
- }\
|
|
|
- \
|
|
|
- z0 = (z0 * object_s_z + object_z);\
|
|
|
- x0 = (x0 * object_s_x + object_x) / z0 * horizontal_fov_factor;\
|
|
|
- y0 = (y0 * object_s_y + object_y) / z0 * vertical_fov_factor;\
|
|
|
- z1 = (z1 * object_s_z + object_z);\
|
|
|
- x1 = (x1 * object_s_x + object_x) / z1 * horizontal_fov_factor;\
|
|
|
- y1 = (y1 * object_s_y + object_y) / z1 * vertical_fov_factor;\
|
|
|
- z2 = (z2 * object_s_z + object_z);\
|
|
|
- y2 = (y2 * object_s_y + object_y) / z2 * horizontal_fov_factor;\
|
|
|
- x2 = (x2 * object_s_x + object_x) / z2 * vertical_fov_factor;\
|
|
|
- \
|
|
|
if (i3 < 0 || i4 < 0 || i5 < 0){\
|
|
|
has_normals = 0;\
|
|
|
}\
|
|
|
@@ -307,17 +286,6 @@ __kernel void raster_kernel(__global Object* objects, __global float* verticies,
|
|
|
float u_y2 = uvs[i8 + 1];\
|
|
|
float u_z2 = uvs[i8 + 2];\
|
|
|
\
|
|
|
- if (object_r_w <= -9999999){\
|
|
|
- rotate_euler(&n_x0, &n_y0, &n_z0, object_r_x, object_r_y, object_r_z);\
|
|
|
- rotate_euler(&n_x1, &n_y1, &n_z1, object_r_x, object_r_y, object_r_z);\
|
|
|
- rotate_euler(&n_x2, &n_y2, &n_z2, object_r_x, object_r_y, object_r_z);\
|
|
|
- }\
|
|
|
- else{\
|
|
|
- rotate_euler(&n_x0, &n_y0, &n_z0, object_r_x, object_r_y, object_r_z);\
|
|
|
- rotate_euler(&n_x1, &n_y1, &n_z1, object_r_x, object_r_y, object_r_z);\
|
|
|
- rotate_euler(&n_x2, &n_y2, &n_z2, object_r_x, object_r_y, object_r_z);\
|
|
|
- }\
|
|
|
- \
|
|
|
switch (show_buffer){\
|
|
|
case 0:{\
|
|
|
double ux = (w0 * (u_x0 / z0) + w1 * (u_x1 / z1) + w2 * (u_x2 / z2)) / w_over_z;\
|
|
|
@@ -400,7 +368,7 @@ __kernel void raster_kernel(__global Object* objects, __global float* verticies,
|
|
|
}\
|
|
|
}\
|
|
|
\
|
|
|
- int pixel_coord = (height * 0.5 - id_y) * width + id_x + width * 0.5;\
|
|
|
+ int pixel_coord = (h_height - id_y) * width + id_x + h_width;\
|
|
|
\
|
|
|
if (pixel_coord >= width * height || pixel_coord < 0){\
|
|
|
return;\
|