Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/camera/projection.h
| Context not available. | |||||
| return make_float2(u, v); | return make_float2(u, v); | ||||
| } | } | ||||
| /* Cubemap projection <-> Cartesion direction */ | |||||
| ccl_device void cubemap_xyz_to_uv(float3 co, float &u, float &v, float &max_axis, int &index) | |||||
kevindietrich: Use pointers instead of references. | |||||
| { | |||||
| float abs_x = fabsf(co.x); | |||||
| float abs_y = fabsf(co.y); | |||||
| float abs_z = fabsf(co.z); | |||||
Not Done Inline ActionsDon't use the std namespace here, you'll break GPU compilation. Just use fabsf directly. kevindietrich: Don't use the `std` namespace here, you'll break GPU compilation. Just use `fabsf` directly. | |||||
| bool is_x_positive = co.x > 0.0f ? true : false; | |||||
Not Done Inline Actionsimplicit int->float cast, use 0.0f LazyDodo: implicit int->float cast, use `0.0f` | |||||
| bool is_y_positive = co.y > 0.0f ? true : false; | |||||
| bool is_z_positive = co.z > 0.0f ? true : false; | |||||
Not Done Inline ActionsUse floating point literals 0.0f. kevindietrich: Use floating point literals `0.0f`. | |||||
| if (is_x_positive && abs_x >= abs_y && abs_x >= abs_z) { | |||||
| max_axis = abs_x; | |||||
| u = co.y; | |||||
| v = co.z; | |||||
| index = 0; | |||||
| } | |||||
| if (!is_x_positive && abs_x >= abs_y && abs_x >= abs_z) { | |||||
Not Done Inline ActionsIf the previous if passed, there should not be any need to evaluate any of the others, else if or a return would likely suffice. LazyDodo: If the previous if passed, there should not be any need to evaluate any of the others, `else… | |||||
| max_axis = abs_x; | |||||
| u = -co.y; | |||||
| v = co.z; | |||||
| index = 1; | |||||
| } | |||||
| if (is_y_positive && abs_y >= abs_x && abs_y >= abs_z) { | |||||
| max_axis = abs_y; | |||||
| u = -co.x; | |||||
| v = co.z; | |||||
| index = 2; | |||||
| } | |||||
| if (!is_y_positive && abs_y >= abs_x && abs_y >= abs_z) { | |||||
| max_axis = abs_y; | |||||
| u = co.x; | |||||
| v = co.z; | |||||
| index = 3; | |||||
| } | |||||
| if (is_z_positive && abs_z >= abs_x && abs_z >= abs_y) { | |||||
| max_axis = abs_z; | |||||
| u = co.x; | |||||
| v = co.y; | |||||
| index = 4; | |||||
| } | |||||
| if (!is_z_positive && abs_z >= abs_x && abs_z >= abs_y) { | |||||
| max_axis = abs_z; | |||||
| u = co.x; | |||||
| v = co.y; | |||||
| index = 5; | |||||
| } | |||||
| } | |||||
| ccl_device float2 cubemap_uv_cross_horizontal(float uc, float vc, float max_axis, int index) | |||||
| { | |||||
| float u = 0.125f * (uc / max_axis + 1.0f); | |||||
| float v = 0.166667f * (vc / max_axis + 1.0f); | |||||
| switch (index) { | |||||
| case 0: { | |||||
| u += 0.5f; | |||||
| v += 0.333333f; | |||||
| break; | |||||
| } | |||||
| case 1: { | |||||
| v += 0.333333f; | |||||
| break; | |||||
| } | |||||
| case 2: { | |||||
| u += 0.75f; | |||||
| v += 0.333333f; | |||||
| break; | |||||
| } | |||||
| case 3: { | |||||
| u += 0.25f; | |||||
| v += 0.333333f; | |||||
| break; | |||||
| } | |||||
| case 4: { | |||||
| u += 0.25f; | |||||
| v += 0.666666f; | |||||
| break; | |||||
| } | |||||
| case 5: { | |||||
| u += 0.25f; | |||||
| v = 0.333333f - v; | |||||
| break; | |||||
| } | |||||
| } | |||||
| return make_float2(u, v); | |||||
| } | |||||
| ccl_device float2 cubemap_uv_stripe_horizontal(float uc, float vc, float max_axis, int index) | |||||
| { | |||||
| float u = 0.083333f * (uc / max_axis + 1.0f); | |||||
| float v = 0.5f * (vc / max_axis + 1.0f); | |||||
| switch (index) { | |||||
| case 1: { | |||||
| u += 0.166666f; | |||||
| break; | |||||
| } | |||||
| case 2: { | |||||
| u += 0.166666f * 5; | |||||
| break; | |||||
| } | |||||
| case 3: { | |||||
| u += 0.166666f * 4; | |||||
| break; | |||||
| } | |||||
| case 4: { | |||||
| u += 0.166666f * 2; | |||||
| break; | |||||
| } | |||||
| case 5: { | |||||
| u += 0.166666f * 3; | |||||
| v = 1.0f - v; | |||||
| break; | |||||
| } | |||||
| } | |||||
| return make_float2(u, v); | |||||
| } | |||||
| ccl_device float2 cubemap_uv_stripe_vertical(float uc, float vc, float max_axis, int index) | |||||
| { | |||||
| float u = 0.5f * (uc / max_axis + 1.0f); | |||||
| float v = 0.083333f * (vc / max_axis + 1.0f); | |||||
| switch (index) { | |||||
| case 0: { | |||||
| v += 0.166666f * 5; | |||||
| break; | |||||
| } | |||||
| case 1: { | |||||
| v += 0.166666f * 4; | |||||
| break; | |||||
| } | |||||
| case 3: { | |||||
| v += 0.166666f; | |||||
| break; | |||||
| } | |||||
| case 4: { | |||||
| v += 0.166666f * 3; | |||||
| break; | |||||
| } | |||||
| case 5: { | |||||
| v = 0.166666f * 3 - v; | |||||
| break; | |||||
| } | |||||
| } | |||||
| return make_float2(u, v); | |||||
| } | |||||
| ccl_device float2 direction_to_cubemap(float3 dir, int layout) | |||||
| { | |||||
| float max_axis = 0.0f; | |||||
Not Done Inline Actionsimplicit double to float casts, use 0.0f LazyDodo: implicit double to float casts, use `0.0f` | |||||
| float uc = 0.0f; | |||||
| float vc = 0.0f; | |||||
Not Done Inline ActionsMissing an f at the end of the floating point literal. Similarly for other areas in this patch. kevindietrich: Missing an `f` at the end of the floating point literal. Similarly for other areas in this… | |||||
| int index = -1; | |||||
| cubemap_xyz_to_uv(dir, uc, vc, max_axis, index); | |||||
| if (layout == NODE_ENVIRONMENT_CROSS_HORIZONTAL) | |||||
| return cubemap_uv_cross_horizontal(uc, vc, max_axis, index); | |||||
| else if (layout == NODE_ENVIRONMENT_STRIPE_HORIZONTAL) | |||||
| return cubemap_uv_stripe_horizontal(uc, vc, max_axis, index); | |||||
| else | |||||
| return cubemap_uv_stripe_vertical(uc, vc, max_axis, index); | |||||
| } | |||||
| ccl_device_inline float3 panorama_to_direction(ccl_constant KernelCamera *cam, float u, float v) | ccl_device_inline float3 panorama_to_direction(ccl_constant KernelCamera *cam, float u, float v) | ||||
| { | { | ||||
| switch (cam->panorama_type) { | switch (cam->panorama_type) { | ||||
| Context not available. | |||||
Use pointers instead of references.