Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/svm/svm_noisetex.h
| Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | return make_float4(100.0f + hash_float2_to_float(make_float2(seed, 0.0f)) * 100.0f, | ||||
| 100.0f + hash_float2_to_float(make_float2(seed, 3.0f)) * 100.0f); | 100.0f + hash_float2_to_float(make_float2(seed, 3.0f)) * 100.0f); | ||||
| } | } | ||||
| ccl_device void noise_texture_1d(float co, | ccl_device void noise_texture_1d(float co, | ||||
| float detail, | float detail, | ||||
| float roughness, | float roughness, | ||||
| float distortion, | float distortion, | ||||
| bool color_is_needed, | bool color_is_needed, | ||||
| float *value, | ccl_private float *value, | ||||
| float3 *color) | ccl_private float3 *color) | ||||
| { | { | ||||
| float p = co; | float p = co; | ||||
| if (distortion != 0.0f) { | if (distortion != 0.0f) { | ||||
| p += snoise_1d(p + random_float_offset(0.0f)) * distortion; | p += snoise_1d(p + random_float_offset(0.0f)) * distortion; | ||||
| } | } | ||||
| *value = fractal_noise_1d(p, detail, roughness); | *value = fractal_noise_1d(p, detail, roughness); | ||||
| if (color_is_needed) { | if (color_is_needed) { | ||||
| *color = make_float3(*value, | *color = make_float3(*value, | ||||
| fractal_noise_1d(p + random_float_offset(1.0f), detail, roughness), | fractal_noise_1d(p + random_float_offset(1.0f), detail, roughness), | ||||
| fractal_noise_1d(p + random_float_offset(2.0f), detail, roughness)); | fractal_noise_1d(p + random_float_offset(2.0f), detail, roughness)); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device void noise_texture_2d(float2 co, | ccl_device void noise_texture_2d(float2 co, | ||||
| float detail, | float detail, | ||||
| float roughness, | float roughness, | ||||
| float distortion, | float distortion, | ||||
| bool color_is_needed, | bool color_is_needed, | ||||
| float *value, | ccl_private float *value, | ||||
| float3 *color) | ccl_private float3 *color) | ||||
| { | { | ||||
| float2 p = co; | float2 p = co; | ||||
| if (distortion != 0.0f) { | if (distortion != 0.0f) { | ||||
| p += make_float2(snoise_2d(p + random_float2_offset(0.0f)) * distortion, | p += make_float2(snoise_2d(p + random_float2_offset(0.0f)) * distortion, | ||||
| snoise_2d(p + random_float2_offset(1.0f)) * distortion); | snoise_2d(p + random_float2_offset(1.0f)) * distortion); | ||||
| } | } | ||||
| *value = fractal_noise_2d(p, detail, roughness); | *value = fractal_noise_2d(p, detail, roughness); | ||||
| if (color_is_needed) { | if (color_is_needed) { | ||||
| *color = make_float3(*value, | *color = make_float3(*value, | ||||
| fractal_noise_2d(p + random_float2_offset(2.0f), detail, roughness), | fractal_noise_2d(p + random_float2_offset(2.0f), detail, roughness), | ||||
| fractal_noise_2d(p + random_float2_offset(3.0f), detail, roughness)); | fractal_noise_2d(p + random_float2_offset(3.0f), detail, roughness)); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device void noise_texture_3d(float3 co, | ccl_device void noise_texture_3d(float3 co, | ||||
| float detail, | float detail, | ||||
| float roughness, | float roughness, | ||||
| float distortion, | float distortion, | ||||
| bool color_is_needed, | bool color_is_needed, | ||||
| float *value, | ccl_private float *value, | ||||
| float3 *color) | ccl_private float3 *color) | ||||
| { | { | ||||
| float3 p = co; | float3 p = co; | ||||
| if (distortion != 0.0f) { | if (distortion != 0.0f) { | ||||
| p += make_float3(snoise_3d(p + random_float3_offset(0.0f)) * distortion, | p += make_float3(snoise_3d(p + random_float3_offset(0.0f)) * distortion, | ||||
| snoise_3d(p + random_float3_offset(1.0f)) * distortion, | snoise_3d(p + random_float3_offset(1.0f)) * distortion, | ||||
| snoise_3d(p + random_float3_offset(2.0f)) * distortion); | snoise_3d(p + random_float3_offset(2.0f)) * distortion); | ||||
| } | } | ||||
| *value = fractal_noise_3d(p, detail, roughness); | *value = fractal_noise_3d(p, detail, roughness); | ||||
| if (color_is_needed) { | if (color_is_needed) { | ||||
| *color = make_float3(*value, | *color = make_float3(*value, | ||||
| fractal_noise_3d(p + random_float3_offset(3.0f), detail, roughness), | fractal_noise_3d(p + random_float3_offset(3.0f), detail, roughness), | ||||
| fractal_noise_3d(p + random_float3_offset(4.0f), detail, roughness)); | fractal_noise_3d(p + random_float3_offset(4.0f), detail, roughness)); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device void noise_texture_4d(float4 co, | ccl_device void noise_texture_4d(float4 co, | ||||
| float detail, | float detail, | ||||
| float roughness, | float roughness, | ||||
| float distortion, | float distortion, | ||||
| bool color_is_needed, | bool color_is_needed, | ||||
| float *value, | ccl_private float *value, | ||||
| float3 *color) | ccl_private float3 *color) | ||||
| { | { | ||||
| float4 p = co; | float4 p = co; | ||||
| if (distortion != 0.0f) { | if (distortion != 0.0f) { | ||||
| p += make_float4(snoise_4d(p + random_float4_offset(0.0f)) * distortion, | p += make_float4(snoise_4d(p + random_float4_offset(0.0f)) * distortion, | ||||
| snoise_4d(p + random_float4_offset(1.0f)) * distortion, | snoise_4d(p + random_float4_offset(1.0f)) * distortion, | ||||
| snoise_4d(p + random_float4_offset(2.0f)) * distortion, | snoise_4d(p + random_float4_offset(2.0f)) * distortion, | ||||
| snoise_4d(p + random_float4_offset(3.0f)) * distortion); | snoise_4d(p + random_float4_offset(3.0f)) * distortion); | ||||
| } | } | ||||
| *value = fractal_noise_4d(p, detail, roughness); | *value = fractal_noise_4d(p, detail, roughness); | ||||
| if (color_is_needed) { | if (color_is_needed) { | ||||
| *color = make_float3(*value, | *color = make_float3(*value, | ||||
| fractal_noise_4d(p + random_float4_offset(4.0f), detail, roughness), | fractal_noise_4d(p + random_float4_offset(4.0f), detail, roughness), | ||||
| fractal_noise_4d(p + random_float4_offset(5.0f), detail, roughness)); | fractal_noise_4d(p + random_float4_offset(5.0f), detail, roughness)); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_noinline int svm_node_tex_noise(const KernelGlobals *kg, | ccl_device_noinline int svm_node_tex_noise(ccl_global const KernelGlobals *kg, | ||||
| ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| float *stack, | ccl_private float *stack, | ||||
| uint dimensions, | uint dimensions, | ||||
| uint offsets1, | uint offsets1, | ||||
| uint offsets2, | uint offsets2, | ||||
| int offset) | int offset) | ||||
| { | { | ||||
| uint vector_stack_offset, w_stack_offset, scale_stack_offset; | uint vector_stack_offset, w_stack_offset, scale_stack_offset; | ||||
| uint detail_stack_offset, roughness_stack_offset, distortion_stack_offset; | uint detail_stack_offset, roughness_stack_offset, distortion_stack_offset; | ||||
| uint value_stack_offset, color_stack_offset; | uint value_stack_offset, color_stack_offset; | ||||
| ▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines | |||||