Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/integrator/integrator_init_from_bake.h
| Show All 37 Lines | ccl_device_inline float bake_clamp_mirror_repeat(float u, float max) | ||||
| u = u - fu; | u = u - fu; | ||||
| return ((((int)fu) & 1) ? 1.0f - u : u) * max; | return ((((int)fu) & 1) ? 1.0f - u : u) * max; | ||||
| } | } | ||||
| /* Return false to indicate that this pixel is finished. | /* Return false to indicate that this pixel is finished. | ||||
| * Used by CPU implementation to not attempt to sample pixel for multiple samples once its known | * Used by CPU implementation to not attempt to sample pixel for multiple samples once its known | ||||
| * that the pixel did converge. */ | * that the pixel did converge. */ | ||||
| ccl_device bool integrator_init_from_bake(INTEGRATOR_STATE_ARGS, | ccl_device bool integrator_init_from_bake(KernelGlobals kg, | ||||
| IntegratorState state, | |||||
| ccl_global const KernelWorkTile *ccl_restrict tile, | ccl_global const KernelWorkTile *ccl_restrict tile, | ||||
| ccl_global float *render_buffer, | ccl_global float *render_buffer, | ||||
| const int x, | const int x, | ||||
| const int y, | const int y, | ||||
| const int scheduled_sample) | const int scheduled_sample) | ||||
| { | { | ||||
| PROFILING_INIT(kg, PROFILING_RAY_SETUP); | PROFILING_INIT(kg, PROFILING_RAY_SETUP); | ||||
| /* Initialize path state to give basic buffer access and allow early outputs. */ | /* Initialize path state to give basic buffer access and allow early outputs. */ | ||||
| path_state_init(INTEGRATOR_STATE_PASS, tile, x, y); | path_state_init(kg, state, tile, x, y); | ||||
| /* Check whether the pixel has converged and should not be sampled anymore. */ | /* Check whether the pixel has converged and should not be sampled anymore. */ | ||||
| if (!kernel_need_sample_pixel(INTEGRATOR_STATE_PASS, render_buffer)) { | if (!kernel_need_sample_pixel(kg, state, render_buffer)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* Always count the sample, even if the camera sample will reject the ray. */ | /* Always count the sample, even if the camera sample will reject the ray. */ | ||||
| const int sample = kernel_accum_sample(INTEGRATOR_STATE_PASS, render_buffer, scheduled_sample); | const int sample = kernel_accum_sample(kg, state, render_buffer, scheduled_sample); | ||||
| /* Setup render buffers. */ | /* Setup render buffers. */ | ||||
| const int index = INTEGRATOR_STATE(path, render_pixel_index); | const int index = INTEGRATOR_STATE(state, path, render_pixel_index); | ||||
| const int pass_stride = kernel_data.film.pass_stride; | const int pass_stride = kernel_data.film.pass_stride; | ||||
| render_buffer += index * pass_stride; | render_buffer += index * pass_stride; | ||||
| ccl_global float *primitive = render_buffer + kernel_data.film.pass_bake_primitive; | ccl_global float *primitive = render_buffer + kernel_data.film.pass_bake_primitive; | ||||
| ccl_global float *differential = render_buffer + kernel_data.film.pass_bake_differential; | ccl_global float *differential = render_buffer + kernel_data.film.pass_bake_differential; | ||||
| const int seed = __float_as_uint(primitive[0]); | const int seed = __float_as_uint(primitive[0]); | ||||
| int prim = __float_as_uint(primitive[1]); | int prim = __float_as_uint(primitive[1]); | ||||
| Show All 10 Lines | ccl_device bool integrator_init_from_bake(KernelGlobals kg, | ||||
| if (sample == 0) { | if (sample == 0) { | ||||
| filter_x = filter_y = 0.5f; | filter_x = filter_y = 0.5f; | ||||
| } | } | ||||
| else { | else { | ||||
| path_rng_2D(kg, rng_hash, sample, PRNG_FILTER_U, &filter_x, &filter_y); | path_rng_2D(kg, rng_hash, sample, PRNG_FILTER_U, &filter_x, &filter_y); | ||||
| } | } | ||||
| /* Initialize path state for path integration. */ | /* Initialize path state for path integration. */ | ||||
| path_state_init_integrator(INTEGRATOR_STATE_PASS, sample, rng_hash); | path_state_init_integrator(kg, state, sample, rng_hash); | ||||
| /* Barycentric UV with sub-pixel offset. */ | /* Barycentric UV with sub-pixel offset. */ | ||||
| float u = primitive[2]; | float u = primitive[2]; | ||||
| float v = primitive[3]; | float v = primitive[3]; | ||||
| float dudx = differential[0]; | float dudx = differential[0]; | ||||
| float dudy = differential[1]; | float dudy = differential[1]; | ||||
| float dvdx = differential[2]; | float dvdx = differential[2]; | ||||
| Show All 23 Lines | if (kernel_data.film.pass_background != PASS_UNUSED) { | ||||
| /* Setup and write ray. */ | /* Setup and write ray. */ | ||||
| Ray ray ccl_optional_struct_init; | Ray ray ccl_optional_struct_init; | ||||
| ray.P = zero_float3(); | ray.P = zero_float3(); | ||||
| ray.D = normalize(P); | ray.D = normalize(P); | ||||
| ray.t = FLT_MAX; | ray.t = FLT_MAX; | ||||
| ray.time = 0.5f; | ray.time = 0.5f; | ||||
| ray.dP = differential_zero_compact(); | ray.dP = differential_zero_compact(); | ||||
| ray.dD = differential_zero_compact(); | ray.dD = differential_zero_compact(); | ||||
| integrator_state_write_ray(INTEGRATOR_STATE_PASS, &ray); | integrator_state_write_ray(kg, state, &ray); | ||||
| /* Setup next kernel to execute. */ | /* Setup next kernel to execute. */ | ||||
| INTEGRATOR_PATH_INIT(DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND); | INTEGRATOR_PATH_INIT(DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Surface baking. */ | /* Surface baking. */ | ||||
| float3 N = (shader & SHADER_SMOOTH_NORMAL) ? triangle_smooth_normal(kg, Ng, prim, u, v) : Ng; | float3 N = (shader & SHADER_SMOOTH_NORMAL) ? triangle_smooth_normal(kg, Ng, prim, u, v) : Ng; | ||||
| Show All 21 Lines | else { | ||||
| differential3 dP; | differential3 dP; | ||||
| dP.dx = dPdu * dudx + dPdv * dvdx; | dP.dx = dPdu * dudx + dPdv * dvdx; | ||||
| dP.dy = dPdu * dudy + dPdv * dvdy; | dP.dy = dPdu * dudy + dPdv * dvdy; | ||||
| ray.dP = differential_make_compact(dP); | ray.dP = differential_make_compact(dP); | ||||
| ray.dD = differential_zero_compact(); | ray.dD = differential_zero_compact(); | ||||
| /* Write ray. */ | /* Write ray. */ | ||||
| integrator_state_write_ray(INTEGRATOR_STATE_PASS, &ray); | integrator_state_write_ray(kg, state, &ray); | ||||
| /* Setup and write intersection. */ | /* Setup and write intersection. */ | ||||
| Intersection isect ccl_optional_struct_init; | Intersection isect ccl_optional_struct_init; | ||||
| isect.object = kernel_data.bake.object_index; | isect.object = kernel_data.bake.object_index; | ||||
| isect.prim = prim; | isect.prim = prim; | ||||
| isect.u = u; | isect.u = u; | ||||
| isect.v = v; | isect.v = v; | ||||
| isect.t = 1.0f; | isect.t = 1.0f; | ||||
| isect.type = PRIMITIVE_TRIANGLE; | isect.type = PRIMITIVE_TRIANGLE; | ||||
| #ifdef __EMBREE__ | #ifdef __EMBREE__ | ||||
| isect.Ng = Ng; | isect.Ng = Ng; | ||||
| #endif | #endif | ||||
| integrator_state_write_isect(INTEGRATOR_STATE_PASS, &isect); | integrator_state_write_isect(kg, state, &isect); | ||||
| /* Setup next kernel to execute. */ | /* Setup next kernel to execute. */ | ||||
| const int shader_index = shader & SHADER_MASK; | const int shader_index = shader & SHADER_MASK; | ||||
| const int shader_flags = kernel_tex_fetch(__shaders, shader_index).flags; | const int shader_flags = kernel_tex_fetch(__shaders, shader_index).flags; | ||||
| if ((shader_flags & SD_HAS_RAYTRACE) || (kernel_data.film.pass_ao != PASS_UNUSED)) { | if ((shader_flags & SD_HAS_RAYTRACE) || (kernel_data.film.pass_ao != PASS_UNUSED)) { | ||||
| INTEGRATOR_PATH_INIT_SORTED(DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE, shader_index); | INTEGRATOR_PATH_INIT_SORTED(DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE, shader_index); | ||||
| } | } | ||||
| else { | else { | ||||
| INTEGRATOR_PATH_INIT_SORTED(DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE, shader_index); | INTEGRATOR_PATH_INIT_SORTED(DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE, shader_index); | ||||
| } | } | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||