(objects:list, lights:list, cam:Camera)
| 969 | |
| 970 | |
| 971 | def render(objects:list, lights:list, cam:Camera): |
| 972 | def get_luminance(normal, x3d, y3d, z3d) -> list: |
| 973 | def in_point_light_shadow(): |
| 974 | x_light1, y_light1, z_light1 = ( |
| 975 | x_light * light.rotation1[0][0] + y_light * light.rotation1[0][1] + z_light * light.rotation1[0][2], |
| 976 | x_light * light.rotation1[1][0] + y_light * light.rotation1[1][1] + z_light * light.rotation1[1][2], |
| 977 | x_light * light.rotation1[2][0] + y_light * light.rotation1[2][1] + z_light * light.rotation1[2][2], |
| 978 | ) |
| 979 | if z_light1 > light.shadow_properties[1]: |
| 980 | x2d = light.shadow_properties[4] + int(x_light1 * light.shadow_properties[3] / z_light1) |
| 981 | y2d = light.shadow_properties[4] - int(y_light1 * light.shadow_properties[3] / z_light1) |
| 982 | if 0 <= x2d < light.shadow_properties[0] and 0 <= y2d < light.shadow_properties[0]: |
| 983 | bias = (1 - (light.rotation1[2][0] * normal[0] + light.rotation1[2][1] * normal[1] + light.rotation1[2][2] * normal[2])) * (cam.z_far - cam.z_near) * bias_scalar * 0.001 |
| 984 | if z_light1 > light.shadow_map1[y2d][x2d] + bias: |
| 985 | return True |
| 986 | |
| 987 | x_light2, y_light2, z_light2 = ( |
| 988 | x_light * light.rotation2[0][0] + y_light * light.rotation2[0][1] + z_light * light.rotation2[0][2], |
| 989 | x_light * light.rotation2[1][0] + y_light * light.rotation2[1][1] + z_light * light.rotation2[1][2], |
| 990 | x_light * light.rotation2[2][0] + y_light * light.rotation2[2][1] + z_light * light.rotation2[2][2], |
| 991 | ) |
| 992 | if z_light2 > light.shadow_properties[1]: |
| 993 | x2d = light.shadow_properties[4] + int(x_light2 * light.shadow_properties[3] / z_light2) |
| 994 | y2d = light.shadow_properties[4] - int(y_light2 * light.shadow_properties[3] / z_light2) |
| 995 | if 0 <= x2d < light.shadow_properties[0] and 0 <= y2d < light.shadow_properties[0]: |
| 996 | bias = (1 - (light.rotation2[2][0] * normal[0] + light.rotation2[2][1] * normal[1] + light.rotation2[2][2] * normal[2])) * (cam.z_far - cam.z_near) * bias_scalar * 0.001 |
| 997 | if z_light2 > light.shadow_map2[y2d][x2d] + bias: |
| 998 | return True |
| 999 | |
| 1000 | x_light3, y_light3, z_light3 = ( |
| 1001 | x_light * light.rotation3[0][0] + y_light * light.rotation3[0][1] + z_light * light.rotation3[0][2], |
| 1002 | x_light * light.rotation3[1][0] + y_light * light.rotation3[1][1] + z_light * light.rotation3[1][2], |
| 1003 | x_light * light.rotation3[2][0] + y_light * light.rotation3[2][1] + z_light * light.rotation3[2][2], |
| 1004 | ) |
| 1005 | if z_light3 > light.shadow_properties[1]: |
| 1006 | x2d = light.shadow_properties[4] + int(x_light3 * light.shadow_properties[3] / z_light3) |
| 1007 | y2d = light.shadow_properties[4] - int(y_light3 * light.shadow_properties[3] / z_light3) |
| 1008 | if 0 <= x2d < light.shadow_properties[0] and 0 <= y2d < light.shadow_properties[0]: |
| 1009 | bias = (1 - (light.rotation3[2][0] * normal[0] + light.rotation3[2][1] * normal[1] + light.rotation3[2][2] * normal[2])) * (cam.z_far - cam.z_near) * bias_scalar * 0.001 |
| 1010 | if z_light3 > light.shadow_map3[y2d][x2d] + bias: |
| 1011 | return True |
| 1012 | |
| 1013 | x_light4, y_light4, z_light4 = ( |
| 1014 | x_light * light.rotation4[0][0] + y_light * light.rotation4[0][1] + z_light * light.rotation4[0][2], |
| 1015 | x_light * light.rotation4[1][0] + y_light * light.rotation4[1][1] + z_light * light.rotation4[1][2], |
| 1016 | x_light * light.rotation4[2][0] + y_light * light.rotation4[2][1] + z_light * light.rotation4[2][2], |
| 1017 | ) |
| 1018 | if z_light4 > light.shadow_properties[1]: |
| 1019 | x2d = light.shadow_properties[4] + int(x_light4 * light.shadow_properties[3] / z_light4) |
| 1020 | y2d = light.shadow_properties[4] - int(y_light4 * light.shadow_properties[3] / z_light4) |
| 1021 | if 0 <= x2d < light.shadow_properties[0] and 0 <= y2d < light.shadow_properties[0]: |
| 1022 | bias = (1 - (light.rotation4[2][0] * normal[0] + light.rotation4[2][1] * normal[1] + light.rotation4[2][2] * normal[2])) * (cam.z_far - cam.z_near) * bias_scalar * 0.001 |
| 1023 | if z_light4 > light.shadow_map4[y2d][x2d] + bias: |
| 1024 | return True |
| 1025 | |
| 1026 | x_light5, y_light5, z_light5 = ( |
| 1027 | x_light * light.rotation5[0][0] + y_light * light.rotation5[0][1] + z_light * light.rotation5[0][2], |
| 1028 | x_light * light.rotation5[1][0] + y_light * light.rotation5[1][1] + z_light * light.rotation5[1][2], |
no test coverage detected